Skip to content

Commit b006985

Browse files
committed
Make -R work for all four task types.
1 parent 69cd69c commit b006985

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

lib/annotate/annotate_models.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ def annotate_model_file(annotated, file, header, options)
407407
end
408408

409409
def remove_annotations(options={})
410+
if options[:require]
411+
options[:require].each do |path|
412+
require path
413+
end
414+
end
415+
410416
self.model_dir = options[:model_dir] if options[:model_dir]
411417
deannotated = []
412418
deannotated_klass = false

lib/annotate/annotate_routes.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ module AnnotateRoutes
2323
def self.do_annotate(options={})
2424
return unless(routes_exists?)
2525

26+
if options[:require]
27+
options[:require].each do |path|
28+
require path
29+
end
30+
end
31+
2632
position_after = options[:position_in_routes] != 'before'
2733

2834
routes_map = `rake routes`.split(/\n/, -1)
@@ -68,6 +74,12 @@ def self.do_annotate(options={})
6874
def self.remove_annotations(options={})
6975
return unless(routes_exists?)
7076

77+
if options[:require]
78+
options[:require].each do |path|
79+
require path
80+
end
81+
end
82+
7183
(content, where_header_found) = strip_annotations(File.read(routes_file))
7284

7385
content = strip_on_removal(content, where_header_found)

lib/tasks/annotate_models.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ task :remove_annotation => :environment do
4444

4545
options={ :is_rake => true }
4646
options[:model_dir] = ENV['model_dir']
47+
options[:require] = ENV['require'] ? ENV['require'].split(',') : []
4748
options[:trace] = ENV['trace'] =~ true_re
4849
AnnotateModels.remove_annotations(options)
4950
end

lib/tasks/annotate_routes.rake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ task :annotate_routes => :environment do
55

66
options={}
77
options[:position_in_routes] = ENV['position_in_routes'] || ENV['position'] || 'after'
8+
options[:require] = ENV['require'] ? ENV['require'].split(',') : []
89
AnnotateRoutes.do_annotate(options)
910
end
1011

@@ -14,5 +15,6 @@ task :remove_routes => :environment do
1415
require "#{annotate_lib}/annotate/annotate_routes"
1516

1617
options={}
18+
options[:require] = ENV['require'] ? ENV['require'].split(',') : []
1719
AnnotateRoutes.remove_annotations(options)
1820
end

0 commit comments

Comments
 (0)