File tree Expand file tree Collapse file tree 4 files changed +41
-20
lines changed Expand file tree Collapse file tree 4 files changed +41
-20
lines changed Original file line number Diff line number Diff line change @@ -25,30 +25,14 @@ module AnnotateRoutes
25
25
class << self
26
26
def do_annotations ( options = { } )
27
27
routes_file = File . join ( 'config' , 'routes.rb' )
28
- processor = AnnotationProcessor . new ( options , routes_file )
29
- if processor . routes_file_exist?
30
- if processor . update
31
- puts "#{ routes_file } was annotated."
32
- else
33
- puts "#{ routes_file } was not changed."
34
- end
35
- else
36
- puts "#{ routes_file } could not be found."
37
- end
28
+ result = AnnotationProcessor . execute ( options , routes_file )
29
+ puts result
38
30
end
39
31
40
32
def remove_annotations ( options = { } )
41
33
routes_file = File . join ( 'config' , 'routes.rb' )
42
- processor = RemovalProcessor . new ( options , routes_file )
43
- if processor . routes_file_exist?
44
- if processor . update
45
- puts "Annotations were removed from #{ routes_file } ."
46
- else
47
- puts "#{ routes_file } was not changed (Annotation did not exist)."
48
- end
49
- else
50
- puts "#{ routes_file } could not be found."
51
- end
34
+ result = RemovalProcessor . execute ( options , routes_file )
35
+ puts result
52
36
end
53
37
end
54
38
end
Original file line number Diff line number Diff line change @@ -6,6 +6,19 @@ module AnnotateRoutes
6
6
class AnnotationProcessor < BaseProcessor
7
7
include Helpers
8
8
9
+ # @return [String]
10
+ def execute
11
+ if routes_file_exist?
12
+ if update
13
+ "#{ routes_file } was annotated."
14
+ else
15
+ "#{ routes_file } was not changed."
16
+ end
17
+ else
18
+ "#{ routes_file } could not be found."
19
+ end
20
+ end
21
+
9
22
private
10
23
11
24
def header
Original file line number Diff line number Diff line change 1
1
module AnnotateRoutes
2
2
class BaseProcessor
3
+ class << self
4
+ # @param options [Hash]
5
+ # @param routes_file [String]
6
+ # @return [String]
7
+ def execute ( options , routes_file )
8
+ new ( options , routes_file ) . execute
9
+ end
10
+
11
+ private :new
12
+ end
13
+
3
14
def initialize ( options , routes_file )
4
15
@options = options
5
16
@routes_file = routes_file
Original file line number Diff line number Diff line change 2
2
3
3
module AnnotateRoutes
4
4
class RemovalProcessor < BaseProcessor
5
+ # @return [String]
6
+ def execute
7
+ if routes_file_exist?
8
+ if update
9
+ "Annotations were removed from #{ routes_file } ."
10
+ else
11
+ "#{ routes_file } was not changed (Annotation did not exist)."
12
+ end
13
+ else
14
+ "#{ routes_file } could not be found."
15
+ end
16
+ end
17
+
5
18
private
6
19
7
20
def generate_new_content_array ( content , header_position )
You can’t perform that action at this time.
0 commit comments