class Cane::Runner

Orchestrates the running of checks per the provided configuration, and hands the result to a formatter for display. This is the core of the application, but for the actual entry point see `Cane::CLI`.

Attributes

checks[R]
opts[R]

Public Class Methods

new(spec) click to toggle source
# File lib/cane/runner.rb, line 17
def initialize(spec)
  @opts = spec
  @checks = spec[:checks]
end

Public Instance Methods

run() click to toggle source
# File lib/cane/runner.rb, line 22
def run
  outputter.print formatter.new(violations, opts)

  violations.length <= opts.fetch(:max_violations)
end

Protected Instance Methods

formatter() click to toggle source
# File lib/cane/runner.rb, line 42
def formatter
  if opts[:json]
    JsonFormatter
  else
    ViolationFormatter
  end
end
outputter() click to toggle source
# File lib/cane/runner.rb, line 38
def outputter
  opts.fetch(:out, $stdout)
end
violations() click to toggle source
# File lib/cane/runner.rb, line 32
def violations
  @violations ||= checks.
    map {|check| check.new(opts).violations }.
    flatten
end