mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-23 11:39:56 +00:00
- foundation work towards more awesome pointer/array handling. not there yet, so don't try this at home kids.
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@145 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
|
||||
require "cmock_generator_plugin_expect.rb"
|
||||
require "cmock_generator_plugin_ignore.rb"
|
||||
require "cmock_generator_plugin_cexception.rb"
|
||||
|
||||
class CMockPluginManager
|
||||
|
||||
attr_accessor :plugins
|
||||
|
||||
def initialize(config, utils)
|
||||
plugins_to_load = config.plugins
|
||||
@plugins = []
|
||||
@plugins << CMockGeneratorPluginExpect.new( config, utils )
|
||||
@plugins << CMockGeneratorPluginCException.new( config, utils ) if plugins_to_load.include? 'cexception'
|
||||
@plugins << CMockGeneratorPluginIgnore.new( config, utils ) if plugins_to_load.include? 'ignore'
|
||||
plugins_to_load = ["expect", config.plugins].flatten.uniq.compact
|
||||
plugins_to_load.each do |plugin|
|
||||
plugin_name = plugin.to_s
|
||||
object_name = "CMockGeneratorPlugin" + camelize(plugin_name)
|
||||
begin
|
||||
unless (Object.const_defined? object_name)
|
||||
require "cmock_generator_plugin_#{plugin_name.downcase}.rb"
|
||||
end
|
||||
@plugins << eval("#{object_name}.new(config, utils)")
|
||||
rescue
|
||||
raise "Unable to load plugin '#{plugin_name}'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def run(method, args=nil)
|
||||
@@ -22,4 +27,8 @@ class CMockPluginManager
|
||||
return @plugins.collect{ |plugin| plugin.send(method, args) if plugin.respond_to?(method) }.flatten.join
|
||||
end
|
||||
end
|
||||
|
||||
def camelize(lower_case_and_underscored_word)
|
||||
lower_case_and_underscored_word.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user