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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c48f1775cb2f4eb3de69655fec93e1bb5d7ad5052b4ed4b82470a687ff2ccf96
4
- data.tar.gz: a7ed111098b147489ca3c4b78c7ca3b2df121d669dc91074a478d1d87e2b5e64
3
+ metadata.gz: 8536f48b75689cbcc22414adaeac301263c491a66418cf5bc8ea71435b53d9ed
4
+ data.tar.gz: f24cc023a8712e3128923860cc647af54fb57e8d70f3c8e426a1b2c291553422
5
5
  SHA512:
6
- metadata.gz: 30761cf2d3ebd5d745308cf86db52c19785ab34fb8356c11f6c06bc4b07ba00c765294de0cea52251fc535c05003f2bf14c0b664b0fbd35e9749ce9e362563f6
7
- data.tar.gz: cd36f13d7b1296d4025ac852755e818661c4c47f17abb0b6d77cd1995ce28757939a9fe7ad5b47de741e8493a42f6e0f764843e6f9314336e3967a620750fb19
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
- return nil unless type
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- VERSION = "0.6.7"
4
+ VERSION = "0.6.8"
5
5
  end
@@ -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.7
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-12 00:00:00.000000000 Z
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