Skip to content

Commit 6ecdc5a

Browse files
nard-techvfonic
authored andcommitted
Refactor AnnotateRoutes.rewrite_contents (ctran#734)
I moved `puts` from `AnnotateRoutes.rewrite_contents` to `.do_annotations` and `.remove_annotations`.
1 parent 4144e78 commit 6ecdc5a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/annotate/annotate_routes.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def do_annotations(options = {})
3636

3737
if rewrite_contents(existing_text, new_text)
3838
puts "#{routes_file} annotated."
39+
else
40+
puts "#{routes_file} unchanged."
3941
end
4042
else
4143
puts "Can't find routes.rb"
@@ -50,6 +52,8 @@ def remove_annotations(_options={})
5052
new_text = new_content.join("\n")
5153
if rewrite_contents(existing_text, new_text)
5254
puts "Removed annotations from #{routes_file}."
55+
else
56+
puts "#{routes_file} unchanged."
5357
end
5458
else
5559
puts "Can't find routes.rb"
@@ -156,7 +160,6 @@ def strip_on_removal(content, header_position)
156160

157161
def rewrite_contents(existing_text, new_text)
158162
if existing_text == new_text
159-
puts "#{routes_file} unchanged."
160163
false
161164
else
162165
File.open(routes_file, 'wb') { |f| f.puts(new_text) }

0 commit comments

Comments
 (0)