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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04a82e16556af6e2b31b4a137e5beef44d499df0d20a019f5406c9c127e94207
4
- data.tar.gz: 998418423acb82ccca419c02b4f7c0abf6574e3ba9e370a9d463b51ae3409d76
3
+ metadata.gz: 58c68ab8bd9ce6ae758ef8a9b2aeb69272dac07ef633e6d400dce01498e4a45a
4
+ data.tar.gz: d118362c2a39b59d6739c67623b31d8a957c093e8b280360be969643041b15f2
5
5
  SHA512:
6
- metadata.gz: 259638f0ce661b7c766787071fa5b6174e3a0f2ca5d0b027375717e1f191315c44d10308819fd7d17ee019fde9d7418f01c8f13614c9c83154616ca4845c9eff
7
- data.tar.gz: 47eca8ccd4000c0f22712818d8e72d7e7f4e37f5f523db0a59ff7441c119ff1ae5e29f4c5bef58c04831ee5b65e9bea7283c064bb4008a5732080cdb80f2ca9c
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
- whenever the native materializer is installed (`gem install yeptris`
25
- platform gems, zero compilation), the stdlib JSON extension otherwise
26
- ** YAML on yeptris opt-in (`CANON_YAML_BACKEND=yeptris`, ~3x Psych loads);
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
- "position #{match.pos1}", "position #{match.pos2}",
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canon
4
- VERSION = "0.3.66"
4
+ VERSION = "0.3.67"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.66
4
+ version: 0.3.67
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.