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.rewrite_contents #734

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
5 changes: 4 additions & 1 deletion lib/annotate/annotate_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def do_annotations(options = {})

if rewrite_contents(existing_text, new_text)
puts "#{routes_file} annotated."
else
puts "#{routes_file} unchanged."
end
else
puts "Can't find routes.rb"
Expand All @@ -50,6 +52,8 @@ def remove_annotations(_options={})
new_text = new_content.join("\n")
if rewrite_contents(existing_text, new_text)
puts "Removed annotations from #{routes_file}."
else
puts "#{routes_file} unchanged."
end
else
puts "Can't find routes.rb"
Expand Down Expand Up @@ -156,7 +160,6 @@ def strip_on_removal(content, header_position)

def rewrite_contents(existing_text, new_text)
if existing_text == new_text
puts "#{routes_file} unchanged."
false
else
File.open(routes_file, 'wb') { |f| f.puts(new_text) }
Expand Down