Sha256: 54ccc871f053f9ac04163f67714ee8c028583eb90e2805b60ac4184a84545d4f

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

require 'entree'
require 'oj'

module Entree
  class Audit
    attr_reader :target

    def initialize(target)
      @target = target
    end

    def run
      perform_audit
    end

    def runner
      @runner ||= Runner.new(self.target)
    end

    private

    def perform_audit
      runner.run
      @output = runner.output
      parse_output
    end

    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)\.((?:[A-Z]+\d+,?)+)/
          record["code"] = $1
          record["techniques"] = $3.split /,/
        end

        record
      }

      @results = raw_results.group_by { |result| result['type'] }
    rescue Exception => e
      raise Entree::ParserError.new(e.message)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
entree-0.0.1 lib/entree/audit.rb