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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 542f29d833d2a2b08ebf8121b9bf847e4d30bfb2f86127742aad93ef648b8ab0
4
- data.tar.gz: 3d16c5ef20e3b540969c21d185d345a6b4fc6e6c0c548811d9af87d6d1105490
3
+ metadata.gz: '05685ad043ad0a5465f4e065c26cf35ad1b453511ce347a56e60d5a5153e731f'
4
+ data.tar.gz: 864587a2ddf54edd3f40d71676882b255904dfe6f46ee41a330ef8117ceddfed
5
5
  SHA512:
6
- metadata.gz: 83d9046ae33bf10605fd636fa9606aaeb481633c12a374046451cd44988f24c9e022257a85441e4d10babc3a0d01957597313cf02fc6373bee43566ed4af76d9
7
- data.tar.gz: d286b0b4358c9ef2a86930ae43fb356cb98a0f475affb6f76cae2140f36145fd440851b481d859af2a7a7ba996033d0719547102d09160a596af610d800301c9
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
 
@@ -14,7 +14,7 @@ module Canon
14
14
  module_function
15
15
 
16
16
  def parse(json)
17
- if Canon::YamlBackend.yeptris_native?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canon
4
- VERSION = "0.3.25"
4
+ VERSION = "0.3.26"
5
5
  end
@@ -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
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.25
4
+ version: 0.3.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.