Commit db8b0999 by Shu Fujita Committed by Andrew W. Lee

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`.
parent d894fa29
...@@ -30,7 +30,11 @@ module AnnotateRoutes ...@@ -30,7 +30,11 @@ module AnnotateRoutes
def do_annotations(options = {}) def do_annotations(options = {})
if routes_file_exist? if routes_file_exist?
existing_text = File.read(routes_file) existing_text = File.read(routes_file)
if rewrite_contents_with_header(existing_text, header(options), options) content, header_position = strip_annotations(existing_text)
new_content = annotate_routes(header(options), content, header_position, options)
new_text = new_content.join("\n")
if rewrite_contents(existing_text, new_text)
puts "#{routes_file} annotated." puts "#{routes_file} annotated."
end end
else else
...@@ -62,20 +66,6 @@ module AnnotateRoutes ...@@ -62,20 +66,6 @@ module AnnotateRoutes
@routes_rb ||= File.join('config', 'routes.rb') @routes_rb ||= File.join('config', 'routes.rb')
end end
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)
new_text = new_content.join("\n")
if existing_text == new_text
puts "#{routes_file} unchanged."
false
else
File.open(routes_file, 'wb') { |f| f.puts(new_text) }
true
end
end
def header(options = {}) def header(options = {})
routes_map = app_routes_map(options) routes_map = app_routes_map(options)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment