Class: AwesomeAnnotate::Route
- Inherits:
-
Thor
- Object
- Thor
- AwesomeAnnotate::Route
- Includes:
- Thor::Actions
- Defined in:
- lib/awesome_annotate/route.rb
Instance Method Summary collapse
- #annotate ⇒ Object
-
#initialize(params = {}) ⇒ Route
constructor
A new instance of Route.
Constructor Details
#initialize(params = {}) ⇒ Route
Returns a new instance of Route.
8 9 10 11 12 |
# File 'lib/awesome_annotate/route.rb', line 8 def initialize(params = {}) super() @env_file_path = Pathname.new(params[:env_file_path] || 'config/environment.rb') @route_file_path = Pathname.new(params[:route_file_path] || 'config/routes.rb') end |
Instance Method Details
#annotate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/awesome_annotate/route.rb', line 15 def annotate raise "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, {}) = parse_routes(routes) raise "Route file not found" unless @route_file_path.exist? insert_file_before_class(@route_file_path, ) say "annotate routes in #{@route_file_path}" end |