class Entree::Audit

Attributes

target[R]

Public Class Methods

new(target) click to toggle source
# File lib/entree/audit.rb, line 8
def initialize(target)
  @target = target
end

Public Instance Methods

run() click to toggle source
# File lib/entree/audit.rb, line 12
def run
  perform_audit
end
runner() click to toggle source
# File lib/entree/audit.rb, line 16
def runner
  @runner ||= Runner.new(self.target)
end

Private Instance Methods

parse_output() click to toggle source
# File lib/entree/audit.rb, line 28
def parse_output
  # refactor into new class
  raw_results = Oj.load(@output).map {|record|
    if record["code"][0..3] == "WCAG"
      record["code"].match /(WCAG2A+\.\w+?\.Guideline(\d_\d)\.\2_\d)(?:_\w)?\.((?:[A-Z]+\d+,?)+)/
      record["code"] = $1
      record["techniques"] = $3.to_s.split /,/
    end

    record
  }

  @results = raw_results.group_by { |result| result['type'] }
rescue Exception => e
  raise Entree::ParserError.new(e.message)
end
perform_audit() click to toggle source
# File lib/entree/audit.rb, line 22
def perform_audit
  runner.run
  @output = runner.output
  parse_output
end