canon 0.3.50 → 0.3.52

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: 6bbfa0c65294f7a3ad7d77b678dab6fc1b9f5c0fc67bf55faba3371e6cfc6614
4
- data.tar.gz: 28b3106753c227ad6973a2698ede0315d3e8812feed6af1cbccdf5cf08636184
3
+ metadata.gz: e699f814a8d0944cf2cef44825a9d417302adf157a7672ee3d94974a372b8ade
4
+ data.tar.gz: ef0e376d61027009a26ba783cb71ab5bedf0efc947cfea7a2b465d5504b32597
5
5
  SHA512:
6
- metadata.gz: 9d3c4a330ec9224eff5a8c84bd677ea1fc72500b06099c188b3c7b30e6b096d3897f8308a40fc003067887dd4f45986464c8786b8bee8096614035dc8189c8ea
7
- data.tar.gz: 84549e0eb08a383bf14934b8b22f58e3ad4aeac8aaaeb56ce80c87d1127df9d3ebc7d2f17763cf6cfd1dda65702e90d2379e0ba5d64193f250bd1f409d292aa3
6
+ metadata.gz: d0ef1400915d857311938307896e5e276bf3fb56088f98716218d2d92d82429f0b5864f4e24ce35eb0a99d249ed04c862b948de6483269df9cd21879845827d2
7
+ data.tar.gz: 5d95e02de1d7eb031a15f41a5705414cebd8360fc9bbaec0b1f90a34b1fb0689d504c3c5f258b3de7b66d91951b2889e2ad5dbc1d75d3485eb6d5f15e8588114
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). `YAML.dump` stays on Psych everywherecanonical output bytes are canon's product and the writers differ. **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`) ran clean after yeptris-ruby #29/#30/#31/#37 all closed (0.1.15.1), so YAML loads flip to yeptris by default; the spec stays as 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.
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 : YAML.dump(obj1)
74
- yaml_str2 = obj2.is_a?(String) ? obj2 : YAML.dump(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,
@@ -597,8 +597,7 @@ module Canon
597
597
  require "json"
598
598
  JSON.pretty_generate(doc)
599
599
  when :yaml
600
- require "yaml"
601
- doc.to_yaml
600
+ Canon::YamlParsing.dump(doc)
602
601
  else
603
602
  doc.to_s
604
603
  end
@@ -8,7 +8,7 @@ module Canon
8
8
  class YamlFormatter
9
9
  def self.format(yaml)
10
10
  parsed = parse(yaml)
11
- sort_yaml_keys(parsed).to_yaml
11
+ Canon::YamlParsing.dump(sort_yaml_keys(parsed))
12
12
  end
13
13
 
14
14
  def self.parse(yaml)
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.50"
4
+ VERSION = "0.3.52"
5
5
  end
@@ -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.50
4
+ version: 0.3.52
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-17 00:00:00.000000000 Z
11
+ date: 2026-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs
@@ -38,20 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: leptris
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.9.193
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.9.193
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: moxml
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 0.5.41
61
+ version: 0.5.60
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 0.5.41
68
+ version: 0.5.60
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: nokogiri
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +150,20 @@ dependencies:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yeptris
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.6.5
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.6.5
139
167
  description: |-
140
168
  Canon provides canonicalization and pretty-printing for various serialization
141
169
  formats (XML, HTML, JSON, YAML), producing standardized forms suitable for