canon 0.3.25 → 0.3.26
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/json_parsing.rb +1 -1
- data/lib/canon/version.rb +1 -1
- data/lib/canon/yaml_backend.rb +16 -0
- 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: '05685ad043ad0a5465f4e065c26cf35ad1b453511ce347a56e60d5a5153e731f'
|
|
4
|
+
data.tar.gz: 864587a2ddf54edd3f40d71676882b255904dfe6f46ee41a330ef8117ceddfed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e568174aeaf605650e7eb64267afddbe30fd4399b82c032757e60177631b75663b0cf388d16e2fbaddea774ea703cb4c88f3e11ac8307ee1a75a3ea6f6530cc
|
|
7
|
+
data.tar.gz: 5af9aded692f6b909ffd1eb50bb9e96c851b8ca98844a397ceec11f8a2eede33437f99d4df15a2870beee56954924d2fd1ec061b6cb4523d2204fa07524f0710
|
data/CLAUDE.md
CHANGED
|
@@ -145,7 +145,7 @@ Engine A/B testing: `CANON_XML_BACKEND=nokogiri bundle exec rspec` (or `=moxml`
|
|
|
145
145
|
|
|
146
146
|
### YAML Engines
|
|
147
147
|
|
|
148
|
-
`Canon::YamlBackend` selects the YAML engine: `:psych` (default) or `:yeptris` (FFI over libyeptris, the YAML counterpart of the leptris XML stack — `CANON_YAML_BACKEND=yeptris` opts in; the optional `yeptris` Gemfile group must be enabled). `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 everywhere — canonical output bytes are canon's product and the writers differ. The default stays `:psych` until the yeptris Psych-parity gaps close (yeptris-ruby#30 sexagesimal scalars, #31 >64-bit integers — #29 empty documents was fixed in 0.1.12); `spec/canon/yaml_engine_parity_spec.rb` is the executable gate, with upstream-tracked cases pending. Never `require "yeptris/psych"` — it rebinds the global `::Psych` constant for the whole process; only the namespaced `Yeptris::YAML` API is used.
|
|
148
|
+
`Canon::YamlBackend` selects the YAML engine: `:psych` (default) or `:yeptris` (FFI over libyeptris, the YAML counterpart of the leptris XML stack — `CANON_YAML_BACKEND=yeptris` opts in; the optional `yeptris` Gemfile group must be enabled). `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 everywhere — canonical 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 YAML default stays `:psych` until the yeptris Psych-parity gaps close (yeptris-ruby#30 sexagesimal scalars, #31 >64-bit integers — #29 empty documents was fixed in 0.1.12); `spec/canon/yaml_engine_parity_spec.rb` is the executable gate, with upstream-tracked cases pending. Never `require "yeptris/psych"` — it rebinds the global `::Psych` constant for the whole process; only the namespaced `Yeptris::YAML` API is used.
|
|
149
149
|
|
|
150
150
|
### Format Detection
|
|
151
151
|
|
data/lib/canon/json_parsing.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Canon
|
|
|
14
14
|
module_function
|
|
15
15
|
|
|
16
16
|
def parse(json)
|
|
17
|
-
if Canon::YamlBackend.
|
|
17
|
+
if Canon::YamlBackend.json_yeptris?
|
|
18
18
|
begin
|
|
19
19
|
# The strict JSON surface — spec-pinned to exact JSON.parse
|
|
20
20
|
# semantics upstream, deliberately separate from the YAML
|
data/lib/canon/version.rb
CHANGED
data/lib/canon/yaml_backend.rb
CHANGED
|
@@ -59,6 +59,22 @@ module Canon
|
|
|
59
59
|
yeptris? && yeptris_available? && !defined?(::Yeptris::Native).nil?
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
# JSON defaults to the strict yeptris surface whenever the
|
|
63
|
+
# native materializer is installed (0.1.13.4 ships platform
|
|
64
|
+
# gems — zero compilation, zero env). JSON parity is
|
|
65
|
+
# spec-pinned to JSON.parse upstream and complete except the
|
|
66
|
+
# #37 duplicate-keys leniency; YAML keeps waiting on #30/#31
|
|
67
|
+
# and stays behind the env opt-in. CANON_YAML_BACKEND=psych
|
|
68
|
+
# forces both formats back to stdlib.
|
|
69
|
+
def json_yeptris?
|
|
70
|
+
return false if RUBY_ENGINE == "opal"
|
|
71
|
+
return false if ENV["CANON_YAML_BACKEND"].to_s.casecmp("psych").zero?
|
|
72
|
+
|
|
73
|
+
# Independent of the YAML selection: the strict JSON surface
|
|
74
|
+
# is complete on its own, so JSON does not wait for #30/#31.
|
|
75
|
+
yeptris_available? && !defined?(::Yeptris::Native).nil?
|
|
76
|
+
end
|
|
77
|
+
|
|
62
78
|
private
|
|
63
79
|
|
|
64
80
|
def forced
|