Class: AnnotateRb::ModelAnnotator::ModelFilesGetter
- Inherits:
-
Object
- Object
- AnnotateRb::ModelAnnotator::ModelFilesGetter
- Defined in:
- lib/annotate_rb/model_annotator/model_files_getter.rb
Class Method Summary collapse
-
.call(options) ⇒ Object
Return a list of the model files to annotate.
Class Method Details
.call(options) ⇒ Object
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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/annotate_rb/model_annotator/model_files_getter.rb', line 11 def call() model_files = list_model_files_from_argument() return model_files if model_files.any? [:model_dir].each do |dir| Dir.chdir(dir) do list = if [:ignore_model_sub_dir] Dir["*.rb"].map { |f| [dir, f] } else Dir["**/*.rb"] .reject { |f| f["concerns/"] } .map { |f| [dir, f] } end model_files.concat(list) end end model_files rescue SystemCallError warn "No models found in directory '#{[:model_dir].join("', '")}'." warn "Either specify models on the command line, or use the --model-dir option." warn "Call 'annotaterb --help' for more info." # exit 1 # TODO: Return exit code back to caller. Right now it messes up RSpec being able to run end |