Class: RouteGuard::Inspector

Inherits:
Object
  • Object
show all
Defined in:
lib/route_guard/inspector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = Configuration.new) ⇒ Inspector

Returns a new instance of Inspector.



11
12
13
# File 'lib/route_guard/inspector.rb', line 11

def initialize(config = Configuration.new)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/route_guard/inspector.rb', line 9

def config
  @config
end

Instance Method Details

#format(report, formatter_sym, io = $stdout) ⇒ Object



32
33
34
35
# File 'lib/route_guard/inspector.rb', line 32

def format(report, formatter_sym, io = $stdout)
  formatter = load_formatter(formatter_sym)
  formatter.format(report, io)
end

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/route_guard/inspector.rb', line 15

def run
  $stderr.puts "RouteGuard: Loading Rails environment and reloading routes..."

  routes = RouteLoader.load

  $stderr.puts "RouteGuard: Loaded #{routes.size} routes. Running #{config.enabled_rules.size} inspections..."

  report = Analyzer.analyze(routes, config.enabled_rules, {
    strict: config.strict,
    verbose: config.verbose
  })

  $stderr.puts "RouteGuard: Inspections complete."

  report
end