mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-17 22:27:57 +00:00
main object is now CMock instead of CMockSetup. Cleaned up the way objects are created, particularly related to plugins.
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@19 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
+40
-2
@@ -1,4 +1,42 @@
|
||||
$here = File.dirname __FILE__
|
||||
require "#{$here}/cmock_setup"
|
||||
require "#{$here}/cmock_generator"
|
||||
require "#{$here}/cmock_header_parser"
|
||||
require "#{$here}/cmock_generator"
|
||||
require "#{$here}/cmock_file_writer"
|
||||
require "#{$here}/cmock_config"
|
||||
require "#{$here}/cmock_plugin_manager"
|
||||
require "#{$here}/cmock_generator_utils"
|
||||
|
||||
class CMock
|
||||
|
||||
def initialize(mocks_path='mocks', includes=[], use_cexception=true, allow_ignore_mock=false)
|
||||
@mocks_path = mocks_path
|
||||
@includes = includes
|
||||
@use_cexception = use_cexception
|
||||
@allow_ignore_mock = allow_ignore_mock
|
||||
end
|
||||
|
||||
def setup_mocks(files)
|
||||
files.each do |src|
|
||||
generate_mock src
|
||||
end
|
||||
end
|
||||
|
||||
private ###############################
|
||||
|
||||
def generate_mock(src)
|
||||
name = File.basename(src, '.h')
|
||||
path = File.dirname(src)
|
||||
|
||||
cm_config = CMockConfig.new(path, @mocks_path, @includes, @use_cexception, @allow_ignore_mock)
|
||||
cm_parser = CMockHeaderParser.new(File.read(src))
|
||||
cm_writer = CMockFileWriter.new(cm_config)
|
||||
cm_gen_utils = CMockGeneratorUtils.new(cm_config)
|
||||
cm_gen_plugins = CMockPluginManager.new(cm_config, cm_gen_utils).get_generator_plugins
|
||||
cm_generator = CMockGenerator.new(cm_config, name, cm_writer, cm_gen_utils, cm_gen_plugins)
|
||||
|
||||
puts "Creating mock for #{name}..."
|
||||
|
||||
parsed_stuff = cm_parser.parse
|
||||
cm_generator.create_mock(parsed_stuff)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user