Skip to content

Commit db8b099

Browse files
nard-techdrwl
authored andcommitted
Remove AnnotateRoutes.rewrite_contents_with_header (#730)
I removed `AnnotateRoutes.rewrite_contents_with_header` because the logic of `AnnotateRoutes.rewrite_contents_with_header` is as same as `.rewrite_contents`.
1 parent d894fa2 commit db8b099

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

lib/annotate/annotate_routes.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ class << self
3030
def do_annotations(options = {})
3131
if routes_file_exist?
3232
existing_text = File.read(routes_file)
33-
if rewrite_contents_with_header(existing_text, header(options), options)
33+
content, header_position = strip_annotations(existing_text)
34+
new_content = annotate_routes(header(options), content, header_position, options)
35+
new_text = new_content.join("\n")
36+
37+
if rewrite_contents(existing_text, new_text)
3438
puts "#{routes_file} annotated."
3539
end
3640
else
@@ -62,20 +66,6 @@ def routes_file
6266
@routes_rb ||= File.join('config', 'routes.rb')
6367
end
6468

65-
def rewrite_contents_with_header(existing_text, header, options = {})
66-
content, header_position = strip_annotations(existing_text)
67-
new_content = annotate_routes(header, content, header_position, options)
68-
new_text = new_content.join("\n")
69-
70-
if existing_text == new_text
71-
puts "#{routes_file} unchanged."
72-
false
73-
else
74-
File.open(routes_file, 'wb') { |f| f.puts(new_text) }
75-
true
76-
end
77-
end
78-
7969
def header(options = {})
8070
routes_map = app_routes_map(options)
8171

0 commit comments

Comments
 (0)