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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9c1c880ebd136229eb81109ecbfc504a27b9bc101805688231525587a1601e8
4
- data.tar.gz: c09ed1d4c857d7a78006f4c2ade2bcb662bac233578858e7aeb0ca0b0d2f09f7
3
+ metadata.gz: 0cc1ee5cd198e8016cd259e62eec132ef73863dbb91125cca55349c8847df01c
4
+ data.tar.gz: 9b3db2921b1acaebaaeccfa6dbba82c78184443c6338e79952e334da0a837b0c
5
5
  SHA512:
6
- metadata.gz: d334d7e9789817b8891a78b77cf2bbaab05af83252a432cdc4bffb6728c37938a9f430098561ab8a8fa2db77f9ec0f089fc563922a1ceab046f26e7b2a1e01ed
7
- data.tar.gz: 1feb278e326095475c68bea001bd68f3ac76e8423fdf021bc3a54b765b4e9069ec5cf403c282687fb3843b6ca6411868d9208e6a50a5ea071ca5e443485358f0
6
+ metadata.gz: 4a4ccdd2949f15fedf7bee4bc2c41b9340250ec58d2d4583e7be7a0a14c397749e034f1ec3e15193c7a2ad93d43de7126338fecf2142ad1180ea50b3de25a97a
7
+ data.tar.gz: 9e4abee61c92cb0a3390804af398e6baaf593107e8bbc9b33b10d5bc40675f9f0b92ef5ded27f0b8948edd8c930b5188496c4c644529a277d8dd71b49f3bae57
@@ -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
@@ -1134,6 +1134,10 @@ module Moxml
1134
1134
  end
1135
1135
  end
1136
1136
 
1137
+ def patches_children?
1138
+ true
1139
+ end
1140
+
1137
1141
  def patch_node(node, _parent = nil)
1138
1142
  # Wrap native LibXML nodes in our wrapper classes
1139
1143
  return node if node.nil?
@@ -243,6 +243,10 @@ module Moxml
243
243
  Marshal.load(Marshal.dump(node))
244
244
  end
245
245
 
246
+ def patches_children?
247
+ true
248
+ end
249
+
246
250
  def patch_node(node, parent = nil)
247
251
  new_node =
248
252
  case node
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. Oga remains the Opal default (pure Ruby).
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 OPAL_DEFAULT_ADAPTER if RUBY_ENGINE == "opal"
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 ||= NodeSet.new(
42
- adapter.children(@native).map { adapter.patch_node(_1, @native) },
43
- context,
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- VERSION = "0.5.4"
4
+ VERSION = "0.5.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.