diff --git a/docs/CMock Summary.odt b/docs/CMock Summary.odt index 8e44969..fc04579 100644 Binary files a/docs/CMock Summary.odt and b/docs/CMock Summary.odt differ diff --git a/docs/CMock Summary.pdf b/docs/CMock Summary.pdf index 21f58e8..d9be965 100644 Binary files a/docs/CMock Summary.pdf and b/docs/CMock Summary.pdf differ diff --git a/lib/cmock.rb b/lib/cmock.rb index eb73c9a..4208dd2 100644 --- a/lib/cmock.rb +++ b/lib/cmock.rb @@ -2,7 +2,7 @@ # CMock Project - Automatic Mock Generation for C # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams # [Released under MIT License. Please refer to license.txt for details] -# ========================================== +# ========================================== [ "../config/production_environment", "cmock_header_parser", @@ -14,9 +14,9 @@ "cmock_unityhelper_parser"].each {|req| require "#{File.expand_path(File.dirname(__FILE__))}/#{req}"} class CMock - + def initialize(options=nil) - cm_config = CMockConfig.new(options) + cm_config = CMockConfig.new(options) cm_unityhelper = CMockUnityHelperParser.new(cm_config) cm_writer = CMockFileWriter.new(cm_config) cm_gen_utils = CMockGeneratorUtils.new(cm_config, {:unity_helper => cm_unityhelper}) @@ -25,7 +25,7 @@ class CMock @cm_generator = CMockGenerator.new(cm_config, cm_writer, cm_gen_utils, cm_gen_plugins) @silent = (cm_config.verbosity < 2) end - + def setup_mocks(files) [files].flatten.each do |src| generate_mock src @@ -41,25 +41,46 @@ class CMock end end +def option_maker(options, key, val) + options = options || {} + options[key.to_sym] = + if val.chr == ":" + val.to_sym + elsif val.include? ";" + val.split(';') + elsif val == 'true' + true + elsif val == 'false' + false + elsif val =~ /^\d+$/ + val.to_i + else + val + end + options +end + # Command Line Support ############################### - + if ($0 == __FILE__) usage = "usage: ruby #{__FILE__} (-oOptionsFile) File(s)ToMock" - + if (!ARGV[0]) puts usage exit 1 end - - options = nil + + options = {} filelist = [] ARGV.each do |arg| - if (arg =~ /^-o(\w*)/) + if (arg =~ /^-o\"?([a-zA-Z0-9._\\\/:\s]+)\"?/) options = arg.gsub(/^-o/,'') + elsif (arg =~ /^--([a-zA-Z0-9._\\\/:\s]+)=\"?([a-zA-Z0-9._\\\/:\s\;]+)\"?/) + options = option_maker(options, $1, $2) else filelist << arg end end - + CMock.new(options).setup_mocks(filelist) -end \ No newline at end of file +end