Skip to content

Commit 3333c35

Browse files
nard-techdrwl
authored andcommitted
Refactor AnnotateRoutes.annotate_routes and .rewrite_contents_with_header (#729)
I refactored `AnnotateRoutes.annotate_routes` and `.rewrite_contents_with_header` in order to add an empty string to `new_content` array in `.annotate_routes`. I will refactor `.rewrite_contents_with_header` more, and remove `. rewrite_contents_with_header` in the next PR.
1 parent 13eeb96 commit 3333c35

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/annotate/annotate_routes.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ def routes_file
6565
def rewrite_contents_with_header(existing_text, header, options = {})
6666
content, header_position = strip_annotations(existing_text)
6767
new_content = annotate_routes(header, content, header_position, options)
68-
69-
# Make sure we end on a trailing newline.
70-
new_content << '' unless new_content.last == ''
7168
new_text = new_content.join("\n")
7269

7370
if existing_text == new_text
@@ -195,6 +192,9 @@ def annotate_routes(header, content, header_position, options = {})
195192
new_content = magic_comments_map + content + header
196193
end
197194

195+
# Make sure we end on a trailing newline.
196+
new_content << '' unless new_content.last == ''
197+
198198
new_content
199199
end
200200

0 commit comments

Comments
 (0)