Method: AnnotateRoutes.do_annotations

Defined in:
lib/annotated/annotate_routes.rb

.do_annotations(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/annotated/annotate_routes.rb', line 26

def do_annotations(options = {})
  if routes_file_exist?
    existing_text = File.read(routes_file)
    content, header_position = Helpers.strip_annotations(existing_text)
    new_content = annotate_routes(HeaderGenerator.generate(options), content, header_position, options)
    new_text = new_content.join("\n")
    if rewrite_contents(existing_text, new_text, options[:frozen])
      puts "#{routes_file} was annotated."
    else
      puts "#{routes_file} was not changed."
    end
  else
    puts "#{routes_file} could not be found."
  end
end