Class: RailsRouteChecker::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-route-checker/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
9
# File 'lib/rails-route-checker/runner.rb', line 5

def initialize(**opts)
  @options = { ignored_controllers: [], ignored_paths: [], ignored_path_whitelist: {} }
  @options.merge!(RailsRouteChecker::ConfigFile.new(opts[:config_file]).config) if opts[:config_file]
  @options.merge!(opts)
end

Instance Method Details

#issuesObject



11
12
13
14
15
16
# File 'lib/rails-route-checker/runner.rb', line 11

def issues
  @issues ||= {
    missing_actions: app_interface.routes_without_actions,
    missing_routes: app_interface.undefined_path_method_calls
  }
end

#issues?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rails-route-checker/runner.rb', line 18

def issues?
  issues.values.flatten(1).count.positive?
end

#outputObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/rails-route-checker/runner.rb', line 22

def output
  output_lines = []
  output_lines += missing_actions_output if issues[:missing_actions].any?
  if issues[:missing_routes].any?
    output_lines << "\n" if output_lines.any?
    output_lines += missing_routes_output
  end
  output_lines = ['All good in the hood'] if output_lines.empty?
  output_lines.join("\n")
end