moxml 0.5.57 → 0.5.58
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/leptris.rb +25 -0
- data/lib/moxml/node.rb +8 -2
- data/lib/moxml/version.rb +1 -1
- data/spec/moxml/adapter/leptris_spec.rb +28 -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: 03fd3940f1334b3f417e4847f35e87497581404372209de4426819a8acc6d363
|
|
4
|
+
data.tar.gz: 805f6966495456ff6e36c4f1be3df9fcbbf1c89cfcf2ddc6a4153c37e1bcec71
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 872ba59e6f8b72779d2ea43c8af201052a69be9d75ad1add3fa2618bc58e81cee0503ce352d06c8b46c64cc6340859006b36afeadef4302f29c81e2760285baa
|
|
7
|
+
data.tar.gz: 01eed98fc6ac76efb35d2456c9af57487bbdddf13092a09b0667d11e6e2d48a1905865046aab6a59ca8a89523fc4337a705c1b1cf95d98342d56cb4494c0d91e
|
|
@@ -246,6 +246,31 @@ module Moxml
|
|
|
246
246
|
NATIVE_MUTATIONS_COHERENT &&
|
|
247
247
|
Gem::Version.new(::Leptris::VERSION) >= Gem::Version.new("1.9.174.4")
|
|
248
248
|
|
|
249
|
+
# leptris-ruby#246 klass-propagating reads: the read
|
|
250
|
+
# family (children/element_children/next_sibling/parent)
|
|
251
|
+
# mints the mapped subclass per kind, so children arrive
|
|
252
|
+
# already carrying the contract — wrap_native's is_a?
|
|
253
|
+
# guard short-circuits and the per-visit from() mint
|
|
254
|
+
# (the second allocation of the pair) drops out. Kind
|
|
255
|
+
# order is the C layer's node-type ints: element, text,
|
|
256
|
+
# comment, cdata, pi.
|
|
257
|
+
NATIVE_KLASS_CHILDREN =
|
|
258
|
+
NATIVE_IDENTITY &&
|
|
259
|
+
Gem::Version.new(::Leptris::VERSION) >= Gem::Version.new("1.9.193.2")
|
|
260
|
+
|
|
261
|
+
if NATIVE_KLASS_CHILDREN
|
|
262
|
+
kind_classes = [
|
|
263
|
+
Identity::ELEMENT,
|
|
264
|
+
Identity::TEXT,
|
|
265
|
+
Identity::COMMENT,
|
|
266
|
+
Identity::CDATA,
|
|
267
|
+
Identity::PROCESSING_INSTRUCTION,
|
|
268
|
+
]
|
|
269
|
+
kind_classes.each do |klass|
|
|
270
|
+
klass.install_child_klasses(kind_classes)
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
249
274
|
def wrap_native(node, type, _context)
|
|
250
275
|
return nil unless NATIVE_IDENTITY &&
|
|
251
276
|
node.is_a?(::Leptris::XML::NativeNode)
|
data/lib/moxml/node.rb
CHANGED
|
@@ -593,10 +593,16 @@ module Moxml
|
|
|
593
593
|
|
|
594
594
|
# Extend-in-place (issue #230): adapters whose natives can
|
|
595
595
|
# carry the contract modules directly (leptris TypedData) mint
|
|
596
|
-
# the native itself as the wrapper — @native is self.
|
|
596
|
+
# the native itself as the wrapper — @native is self. The
|
|
597
|
+
# minted wrapper primes with ITSELF (not the input native):
|
|
598
|
+
# adapter calls then receive the contract-bearing receiver,
|
|
599
|
+
# which klass-propagating reads (#246) dispatch on — and the
|
|
600
|
+
# input native keeps its registration so later wraps of the
|
|
601
|
+
# same base object hit the cache instead of re-minting.
|
|
597
602
|
if (extended = adapter.wrap_native(node, type, context))
|
|
598
|
-
extended.prime_contract(
|
|
603
|
+
extended.prime_contract(extended, context, adapter, type)
|
|
599
604
|
context.register_wrapper(node, extended)
|
|
605
|
+
context.register_wrapper(extended, extended) unless extended.equal?(node)
|
|
600
606
|
return extended
|
|
601
607
|
end
|
|
602
608
|
|
data/lib/moxml/version.rb
CHANGED
|
@@ -798,4 +798,32 @@ RSpec.describe Moxml::Adapter::Leptris do
|
|
|
798
798
|
expect(pi[2]).to be_a(Integer)
|
|
799
799
|
end
|
|
800
800
|
end
|
|
801
|
+
|
|
802
|
+
describe "klass-propagating children" do
|
|
803
|
+
let(:ctx) { Moxml.new(:leptris) }
|
|
804
|
+
|
|
805
|
+
it "mints contract-bearing children in C" do
|
|
806
|
+
skip "requires klass-propagating reads (leptris 1.9.193.2+)" unless described_class.singleton_class.const_get(:NATIVE_KLASS_CHILDREN)
|
|
807
|
+
|
|
808
|
+
doc = ctx.parse(%(<r><e a="1"/>t</r>))
|
|
809
|
+
kids = doc.root.children
|
|
810
|
+
expect(kids.first).to be_a(Moxml::Element)
|
|
811
|
+
expect(kids.last).to be_a(Moxml::Text)
|
|
812
|
+
expect(kids.first["a"]).to eq("1")
|
|
813
|
+
expect(kids.last.text).to eq("t")
|
|
814
|
+
# The C mint IS the wrapper — @native is self, no re-mint.
|
|
815
|
+
expect(kids.first.native).to equal(kids.first)
|
|
816
|
+
end
|
|
817
|
+
|
|
818
|
+
it "keeps identity across access paths" do
|
|
819
|
+
skip "requires klass-propagating reads (leptris 1.9.193.2+)" unless described_class.singleton_class.const_get(:NATIVE_KLASS_CHILDREN)
|
|
820
|
+
|
|
821
|
+
doc = ctx.parse(%(<r><a/>t</r>))
|
|
822
|
+
first = doc.root.children.first
|
|
823
|
+
expect(doc.root.element_children.first).to equal(first)
|
|
824
|
+
expect(first.parent.children.first).to equal(first)
|
|
825
|
+
expect(first.next_sibling.text).to eq("t")
|
|
826
|
+
expect(first.next_sibling.parent).to eq(doc.root)
|
|
827
|
+
end
|
|
828
|
+
end
|
|
801
829
|
end
|