@@ -41,7 +41,9 @@ def remove_annotations(_options={})
41
41
existing_text = File . read ( routes_file )
42
42
content , header_position = strip_annotations ( existing_text )
43
43
new_content = strip_on_removal ( content , header_position )
44
- if rewrite_contents ( existing_text , new_content )
44
+ new_text = new_content . join ( "\n " )
45
+
46
+ if rewrite_contents ( existing_text , new_text )
45
47
puts "Removed annotations from #{ routes_file } ."
46
48
end
47
49
end
@@ -155,18 +157,17 @@ def strip_on_removal(content, header_position)
155
157
content . pop while content . last == ''
156
158
end
157
159
160
+ # Make sure we end on a trailing newline.
161
+ content << '' unless content . last == ''
162
+
158
163
# TODO: If the user buried it in the middle, we should probably see about
159
164
# TODO: preserving a single line of space between the content above and
160
165
# TODO: below...
161
166
content
162
167
end
163
168
164
169
# @param [String, Array<String>]
165
- def rewrite_contents ( existing_text , new_content )
166
- # Make sure we end on a trailing newline.
167
- new_content << '' unless new_content . last == ''
168
- new_text = new_content . join ( "\n " )
169
-
170
+ def rewrite_contents ( existing_text , new_text )
170
171
if existing_text == new_text
171
172
puts "#{ routes_file } unchanged."
172
173
false
0 commit comments