moxml 0.6.7 → 0.6.8
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 +24 -1
- data/lib/moxml/version.rb +1 -1
- data/spec/moxml/adapter/leptris_registered_subclass_spec.rb +74 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8536f48b75689cbcc22414adaeac301263c491a66418cf5bc8ea71435b53d9ed
|
|
4
|
+
data.tar.gz: f24cc023a8712e3128923860cc647af54fb57e8d70f3c8e426a1b2c291553422
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0226b4d3d7f9ddea1cc8bd69034b8c243950240c0859d30507920dc1d0f35e27c7fc5ffe5ca11197f8f07e713362c91058376ca7c4991e06e5ee4ddcf3890ae
|
|
7
|
+
data.tar.gz: 5da68f6cdae48d0b8c9289780473a6c83d13e140266b9891f92654ec38b53538515b05e6d7198513deabb14ca420a9ca7992ff5ffb734d3b73124921ad93bb34
|
|
@@ -1097,8 +1097,31 @@ module Moxml
|
|
|
1097
1097
|
# IS the wrapper. Prime in place with a self-marker
|
|
1098
1098
|
# (never a shell, never the WeakMap round trip).
|
|
1099
1099
|
if NATIVE_C_MINT && node.is_a?(::Moxml::Node)
|
|
1100
|
+
# #340 admits ANY NativeNode subclass as a registered
|
|
1101
|
+
# wrapper klass, and consumers register their own
|
|
1102
|
+
# (define_hot_readers subclasses, leptris-ruby#629) —
|
|
1103
|
+
# the exact-class hash answers only the Identity
|
|
1104
|
+
# originals, so a subclass minted nil here and every
|
|
1105
|
+
# walk-yielded node dropped from results (XPath
|
|
1106
|
+
# answered zero rows with subclasses registered).
|
|
1107
|
+
# Resolve the kind subclass-aware; the hash still
|
|
1108
|
+
# serves the exact originals without the ladder.
|
|
1100
1109
|
type = IDENTITY_WALK_TYPE[node.class]
|
|
1101
|
-
|
|
1110
|
+
unless type
|
|
1111
|
+
type = case node
|
|
1112
|
+
when Identity::ELEMENT
|
|
1113
|
+
:element
|
|
1114
|
+
when Identity::TEXT
|
|
1115
|
+
:text
|
|
1116
|
+
when Identity::CDATA
|
|
1117
|
+
:cdata
|
|
1118
|
+
when Identity::COMMENT
|
|
1119
|
+
:comment
|
|
1120
|
+
when Identity::PROCESSING_INSTRUCTION
|
|
1121
|
+
:processing_instruction
|
|
1122
|
+
end
|
|
1123
|
+
return nil unless type
|
|
1124
|
+
end
|
|
1102
1125
|
|
|
1103
1126
|
node.prime_contract(node, context, self, type)
|
|
1104
1127
|
node.instance_variable_set(:@moxml_wrapper, node)
|
data/lib/moxml/version.rb
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# leptris-ruby#629 — registering SUBCLASSES as wrapper klasses made
|
|
6
|
+
# XPath answer zero rows: wrap_binding_node resolved the node kind
|
|
7
|
+
# through the exact-class hash (IDENTITY_WALK_TYPE), so a subclass
|
|
8
|
+
# minted nil there and every walk-yielded node dropped from results.
|
|
9
|
+
# #340's register_wrapper_klasses admits ANY NativeNode subclass and
|
|
10
|
+
# consumers register their own (define_hot_readers subclasses,
|
|
11
|
+
# leptris-ruby#627) — the resolution must be subclass-aware.
|
|
12
|
+
RSpec.describe "leptris registered-subclass wraps" do
|
|
13
|
+
let(:ctx) { Moxml.new(:leptris) }
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
unless
|
|
17
|
+
defined?(Leptris::XML::Native.define_hot_readers) &&
|
|
18
|
+
ctx.parse("<r/>").native
|
|
19
|
+
.instance_variable_get(:@doc_klass_map)
|
|
20
|
+
skip "binding lacks the C-mint registered-klass face"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def parse_with_map(map)
|
|
25
|
+
ctx.parse('<root xmlns="urn:a"><child xmlns="urn:b"><leaf xmlns=""/></child></root>')
|
|
26
|
+
.tap do |doc|
|
|
27
|
+
doc.native.instance_variable_set(:@doc_klass_map, map) if map
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "matches with the exact classes the adapter registered" do
|
|
32
|
+
doc = parse_with_map(nil) # the adapter registers at parse
|
|
33
|
+
expect(doc.at_xpath("//xmlns:leaf", "xmlns" => "")&.name).to eq("leaf")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "matches with a plain Class.new of the registered element klass" do
|
|
37
|
+
doc = ctx.parse('<root xmlns="urn:a"><child xmlns="urn:b"><leaf xmlns=""/></child></root>')
|
|
38
|
+
orig = doc.native.instance_variable_get(:@doc_klass_map)
|
|
39
|
+
map = [Class.new(orig[0]), orig[1], orig[2], orig[3], orig[4]]
|
|
40
|
+
doc.native.instance_variable_set(:@doc_klass_map, map)
|
|
41
|
+
expect(doc.at_xpath("//xmlns:leaf", "xmlns" => "")&.name).to eq("leaf")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "matches with a define_hot_readers subclass registered" do
|
|
45
|
+
doc = ctx.parse('<root xmlns="urn:a"><child xmlns="urn:b"><leaf xmlns=""/></child></root>')
|
|
46
|
+
orig = doc.native.instance_variable_get(:@doc_klass_map)
|
|
47
|
+
hot = Class.new(orig[0]) do
|
|
48
|
+
Leptris::XML::Native.define_hot_readers(self)
|
|
49
|
+
end
|
|
50
|
+
doc.native.instance_variable_set(:@doc_klass_map,
|
|
51
|
+
[hot, orig[1], orig[2], orig[3], orig[4]])
|
|
52
|
+
row = doc.at_xpath("//xmlns:leaf", "xmlns" => "")
|
|
53
|
+
expect(row&.name).to eq("leaf")
|
|
54
|
+
expect(row).to be_a(hot) # the consumer's klass mints on walks
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "matches with a subclass of every kind registered" do
|
|
58
|
+
doc = ctx.parse('<root xmlns="urn:a"><child xmlns="urn:b"><leaf xmlns=""/></child></root>')
|
|
59
|
+
orig = doc.native.instance_variable_get(:@doc_klass_map)
|
|
60
|
+
map = orig.map { |k| k.is_a?(Class) ? Class.new(k) : k }
|
|
61
|
+
doc.native.instance_variable_set(:@doc_klass_map, map)
|
|
62
|
+
expect(doc.at_xpath("//xmlns:leaf", "xmlns" => "")&.name).to eq("leaf")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "keeps the mint klass through the walk (contract rides the subclass)" do
|
|
66
|
+
doc = ctx.parse('<root xmlns="urn:a"><child xmlns="urn:b"><leaf xmlns=""/></child></root>')
|
|
67
|
+
orig = doc.native.instance_variable_get(:@doc_klass_map)
|
|
68
|
+
map = orig.map { |k| k.is_a?(Class) ? Class.new(k) : k }
|
|
69
|
+
doc.native.instance_variable_set(:@doc_klass_map, map)
|
|
70
|
+
row = doc.at_xpath("//xmlns:leaf", "xmlns" => "")
|
|
71
|
+
expect(row.class).to eq(map[0])
|
|
72
|
+
expect(row).to be_a(Moxml::Node) # the contract still rides
|
|
73
|
+
end
|
|
74
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: moxml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.8
|
|
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-11-
|
|
11
|
+
date: 2026-11-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |
|
|
14
14
|
Moxml is a unified XML manipulation library that provides a common API
|
|
@@ -498,6 +498,7 @@ files:
|
|
|
498
498
|
- spec/moxml/adapter/leptris_parse_lint_spec.rb
|
|
499
499
|
- spec/moxml/adapter/leptris_parse_skips_spec.rb
|
|
500
500
|
- spec/moxml/adapter/leptris_record_driver_spec.rb
|
|
501
|
+
- spec/moxml/adapter/leptris_registered_subclass_spec.rb
|
|
501
502
|
- spec/moxml/adapter/leptris_sax_dup_attr_spec.rb
|
|
502
503
|
- spec/moxml/adapter/leptris_sax_records_spec.rb
|
|
503
504
|
- spec/moxml/adapter/leptris_spec.rb
|