canon 0.3.6 → 0.3.7
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/lib/canon/version.rb +1 -1
- data/lib/canon/xml/data_model.rb +8 -1
- data/lib/canon/xml/sax.rb +8 -11
- data/lib/canon/xml_backend.rb +13 -10
- 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: b1ce43e1e3cb461ac60687f0e9cdd815916f85cd40a87c8d70f0a071c56b1c04
|
|
4
|
+
data.tar.gz: 3eff7d2db22b5fe57674e64aa5f6b5ebb1d4b82d6f3afde5c45444f57f2c8e55
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7428800d8125c5173b61338ce8929f1c3700684ccba7cae25847a1d5cc533c99eea946a46cd5f567841b978597670e26d546849b853b11bd88cb6f72c023c647
|
|
7
|
+
data.tar.gz: 77cdd82d177e2d476aece71503a70487ee31f6593f30d401e748199944fbc9230756c5bba08b73411dae62621c5d08c16c1fdb4ec427a5e96f0d43955cea0414
|
data/lib/canon/version.rb
CHANGED
data/lib/canon/xml/data_model.rb
CHANGED
|
@@ -205,9 +205,16 @@ inherited_namespaces: nil)
|
|
|
205
205
|
# scopes cannot flow down during the stream).
|
|
206
206
|
|
|
207
207
|
def self.from_moxml_xml(xml_string, preserve_whitespace:)
|
|
208
|
-
|
|
208
|
+
# strict: false keeps the Nokogiri-engine contract — malformed
|
|
209
|
+
# input yields a recovered document plus diagnostics instead of
|
|
210
|
+
# an exception (moxml 0.5.15 defaults strict to true; issue
|
|
211
|
+
# #147 rides recover errors on Document#parse_errors).
|
|
212
|
+
doc = Canon::XmlParsing.moxml_context.parse(xml_string,
|
|
213
|
+
readonly: true,
|
|
214
|
+
strict: false)
|
|
209
215
|
check_moxml_relative_namespace_uris(doc)
|
|
210
216
|
result = build_from_moxml(doc, preserve_whitespace: preserve_whitespace)
|
|
217
|
+
result.parse_errors = doc.parse_errors if doc.parse_errors.any?
|
|
211
218
|
# Canon owns this document's full lifecycle: the canon tree holds
|
|
212
219
|
# no engine references once built, so release the native tree now
|
|
213
220
|
# instead of waiting for the GC finalizer (moxml#134; no-op on
|
data/lib/canon/xml/sax.rb
CHANGED
|
@@ -10,16 +10,13 @@ module Canon
|
|
|
10
10
|
# API to that protocol. OCP: a new engine is a new driver plus one line
|
|
11
11
|
# here; the builder never changes.
|
|
12
12
|
#
|
|
13
|
-
# Engine choice
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# Nokogiri driver; the flip is the one-line change below. With
|
|
21
|
-
# leptris absent (moxml resolving nokogiri) the driver calls Nokogiri
|
|
22
|
-
# directly — the wrapper layer only adds overhead there.
|
|
13
|
+
# Engine choice follows the resolved adapter — independent of the
|
|
14
|
+
# DOM engine default: leptris SAX (corruption leptris#625 and the
|
|
15
|
+
# missing xmlns reporting leptris-ruby#99 both fixed) builds canon
|
|
16
|
+
# trees at parity with or faster than Nokogiri SAX, CI-gated. The
|
|
17
|
+
# DOM engine default stays Nokogiri until the record conversion
|
|
18
|
+
# passes the same gate (see XmlBackend). With leptris absent the
|
|
19
|
+
# driver calls Nokogiri directly.
|
|
23
20
|
module Sax
|
|
24
21
|
autoload :NokogiriDriver, "canon/xml/sax/nokogiri_driver"
|
|
25
22
|
autoload :MoxmlDriver, "canon/xml/sax/moxml_driver"
|
|
@@ -27,7 +24,7 @@ module Canon
|
|
|
27
24
|
class << self
|
|
28
25
|
# Drive `builder` with the runtime's SAX engine.
|
|
29
26
|
def parse(xml_string, builder)
|
|
30
|
-
if RUBY_ENGINE == "opal"
|
|
27
|
+
if RUBY_ENGINE == "opal" || Canon::XmlParsing.moxml_adapter_name != :nokogiri
|
|
31
28
|
MoxmlDriver.new(builder).parse(xml_string)
|
|
32
29
|
else
|
|
33
30
|
NokogiriDriver.new(builder).parse(xml_string)
|
data/lib/canon/xml_backend.rb
CHANGED
|
@@ -9,16 +9,14 @@ module Canon
|
|
|
9
9
|
# - HTML support — always Nokogiri on CRuby; moxml has no HTML adapter and
|
|
10
10
|
# leptris no HTML parser (see Canon::Html::NokogiriSupport).
|
|
11
11
|
#
|
|
12
|
-
# SSOT: moxml owns adapter preference (Moxml::Config prefers leptris
|
|
13
|
-
# installed
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# #detect; CANON_XML_BACKEND=moxml opts in today. Under Opal the engine
|
|
21
|
-
# is moxml (rexml adapter).
|
|
12
|
+
# SSOT: moxml owns adapter preference (Moxml::Config prefers leptris
|
|
13
|
+
# when installed; see XmlParsing.moxml_adapter_name). The SAX engine
|
|
14
|
+
# follows the resolved adapter — leptris (correct since leptris#625
|
|
15
|
+
# and leptris-ruby#99; CI perf-gated). The DOM engine stays Nokogiri
|
|
16
|
+
# until the record conversion passes the same gate (moxml#143's fix
|
|
17
|
+
# landed; still -40%/-37% from_xml on the CI runner). Conformance
|
|
18
|
+
# parity is complete (engine_parity_spec 12/12, zero pendings).
|
|
19
|
+
# CANON_XML_BACKEND=moxml opts into the leptris DOM engine today.
|
|
22
20
|
#
|
|
23
21
|
# HTML stays on Nokogiri on CRuby (Canon::Html::NokogiriSupport) and the
|
|
24
22
|
# pretty-printers keep the Nokogiri pipeline — pretty-printed bytes are
|
|
@@ -63,6 +61,11 @@ module Canon
|
|
|
63
61
|
def detect
|
|
64
62
|
return :moxml if RUBY_ENGINE == "opal"
|
|
65
63
|
|
|
64
|
+
# The SAX engine flipped to leptris (leptris#625/#99 fixed,
|
|
65
|
+
# CI-gated — see Canon::Xml::Sax), but the DOM conversion still
|
|
66
|
+
# trails Nokogiri on the CI runner (-40%/-37% from_xml after
|
|
67
|
+
# moxml#143's emission fix landed). Nokogiri stays the DOM
|
|
68
|
+
# default until that gate passes; flipping is this one line.
|
|
66
69
|
:nokogiri
|
|
67
70
|
end
|
|
68
71
|
end
|
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.7
|
|
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-08-
|
|
11
|
+
date: 2026-08-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: diff-lcs
|