From 9407dc679937105429946790bbc7040ed15f5883 Mon Sep 17 00:00:00 2001 From: "cuong.tran" Date: Sat, 7 Mar 2015 16:33:31 -0800 Subject: [PATCH] Fix #214 where annotation for a single model is broken --- lib/annotate/annotate_models.rb | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/annotate/annotate_models.rb b/lib/annotate/annotate_models.rb index 5a796ff41..36d8854a4 100755 --- a/lib/annotate/annotate_models.rb +++ b/lib/annotate/annotate_models.rb @@ -344,28 +344,27 @@ def options_with_position(options, position_in) options.merge(:position=>(options[position_in] || options[:position])) end - # Return a list of the model files to annotate. If we have - # command line arguments, they're assumed to be either - # the underscore or CamelCase versions of model names. - # Otherwise we take all the model files in the - # model_dir directory. + # Return a list of the model files to annotate. + # If we have command line arguments, they're assumed to the path + # of model files from root dir. Otherwise we take all the model files + # in the model_dir directory. def get_model_files(options) + models = [] if(!options[:is_rake]) - models = ARGV.dup - models.shift - else - models = [] + models = ARGV.dup.reject{|m| m.match(/^(.*)=/)} end - models.reject!{|m| m.match(/^(.*)=/)} + if models.empty? begin model_dir.each do |dir| Dir.chdir(dir) do - models.concat( if options[:ignore_model_sub_dir] - Dir["*.rb"].map{ |f| [dir, f] } - else - Dir["**/*.rb"].reject{ |f| f["concerns/"] }.map{ |f| [dir, f] } - end) + lst = + if options[:ignore_model_sub_dir] + Dir["*.rb"].map{ |f| [dir, f] } + else + Dir["**/*.rb"].reject{ |f| f["concerns/"] }.map{ |f| [dir, f] } + end + models.concat(lst) end end rescue SystemCallError @@ -375,6 +374,9 @@ def get_model_files(options) exit 1 end end + + puts "MODELS: #{models}" + models end