Commit 4a8e2a03 by Ben Langfeld

Add the ability to ignore subdirectories of the models dir

parent 9c68c8c9
...@@ -48,6 +48,11 @@ OptionParser.new do |opts| ...@@ -48,6 +48,11 @@ OptionParser.new do |opts|
ENV['model_dir'] = dir ENV['model_dir'] = dir
end end
opts.on('--ignore-model-subdirectories',
"Ignore subdirectories of the models directory") do |dir|
ENV['ignore_model_sub_dir'] = "yes"
end
opts.on('-R', '--require path', opts.on('-R', '--require path',
"Additional files to require before loading models") do |path| "Additional files to require before loading models") do |path|
if ENV['require'] if ENV['require']
......
...@@ -211,7 +211,11 @@ module AnnotateModels ...@@ -211,7 +211,11 @@ module AnnotateModels
if models.empty? if models.empty?
begin begin
Dir.chdir(model_dir) do Dir.chdir(model_dir) do
models = Dir["**/*.rb"] models = if ENV['ignore_model_sub_dir']
Dir["*.rb"]
else
Dir["**/*.rb"]
end
end end
rescue SystemCallError rescue SystemCallError
puts "No models found in directory '#{model_dir}'." puts "No models found in directory '#{model_dir}'."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment