Class: RoutesApiSpecGenerator::Generator
- Inherits:
-
Object
- Object
- RoutesApiSpecGenerator::Generator
- Defined in:
- lib/routes_api_spec_generator/generator.rb
Constant Summary collapse
- OUTPUT_DIR =
'spec/requests'
Instance Method Summary collapse
-
#initialize(rails_root:, force: false, dry_run: false, namespace: '/api/v1') ⇒ Generator
constructor
A new instance of Generator.
- #run ⇒ Object
Constructor Details
#initialize(rails_root:, force: false, dry_run: false, namespace: '/api/v1') ⇒ Generator
Returns a new instance of Generator.
9 10 11 12 13 14 15 16 |
# File 'lib/routes_api_spec_generator/generator.rb', line 9 def initialize(rails_root:, force: false, dry_run: false, namespace: '/api/v1') @rails_root = Pathname.new(rails_root) @force = force @dry_run = dry_run @namespace = namespace @config = ConfigLoader.new(rails_root: @rails_root).load @inspector = ControllerInspector.new(rails_root: @rails_root) end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/routes_api_spec_generator/generator.rb', line 18 def run require_routes! routes = RouteCollector.new(routes: @routes, namespace_prefix: @namespace).collect endpoints = routes.map { |route| build_endpoint(route) } results = endpoints.map { |endpoint| write_endpoint(endpoint) } summary(results) end |