canon 0.3.66 → 0.3.67
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/README.adoc +3 -4
- data/lib/canon/comparison/comparison_result.rb +17 -0
- data/lib/canon/comparison/xml_comparator/child_comparison.rb +19 -1
- data/lib/canon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58c68ab8bd9ce6ae758ef8a9b2aeb69272dac07ef633e6d400dce01498e4a45a
|
|
4
|
+
data.tar.gz: d118362c2a39b59d6739c67623b31d8a957c093e8b280360be969643041b15f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc4582dc42ff629f85115a37e5456f6339ec7fe27f6e9b568fa6af1096d42c362aa5eb6bd767ceb40fb8f2e0f781cf642cfecd454631e34e937961e5c5b3ca45
|
|
7
|
+
data.tar.gz: d7c4b776c8720cd9c04bbc0b002d9a355ce23ea57668bb42df2bb7c3224a2a654776ff67ed8c0ad6b0c74a6173557ef650bb7a5f3f1178e042d379c8f833b6a6
|
data/README.adoc
CHANGED
|
@@ -21,10 +21,9 @@ Key features:
|
|
|
21
21
|
installed — Nokogiri otherwise and for HTML; both byte-compatible, engine
|
|
22
22
|
parity is spec-gated
|
|
23
23
|
** JSON on https://github.com/leptris/yeptris[libyeptris]' strict JSON surface
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Psych otherwise
|
|
24
|
+
(yeptris is a required gem — platform gems, zero compilation)
|
|
25
|
+
** YAML on yeptris (default — byte-parity with Psych, gated by the dump
|
|
26
|
+
corpus in the suite); Psych via `CANON_YAML_BACKEND=psych`
|
|
28
27
|
|
|
29
28
|
== When to use formatting vs comparison
|
|
30
29
|
|
|
@@ -56,6 +56,23 @@ parse_errors_expected: nil, parse_errors_received: nil)
|
|
|
56
56
|
@original_strings || preprocessed_strings
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
# The lazy display-string builder is a Proc, which Marshal (and
|
|
60
|
+
# every serializing test-distribution tool) cannot dump.
|
|
61
|
+
# Materialize first — the restored copy carries plain strings
|
|
62
|
+
# and round-trips exactly like the pre-lazy results.
|
|
63
|
+
def marshal_dump
|
|
64
|
+
preprocessed_strings
|
|
65
|
+
[@differences, @preprocessed_strings, @original_strings,
|
|
66
|
+
@format, @html_version, @match_options, @algorithm,
|
|
67
|
+
@parse_errors_expected, @parse_errors_received]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def marshal_load(data)
|
|
71
|
+
@differences, @preprocessed_strings, @original_strings,
|
|
72
|
+
@format, @html_version, @match_options, @algorithm,
|
|
73
|
+
@parse_errors_expected, @parse_errors_received = data
|
|
74
|
+
end
|
|
75
|
+
|
|
59
76
|
# Whether either side reported parse errors. Used by the diff
|
|
60
77
|
# formatter to decide whether to render the parse-error banner.
|
|
61
78
|
#
|
|
@@ -122,6 +122,23 @@ module Canon
|
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
# Process ElementMatcher results
|
|
125
|
+
# Position differences carry element identity — a bare
|
|
126
|
+
# "position 0 vs position 1" next to identical-looking
|
|
127
|
+
# Expected/Actual payloads reads as a canon false positive
|
|
128
|
+
# when the real change is sibling order (e.g. id="1" and
|
|
129
|
+
# id="2" swapped).
|
|
130
|
+
def position_reason(elem, pos)
|
|
131
|
+
return "position #{pos}" if elem.nil?
|
|
132
|
+
|
|
133
|
+
label = elem.name.to_s
|
|
134
|
+
attrs = Canon::Diff::NodeSerializer.extract_attributes(elem)
|
|
135
|
+
return "position #{pos}" if attrs.nil? || attrs.empty?
|
|
136
|
+
|
|
137
|
+
id_like = %w[id href name].filter_map { |k| attrs[k] && "#{k}=#{attrs[k]}" }
|
|
138
|
+
id_like << attrs.first.then { |k, v| "#{k}=#{v}" } if id_like.empty?
|
|
139
|
+
"#{label}[#{id_like.first}] at position #{pos}"
|
|
140
|
+
end
|
|
141
|
+
|
|
125
142
|
def process_matches(matches, _children1, _children2, _parent_node, comparator,
|
|
126
143
|
opts, child_opts, diff_children, differences)
|
|
127
144
|
all_equivalent = true
|
|
@@ -137,7 +154,8 @@ module Canon
|
|
|
137
154
|
# Only create DiffNode if element_position is not :ignore
|
|
138
155
|
if position_behavior != :ignore
|
|
139
156
|
comparator.add_difference(match.elem1, match.elem2,
|
|
140
|
-
|
|
157
|
+
position_reason(match.elem1, match.pos1),
|
|
158
|
+
position_reason(match.elem2, match.pos2),
|
|
141
159
|
:element_position, opts, differences)
|
|
142
160
|
all_equivalent = false if position_behavior == :strict
|
|
143
161
|
end
|
data/lib/canon/version.rb
CHANGED