Skip to content

Commit

Permalink
Refactor AnnotateRoutes.annotate_routes and .rewrite_contents_with_he…
Browse files Browse the repository at this point in the history
…ader (ctran#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.
  • Loading branch information
nard-tech authored and vfonic committed May 8, 2020
1 parent 266afe0 commit 76dddea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/annotate/annotate_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ def routes_file
def rewrite_contents_with_header(existing_text, header, options = {})
content, header_position = strip_annotations(existing_text)
new_content = annotate_routes(header, content, header_position, options)

# Make sure we end on a trailing newline.
new_content << '' unless new_content.last == ''
new_text = new_content.join("\n")

if existing_text == new_text
Expand Down Expand Up @@ -195,6 +192,9 @@ def annotate_routes(header, content, header_position, options = {})
new_content = magic_comments_map + content + header
end

# Make sure we end on a trailing newline.
new_content << '' unless new_content.last == ''

new_content
end

Expand Down

0 comments on commit 76dddea

Please sign in to comment.