Commit 8341983f by Emil Sågfors Committed by Cuong Tran

Prevent root_dir option from being empty (#448)

* Prevent root_dir option from being empty When setting root_dir to an empty string (as is done in the default rake task config) this line previously caused root_dir to become an empty array. This in turn caused factories, specs etc not to be annotated. This is just a quick band-aid on a larger problem. We have option parsing spread out over many different places, with slight mismatches like this in the assumptions made. * Handle blank values & comma-separated strings in AnnotateModels.root_dir These cases are currently handled (inconsistently) in the different option parsing routines. * Pass root_dir forward unmodified The different cases are now handled inside AnnotateModels
parent 82a2c403
......@@ -88,7 +88,6 @@ module Annotate
end
options[:model_dir] = ['app/models'] if options[:model_dir].empty?
options[:root_dir] = [''] if options[:root_dir].empty?
options[:wrapper_open] ||= options[:wrapper]
options[:wrapper_close] ||= options[:wrapper]
......
......@@ -80,7 +80,13 @@ module AnnotateModels
attr_writer :model_dir
def root_dir
@root_dir.is_a?(Array) ? @root_dir : [@root_dir || '']
if @root_dir.blank?
['']
elsif @root_dir.is_a?(String)
@root_dir.split(',')
else
@root_dir
end
end
attr_writer :root_dir
......
......@@ -21,7 +21,7 @@ task annotate_models: :environment do
options[:show_indexes] = Annotate.true?(ENV['show_indexes'])
options[:simple_indexes] = Annotate.true?(ENV['simple_indexes'])
options[:model_dir] = ENV['model_dir'] ? ENV['model_dir'].split(',') : ['app/models']
options[:root_dir] = ENV['root_dir'] ? ENV['root_dir'].split(',') : ['']
options[:root_dir] = ENV['root_dir']
options[:include_version] = Annotate.true?(ENV['include_version'])
options[:require] = ENV['require'] ? ENV['require'].split(',') : []
options[:exclude_tests] = Annotate.true?(ENV['exclude_tests'])
......
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