moxml 0.5.4 → 0.5.5
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/moxml/adapter/base.rb +8 -0
- data/lib/moxml/adapter/leptris.rb +6 -1
- data/lib/moxml/adapter/libxml.rb +4 -0
- data/lib/moxml/adapter/ox.rb +4 -0
- data/lib/moxml/config.rb +18 -2
- data/lib/moxml/node.rb +5 -5
- data/lib/moxml/version.rb +1 -1
- 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: 0cc1ee5cd198e8016cd259e62eec132ef73863dbb91125cca55349c8847df01c
|
|
4
|
+
data.tar.gz: 9b3db2921b1acaebaaeccfa6dbba82c78184443c6338e79952e334da0a837b0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a4ccdd2949f15fedf7bee4bc2c41b9340250ec58d2d4583e7be7a0a14c397749e034f1ec3e15193c7a2ad93d43de7126338fecf2142ad1180ea50b3de25a97a
|
|
7
|
+
data.tar.gz: 9e4abee61c92cb0a3390804af398e6baaf593107e8bbc9b33b10d5bc40675f9f0b92ef5ded27f0b8948edd8c930b5188496c4c644529a277d8dd71b49f3bae57
|
data/lib/moxml/adapter/base.rb
CHANGED
|
@@ -173,6 +173,14 @@ namespace_validation_mode: :strict)
|
|
|
173
173
|
node
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
+
# Whether children() results need per-child patch_node
|
|
177
|
+
# rewriting. Adapters whose natives arrive pre-wrapped (all but
|
|
178
|
+
# ox and libxml) answer false so the wrapper layer can skip
|
|
179
|
+
# the identity map over every child list.
|
|
180
|
+
def patches_children?
|
|
181
|
+
false
|
|
182
|
+
end
|
|
183
|
+
|
|
176
184
|
# Whether the subtree at native can contain entity markers.
|
|
177
185
|
# Marker-tracking adapters override this so the post-serialize
|
|
178
186
|
# restore can skip its full-output scans on marker-free
|
|
@@ -270,7 +270,12 @@ module Moxml
|
|
|
270
270
|
when ::Leptris::XML::Document
|
|
271
271
|
assemble_document_children(node)
|
|
272
272
|
when CustomizedLeptris::Declaration, CustomizedLeptris::Doctype,
|
|
273
|
-
CustomizedLeptris::EntityReference, CustomizedLeptris::TextSegment
|
|
273
|
+
CustomizedLeptris::EntityReference, CustomizedLeptris::TextSegment,
|
|
274
|
+
# Terminal node kinds pay an FFI round trip for an empty
|
|
275
|
+
# list; unfiltered recursions visit every text node.
|
|
276
|
+
::Leptris::XML::Text, ::Leptris::XML::Comment,
|
|
277
|
+
::Leptris::XML::CDATA, ::Leptris::XML::ProcessingInstruction,
|
|
278
|
+
::Leptris::XML::Attr
|
|
274
279
|
[]
|
|
275
280
|
else
|
|
276
281
|
natives = node.children.to_a
|
data/lib/moxml/adapter/libxml.rb
CHANGED
data/lib/moxml/adapter/ox.rb
CHANGED
data/lib/moxml/config.rb
CHANGED
|
@@ -11,10 +11,13 @@ module Moxml
|
|
|
11
11
|
# when the installed leptris supports programmatic document
|
|
12
12
|
# construction (Leptris::XML::Document.create); otherwise moxml
|
|
13
13
|
# falls back to FALLBACK_ADAPTER so released-gem environments keep
|
|
14
|
-
# working.
|
|
14
|
+
# working. Under Opal the default is oga only when the vendored
|
|
15
|
+
# pure-Ruby fork was compiled into the bundle — stock oga requires
|
|
16
|
+
# its C extension and cannot load there; otherwise rexml.
|
|
15
17
|
PREFERRED_ADAPTER = :leptris
|
|
16
18
|
FALLBACK_ADAPTER = :nokogiri
|
|
17
19
|
OPAL_DEFAULT_ADAPTER = :oga
|
|
20
|
+
OPAL_FALLBACK_ADAPTER = :rexml
|
|
18
21
|
|
|
19
22
|
# Entity loading modes:
|
|
20
23
|
# - :required - Must load entities, raise error if unavailable (default)
|
|
@@ -35,13 +38,26 @@ module Moxml
|
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
def runtime_default_adapter
|
|
38
|
-
return
|
|
41
|
+
return opal_runtime_adapter if RUBY_ENGINE == "opal"
|
|
39
42
|
|
|
40
43
|
return PREFERRED_ADAPTER if leptris_preferred_available?
|
|
41
44
|
|
|
42
45
|
detect_loaded_adapter || FALLBACK_ADAPTER
|
|
43
46
|
end
|
|
44
47
|
|
|
48
|
+
# Stock oga requires its C extension, so under Opal the oga
|
|
49
|
+
# adapter can only come from the vendored pure-Ruby fork — a
|
|
50
|
+
# repo-only artifact the released gem does not ship. Bundles
|
|
51
|
+
# that compiled it in (moxml's own harness) keep oga; everyone
|
|
52
|
+
# else gets the rexml adapter, whose Opal compat ships in-gem.
|
|
53
|
+
# `defined?` is safe here: this branch never runs under MRI,
|
|
54
|
+
# where it would trigger autoload resolution.
|
|
55
|
+
def opal_runtime_adapter
|
|
56
|
+
return OPAL_DEFAULT_ADAPTER if defined?(Moxml::Adapter::Oga)
|
|
57
|
+
|
|
58
|
+
OPAL_FALLBACK_ADAPTER
|
|
59
|
+
end
|
|
60
|
+
|
|
45
61
|
# True when the leptris gem is installed AND new enough for the
|
|
46
62
|
# adapter (it needs programmatic document construction, which
|
|
47
63
|
# released 1.1.x lacks). Memoized: the require probe runs once.
|
data/lib/moxml/node.rb
CHANGED
|
@@ -38,11 +38,11 @@ module Moxml
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def children
|
|
41
|
-
@children ||=
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
self
|
|
45
|
-
|
|
41
|
+
@children ||= begin
|
|
42
|
+
natives = adapter.children(@native)
|
|
43
|
+
natives = natives.map { adapter.patch_node(_1, @native) } if adapter.patches_children?
|
|
44
|
+
NodeSet.new(natives, context, self)
|
|
45
|
+
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def next_sibling
|
data/lib/moxml/version.rb
CHANGED