From da006b3fb4e7e265b903374d8878d42317b99776 Mon Sep 17 00:00:00 2001 From: Shu Fujita Date: Thu, 9 Jan 2020 00:22:35 +0900 Subject: [PATCH] Refactor AnnotateRoutes.annotate_routes and .rewrite_contents_with_header --- lib/annotate/annotate_routes.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/annotate/annotate_routes.rb b/lib/annotate/annotate_routes.rb index 37fc452ca..5c1f71275 100644 --- a/lib/annotate/annotate_routes.rb +++ b/lib/annotate/annotate_routes.rb @@ -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 @@ -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