Class: AxeCuprite::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/axe/cuprite/results.rb

Overview

Wraps the (slimmed) payload returned by axe.run. We deliberately only carry ‘violations` and `incomplete` across the CDP boundary plus a little metadata — the full results object (with `passes`/`inapplicable`) can be huge.

The wrappers are read-only: ‘@raw` is deep-frozen at construction, so `raw` and `to_h` expose the live underlying hash safely (callers cannot mutate it).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Results

Returns a new instance of Results.



32
33
34
# File 'lib/axe/cuprite/results.rb', line 32

def initialize(raw)
  @raw = DeepFreeze.call(raw || {})
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



30
31
32
# File 'lib/axe/cuprite/results.rb', line 30

def raw
  @raw
end

Instance Method Details

#incompleteObject

Nodes axe could not decide on (needs review). Surfaced but never fails.



41
42
43
# File 'lib/axe/cuprite/results.rb', line 41

def incomplete
  @incomplete ||= Array(@raw["incomplete"]).map { |v| Violation.new(v) }
end

#passes?Boolean Also known as: clean?

Returns:

  • (Boolean)


45
46
47
# File 'lib/axe/cuprite/results.rb', line 45

def passes?
  violations.empty?
end

#test_engineObject



58
59
60
# File 'lib/axe/cuprite/results.rb', line 58

def test_engine
  @raw["testEngine"]
end

#timestampObject



54
55
56
# File 'lib/axe/cuprite/results.rb', line 54

def timestamp
  @raw["timestamp"]
end

#to_hObject



62
63
64
# File 'lib/axe/cuprite/results.rb', line 62

def to_h
  @raw
end

#urlObject



50
51
52
# File 'lib/axe/cuprite/results.rb', line 50

def url
  @raw["url"]
end

#violationsObject



36
37
38
# File 'lib/axe/cuprite/results.rb', line 36

def violations
  @violations ||= Array(@raw["violations"]).map { |v| Violation.new(v) }
end