Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor AnnotateRoutes.annotate_routes and .rewrite_contents_with_header #729

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -196,6 +193,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