axe-core-api 4.11.3.pre.5ef90f3 → 4.11.3.pre.aa0236f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/axe/api/results/check.rb +1 -1
- data/lib/axe/api/results/checked_node.rb +3 -3
- data/lib/axe/api/results/rule.rb +2 -2
- data/lib/axe/api/results.rb +4 -4
- data/lib/axe/api/value_object.rb +123 -3
- metadata +2 -30
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd2783fb2c8ca2eb703e6d673bf4b9d9a48639de6653d4ba946fb25fe74b851e
|
|
4
|
+
data.tar.gz: d8a9364f9f929acbc89e470382bce7d8946a32352084e706bba20c45f6d10c4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d343f01d512f2b71bb9cc7ae319f42d72560e82d8df7c1268479704b35d8e180d116008b344874ae958b6cb889927cefd4577a6e54a5ff42b5a78b21cb67acc
|
|
7
|
+
data.tar.gz: a6f3810b0ce88b865967b0fd79dd81da2e877fdd46c2c25fed5a667ffa63712a7b6aa01d1b01a28bae062b84225c3331b6fceaa9ea5812c164f04994b945d640
|
|
@@ -7,9 +7,9 @@ module Axe
|
|
|
7
7
|
class CheckedNode < Node
|
|
8
8
|
values do
|
|
9
9
|
attribute :impact, ::Symbol
|
|
10
|
-
attribute :any,
|
|
11
|
-
attribute :all,
|
|
12
|
-
attribute :none,
|
|
10
|
+
attribute :any, [Check]
|
|
11
|
+
attribute :all, [Check]
|
|
12
|
+
attribute :none, [Check]
|
|
13
13
|
attribute :failureSummary, ::Symbol
|
|
14
14
|
attribute :html, ::String
|
|
15
15
|
attribute :target
|
data/lib/axe/api/results/rule.rb
CHANGED
|
@@ -11,8 +11,8 @@ module Axe
|
|
|
11
11
|
attribute :help, ::String
|
|
12
12
|
attribute :helpUrl, ::String
|
|
13
13
|
attribute :impact, ::Symbol
|
|
14
|
-
attribute :tags,
|
|
15
|
-
attribute :nodes,
|
|
14
|
+
attribute :tags, [::Symbol]
|
|
15
|
+
attribute :nodes, [CheckedNode]
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def failure_messages(index)
|
data/lib/axe/api/results.rb
CHANGED
|
@@ -6,16 +6,16 @@ module Axe
|
|
|
6
6
|
require_relative "./results/rule"
|
|
7
7
|
|
|
8
8
|
values do
|
|
9
|
-
attribute :inapplicable,
|
|
10
|
-
attribute :incomplete,
|
|
11
|
-
attribute :passes,
|
|
9
|
+
attribute :inapplicable, [Rule]
|
|
10
|
+
attribute :incomplete, [Rule]
|
|
11
|
+
attribute :passes, [Rule]
|
|
12
12
|
attribute :timestamp
|
|
13
13
|
attribute :testEngine
|
|
14
14
|
attribute :testEnvironment
|
|
15
15
|
attribute :testRunner
|
|
16
16
|
attribute :toolOptions
|
|
17
17
|
attribute :url, ::String
|
|
18
|
-
attribute :violations,
|
|
18
|
+
attribute :violations, [Rule]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def failure_message
|
data/lib/axe/api/value_object.rb
CHANGED
|
@@ -1,9 +1,129 @@
|
|
|
1
|
-
require 'virtus'
|
|
2
|
-
|
|
3
1
|
module Axe
|
|
4
2
|
module API
|
|
5
3
|
class ValueObject
|
|
6
|
-
|
|
4
|
+
class << self
|
|
5
|
+
def attributes
|
|
6
|
+
@attributes ||= superclass.respond_to?(:attributes) ? superclass.attributes.dup : {}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def values(&block)
|
|
10
|
+
instance_eval(&block)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def attribute(name, type = nil)
|
|
14
|
+
attributes[name] = type
|
|
15
|
+
attr_reader(name) unless method_defined?(name)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def initialize(attrs = {})
|
|
20
|
+
attrs ||= {}
|
|
21
|
+
self.class.attributes.each do |name, type|
|
|
22
|
+
raw = if attrs.respond_to?(:key?)
|
|
23
|
+
if attrs.key?(name)
|
|
24
|
+
attrs[name]
|
|
25
|
+
elsif attrs.key?(name.to_s)
|
|
26
|
+
attrs[name.to_s]
|
|
27
|
+
end
|
|
28
|
+
elsif attrs.respond_to?(name)
|
|
29
|
+
attrs.public_send(name)
|
|
30
|
+
end
|
|
31
|
+
instance_variable_set("@#{name}", coerce(raw, type))
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def attributes
|
|
36
|
+
self.class.attributes.each_key.each_with_object({}) do |name, hash|
|
|
37
|
+
hash[name] = public_send(name)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_h
|
|
42
|
+
attributes
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def to_hash
|
|
46
|
+
to_h
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def ==(other)
|
|
50
|
+
other.instance_of?(self.class) && attributes == other.attributes
|
|
51
|
+
end
|
|
52
|
+
alias_method :eql?, :==
|
|
53
|
+
|
|
54
|
+
def hash
|
|
55
|
+
[self.class, attributes].hash
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def inspect
|
|
59
|
+
pairs = attributes.map { |name, value| "#{name}=#{value.inspect}" }
|
|
60
|
+
pairs.empty? ? "#<#{self.class.name}>" : "#<#{self.class.name} #{pairs.join(" ")}>"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def [](name)
|
|
64
|
+
key = name.to_sym
|
|
65
|
+
self.class.attributes.key?(key) ? public_send(key) : nil
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
BOOLEAN_TRUE_STRINGS = %w[1 t T true TRUE].freeze
|
|
69
|
+
BOOLEAN_FALSE_STRINGS = %w[0 f F false FALSE].freeze
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def coerce(value, type)
|
|
74
|
+
return value if type.nil?
|
|
75
|
+
|
|
76
|
+
case type
|
|
77
|
+
when Array
|
|
78
|
+
Array(value).map { |element| coerce(element, type.first) }
|
|
79
|
+
when Class
|
|
80
|
+
coerce_class(value, type)
|
|
81
|
+
else
|
|
82
|
+
value
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Virtus-compatible lenient coercion: returns the input unchanged when
|
|
87
|
+
# it can't be cleanly converted, rather than raising.
|
|
88
|
+
def coerce_class(value, type)
|
|
89
|
+
return nil if value.nil?
|
|
90
|
+
|
|
91
|
+
if type == ::Symbol
|
|
92
|
+
value.to_sym
|
|
93
|
+
elsif type == ::String
|
|
94
|
+
value.to_s
|
|
95
|
+
elsif type == ::Integer
|
|
96
|
+
coerce_integer(value)
|
|
97
|
+
elsif type == ::Float
|
|
98
|
+
coerce_float(value)
|
|
99
|
+
elsif type == ::TrueClass || type == ::FalseClass
|
|
100
|
+
coerce_boolean(value)
|
|
101
|
+
elsif type <= ValueObject
|
|
102
|
+
value.is_a?(type) ? value : type.new(value)
|
|
103
|
+
else
|
|
104
|
+
value
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def coerce_integer(value)
|
|
109
|
+
return value.to_i if value.is_a?(::Numeric)
|
|
110
|
+
return value.to_i if value.is_a?(::String) && value =~ /\A-?\d+\z/
|
|
111
|
+
value
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def coerce_float(value)
|
|
115
|
+
return value.to_f if value.is_a?(::Numeric)
|
|
116
|
+
return value.to_f if value.is_a?(::String) && value =~ /\A-?(?:\d+\.?\d*|\.\d+)\z/
|
|
117
|
+
value
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def coerce_boolean(value)
|
|
121
|
+
return value if value == true || value == false
|
|
122
|
+
str = value.to_s
|
|
123
|
+
return true if BOOLEAN_TRUE_STRINGS.include?(str)
|
|
124
|
+
return false if BOOLEAN_FALSE_STRINGS.include?(str)
|
|
125
|
+
value
|
|
126
|
+
end
|
|
7
127
|
end
|
|
8
128
|
end
|
|
9
129
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: axe-core-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.11.3.pre.
|
|
4
|
+
version: 4.11.3.pre.aa0236f
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Deque Systems
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dumb_delegator
|
|
@@ -24,34 +24,6 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: ostruct
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: virtus
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :runtime
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
27
|
- !ruby/object:Gem::Dependency
|
|
56
28
|
name: bundler
|
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|