canon 0.3.49 → 0.3.51
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/CLAUDE.md +1 -1
- data/lib/canon/comparison/yaml_comparator.rb +2 -2
- data/lib/canon/comparison.rb +1 -2
- data/lib/canon/diff_formatter/by_line/xml_formatter.rb +43 -0
- data/lib/canon/formatters/yaml_formatter.rb +1 -1
- data/lib/canon/version.rb +1 -1
- data/lib/canon/yaml_parsing.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f61c2faf1fb2cddf94fac6e26f2e488525fb35bab80c11a0c044a7e31ebf590c
|
|
4
|
+
data.tar.gz: c3f30512ba09c3110fe517306ec1588eead657014c90e4cb229dba7d0b5d43ed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: abb829d4a9944c9b191cd2da72a5677e775e74d5048e106f9170e2de3a9e0d0165d458d14f06227cfb1a991c99d37c2ab51957b260bad0de9eafb248b036b056
|
|
7
|
+
data.tar.gz: 0a8d8d11482a3aec546a040f21eebfd2888d04d44d9397039b9448b8167f0fac89e5eb656fa6b5c3210db6bae0b0c2ffa1d0b27007023ce9afea70e18dbdf138
|
data/CLAUDE.md
CHANGED
|
@@ -149,7 +149,7 @@ Engine A/B testing: `CANON_XML_BACKEND=nokogiri bundle exec rspec` (or `=moxml`
|
|
|
149
149
|
|
|
150
150
|
### YAML Engines
|
|
151
151
|
|
|
152
|
-
`Canon::YamlBackend` selects the YAML engine: `:yeptris` (default — Marshal bulk materialization in yeptris 0.1.28, 4.5–5x Psych load) or `:psych` (`CANON_YAML_BACKEND=psych` forces the stdlib engine). The default follows availability: yeptris when loadable, Psych otherwise. `Canon::YamlParsing` is the single gateway for string loads; `Canon::JsonParsing` mirrors it for JSON (the same yeptris engine serves both — `Yeptris::YAML.load` auto-detects JSON and routes to the native C-API materializer; JSON falls back to stdlib unless `YamlBackend.yeptris_native?`, since the FFI ladder is ~29x slower than the stdlib C extension).
|
|
152
|
+
`Canon::YamlBackend` selects the YAML engine: `:yeptris` (default — Marshal bulk materialization in yeptris 0.1.28, 4.5–5x Psych load) or `:psych` (`CANON_YAML_BACKEND=psych` forces the stdlib engine). The default follows availability: yeptris when loadable, Psych otherwise. `Canon::YamlParsing` is the single gateway for string loads; `Canon::JsonParsing` mirrors it for JSON (the same yeptris engine serves both — `Yeptris::YAML.load` auto-detects JSON and routes to the native C-API materializer; JSON falls back to stdlib unless `YamlBackend.yeptris_native?`, since the FFI ladder is ~29x slower than the stdlib C extension). YAML dumps also default to yeptris (0.6.5+'s emitter is byte-identical to Psych across the dump corpus — nil/Time/special-float/block-scalar/key-type families, yeptris#290/#300 closed; `header: true` supplies the `---` marker; `YamlParsing.dump` is the seam). **JSON defaults to the strict yeptris surface whenever the native materializer is installed** (yeptris 0.1.13.4 ships platform gems — zero compilation, zero env; parity spec-pinned to `JSON.parse` upstream). The parity gate (`spec/canon/yaml_engine_parity_spec.rb`) includes dump-lane byte-parity pins (yeptris#290/#300 closed in 0.6.5) — the executable gate for future yeptris releases. Never `require "yeptris/psych"` — it rebinds the global `::Psych` constant for the whole process; only the namespaced `Yeptris::YAML` API is used.
|
|
153
153
|
|
|
154
154
|
### Format Detection
|
|
155
155
|
|
|
@@ -70,8 +70,8 @@ module Canon
|
|
|
70
70
|
|
|
71
71
|
if opts[:verbose]
|
|
72
72
|
# Format YAML for display
|
|
73
|
-
yaml_str1 = obj1.is_a?(String) ? obj1 :
|
|
74
|
-
yaml_str2 = obj2.is_a?(String) ? obj2 :
|
|
73
|
+
yaml_str1 = obj1.is_a?(String) ? obj1 : Canon::YamlParsing.dump(obj1)
|
|
74
|
+
yaml_str2 = obj2.is_a?(String) ? obj2 : Canon::YamlParsing.dump(obj2)
|
|
75
75
|
|
|
76
76
|
ComparisonResult.new(
|
|
77
77
|
differences: differences,
|
data/lib/canon/comparison.rb
CHANGED
|
@@ -118,6 +118,13 @@ module Canon
|
|
|
118
118
|
after = diff_node.serialized_after&.split("\n") || []
|
|
119
119
|
fmt = diff_node.formatting?
|
|
120
120
|
lines = []
|
|
121
|
+
header = parent_chain(diff_node.path)
|
|
122
|
+
if header
|
|
123
|
+
lines << Canon::Diff::DiffLine.new(
|
|
124
|
+
line_number: nil, new_position: nil,
|
|
125
|
+
content: header, type: :location_header
|
|
126
|
+
)
|
|
127
|
+
end
|
|
121
128
|
require "diff/lcs" unless defined?(::Diff::LCS)
|
|
122
129
|
|
|
123
130
|
::Diff::LCS.sdiff(before, after).each do |change|
|
|
@@ -156,6 +163,27 @@ module Canon
|
|
|
156
163
|
lines
|
|
157
164
|
end
|
|
158
165
|
|
|
166
|
+
# Display chain of a DiffNode's ancestor elements, e.g.
|
|
167
|
+
# "bibitem > formattedref" — gives the blank-numbered
|
|
168
|
+
# unlocated lines a readable home (#86).
|
|
169
|
+
def parent_chain(path)
|
|
170
|
+
return nil if path.nil?
|
|
171
|
+
|
|
172
|
+
segments = path.split("/").reject(&:empty?)
|
|
173
|
+
return nil if segments.length < 2
|
|
174
|
+
|
|
175
|
+
chain = segments[0...-1].filter_map do |seg|
|
|
176
|
+
seg[/\A(?:\{[^}]+\})?([a-zA-Z0-9_:-]+)/, 1]
|
|
177
|
+
end
|
|
178
|
+
# Comparator paths repeat the element name before the node
|
|
179
|
+
# segment ("formattedref/formattedref/text()") — collapse
|
|
180
|
+
# consecutive repeats for display.
|
|
181
|
+
collapsed = chain.each_with_object([]) do |name, acc|
|
|
182
|
+
acc << name unless acc.last == name
|
|
183
|
+
end
|
|
184
|
+
collapsed.join(" > ")
|
|
185
|
+
end
|
|
186
|
+
|
|
159
187
|
# The nearest preceding node (in @differences walk order)
|
|
160
188
|
# that the enricher DID locate.
|
|
161
189
|
def preceding_located(diff_node)
|
|
@@ -225,6 +253,9 @@ module Canon
|
|
|
225
253
|
new_num = (diff_line.new_position || diff_line.line_number)&.+(1)
|
|
226
254
|
output << format_unified_line(old_num, new_num, " ",
|
|
227
255
|
diff_line.content)
|
|
256
|
+
when :location_header
|
|
257
|
+
output << format_location_header(diff_line.content)
|
|
258
|
+
|
|
228
259
|
when :removed
|
|
229
260
|
line_num = diff_line.line_number&.+(1)
|
|
230
261
|
formatting = diff_line.formatting?
|
|
@@ -992,6 +1023,18 @@ module Canon
|
|
|
992
1023
|
end
|
|
993
1024
|
end
|
|
994
1025
|
|
|
1026
|
+
# Dimmed section header for unlocated-node contexts (#86):
|
|
1027
|
+
# "⋯ in bibitem > formattedref"
|
|
1028
|
+
def format_location_header(chain)
|
|
1029
|
+
blank = " " * @line_num_width
|
|
1030
|
+
text = " ⋯ in #{chain}"
|
|
1031
|
+
if @use_color
|
|
1032
|
+
"#{blank}|#{blank} | #{colorize(text, :light_black)}"
|
|
1033
|
+
else
|
|
1034
|
+
"#{blank}|#{blank} | #{text}"
|
|
1035
|
+
end
|
|
1036
|
+
end
|
|
1037
|
+
|
|
995
1038
|
def format_unified_line(old_num, new_num, marker, content, color = nil,
|
|
996
1039
|
informative: false, formatting: false)
|
|
997
1040
|
old_str = old_num ? "%#{@line_num_width}d" % old_num : " " * @line_num_width
|
data/lib/canon/version.rb
CHANGED
data/lib/canon/yaml_parsing.rb
CHANGED
|
@@ -18,6 +18,21 @@ module Canon
|
|
|
18
18
|
# call site) — a canonicalizer treats anchors as content: yeptris
|
|
19
19
|
# resolves them unconditionally, so :true keeps both engines
|
|
20
20
|
# behavior-identical.
|
|
21
|
+
# Serialize a Ruby object graph to YAML. yeptris 0.6.5+'s
|
|
22
|
+
# emitter is byte-identical to Psych across canon's dump corpus
|
|
23
|
+
# (nil/Time/special-float/block-scalar/key-type families —
|
|
24
|
+
# yeptris#290/#300 closed) with header: true supplying the
|
|
25
|
+
# "---" document start Psych emits; Psych serves when yeptris
|
|
26
|
+
# is inactive (CANON_YAML_BACKEND=psych forces it for dumps as
|
|
27
|
+
# for loads).
|
|
28
|
+
def dump(obj)
|
|
29
|
+
if YamlBackend.yeptris?
|
|
30
|
+
::Yeptris::YAML.dump(obj, header: true)
|
|
31
|
+
else
|
|
32
|
+
YAML.dump(obj)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
21
36
|
def safe_load(yaml, permitted_classes: [Symbol, Date, Time],
|
|
22
37
|
aliases: true)
|
|
23
38
|
if YamlBackend.yeptris?
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: canon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.51
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: diff-lcs
|