Skip to content

Commit 9407dc6

Browse files
committed
Fix #214 where annotation for a single model is broken
1 parent d260a19 commit 9407dc6

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

lib/annotate/annotate_models.rb

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,28 +344,27 @@ def options_with_position(options, position_in)
344344
options.merge(:position=>(options[position_in] || options[:position]))
345345
end
346346

347-
# Return a list of the model files to annotate. If we have
348-
# command line arguments, they're assumed to be either
349-
# the underscore or CamelCase versions of model names.
350-
# Otherwise we take all the model files in the
351-
# model_dir directory.
347+
# Return a list of the model files to annotate.
348+
# If we have command line arguments, they're assumed to the path
349+
# of model files from root dir. Otherwise we take all the model files
350+
# in the model_dir directory.
352351
def get_model_files(options)
352+
models = []
353353
if(!options[:is_rake])
354-
models = ARGV.dup
355-
models.shift
356-
else
357-
models = []
354+
models = ARGV.dup.reject{|m| m.match(/^(.*)=/)}
358355
end
359-
models.reject!{|m| m.match(/^(.*)=/)}
356+
360357
if models.empty?
361358
begin
362359
model_dir.each do |dir|
363360
Dir.chdir(dir) do
364-
models.concat( if options[:ignore_model_sub_dir]
365-
Dir["*.rb"].map{ |f| [dir, f] }
366-
else
367-
Dir["**/*.rb"].reject{ |f| f["concerns/"] }.map{ |f| [dir, f] }
368-
end)
361+
lst =
362+
if options[:ignore_model_sub_dir]
363+
Dir["*.rb"].map{ |f| [dir, f] }
364+
else
365+
Dir["**/*.rb"].reject{ |f| f["concerns/"] }.map{ |f| [dir, f] }
366+
end
367+
models.concat(lst)
369368
end
370369
end
371370
rescue SystemCallError
@@ -375,6 +374,9 @@ def get_model_files(options)
375374
exit 1
376375
end
377376
end
377+
378+
puts "MODELS: #{models}"
379+
378380
models
379381
end
380382

0 commit comments

Comments
 (0)