|
14 | 14 | here = File.expand_path(File.dirname __FILE__) |
15 | 15 | $LOAD_PATH << "#{here}/../lib" |
16 | 16 |
|
17 | | -require 'annotate' |
18 | | -require 'annotate/parser' |
| 17 | +require 'annotate_rb' |
19 | 18 |
|
20 | | -Annotate.bootstrap_rake |
| 19 | +AnnotateRb::OldAnnotate.bootstrap_rake |
21 | 20 |
|
22 | | -# Annotate::Parser.parse takes in ARGV |
23 | | -# - Parses it and writes stuff to ENV |
24 | | -# - Returns some in a hash as seen below, this script will exit if `:exit` is defined |
25 | | -options_result = Annotate::Parser.parse(ARGV) |
| 21 | +options = ::AnnotateRb::Options.from({}, {}) |
26 | 22 |
|
27 | | -exit if options_result[:exit] |
| 23 | +if options[:models] |
| 24 | + # Eager load Models when we're annotating models |
| 25 | + AnnotateRb::OldAnnotate.eager_load(options) |
28 | 26 |
|
29 | | -# Not sure what this does yet |
30 | | -options = Annotate.setup_options( |
31 | | - # .setup_options takes in starting options. It looks like :is_rake is used later down the road so we want to capture |
32 | | - # if it was done via rake task or not. |
33 | | - # |
34 | | - # Looks like it's set in lib/tasks/annotate*.rake files |
35 | | - is_rake: ENV['is_rake'] && !ENV['is_rake'].empty? |
36 | | -) |
37 | | - |
38 | | -# Eager load Models when we're annotating models |
39 | | -Annotate.eager_load(options) if Annotate::Helpers.include_models? |
| 27 | + puts "Annotating models" |
| 28 | + AnnotateRb::ModelAnnotator::Annotator.send(options[:target_action], options) |
| 29 | +end |
40 | 30 |
|
41 | | -# options_result[:target_action] has possible values of: [:do_annotations, :remove_annotations] |
42 | | -AnnotateModels.send(options_result[:target_action], options) if Annotate::Helpers.include_models? |
43 | | -AnnotateRoutes.send(options_result[:target_action], options) if Annotate::Helpers.include_routes? |
| 31 | +if options[:routes] |
| 32 | + puts "Annotating routes" |
| 33 | + AnnotateRb::RouteAnnotator::Annotator.send(options[:target_action], options) |
| 34 | +end |
0 commit comments