Class: AwesomeAnnotate::Route

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/awesome_annotate/route.rb

Instance Method Summary collapse

Instance Method Details

#annotateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/awesome_annotate/route.rb', line 9

def annotate
  abort "Rails application path is required" unless env_file_path.exist?

  apply env_file_path.to_s

  inspector = ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes)
  formatter = ActionDispatch::Routing::ConsoleFormatter::Sheet.new

  routes = inspector.format(formatter, {})
  route_message = parse_routes(routes)

  insert_file_before_class(route_file_path, route_message)

  say "annotate routes in #{route_file_path}"
end