Skip to content

Commit

Permalink
Fix #214 where annotation for a single model is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
ctran committed Mar 8, 2015
1 parent d260a19 commit 9407dc6
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions lib/annotate/annotate_models.rb
Expand Up @@ -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
Expand All @@ -375,6 +374,9 @@ def get_model_files(options)
exit 1
end
end

puts "MODELS: #{models}"

models
end

Expand Down

0 comments on commit 9407dc6

Please sign in to comment.