moxml 0.5.54 → 0.5.55

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: ba51d35ca414232eb04fafd976a2f5d24b2f43fff1b0e4c4a69147162da324c7
4
- data.tar.gz: 73df7c7f9da2ff33e4ab2d06f3b56b29b0a09e4784c78eb9907d3ec15f82c234
3
+ metadata.gz: ded5e928e12262125965a33ed378e35d8ecc85c3e65de4d514a1fefe0ddd9458
4
+ data.tar.gz: b86296c3c0402915fc455696b9bd76b7892a08f58ec8fa9d8ac043fcd36784f4
5
5
  SHA512:
6
- metadata.gz: c30f3bef444d6a6da7416e5ee5493c5656a6bbca1f28c9d504c9405b3be54b083eb5bf9a218ed1e0ac1cb94b3551678c028adadf667fcc7b15b50a2e403341ab
7
- data.tar.gz: cef805979f7168ec08ce5dc80624e74a2bef27225233d1389862d84b6d4d9cea56806b50a6231e078a626ba488ce90668e0fd8b40ad6cf11a650a3b154c24041
6
+ metadata.gz: 8a29c038b4e5290a47acab859cf99796e9b653eb991f12e34539871e3dc8f02a6d3e2c66b312db64d87488a308bbb93f365dd5e4294e75fa329a5bfcb77bb174
7
+ data.tar.gz: ddfecce2232d70546ed2ac42c9ba5eb000e1d98cee79a00047f0a2927fcb47e40b27b4b35fb282f8086b805428062e664a3652673195e67a6fa7596907579063
@@ -141,6 +141,29 @@ module Moxml
141
141
  nil
142
142
  end
143
143
 
144
+ # Prefixed-attribute value fast path: adapters whose engine
145
+ # resolves expanded-name (uri, local) lookups natively answer
146
+ # the value here; others fall back to the resolver's
147
+ # attribute-list match. Capability probe, not a class
148
+ # identity check — Moxml::Adapter::Leptris is only defined
149
+ # once that adapter loads (issue #242).
150
+ def expanded_attr_reads?
151
+ false
152
+ end
153
+
154
+ def expanded_attr_value(_element, _uri, _local)
155
+ nil
156
+ end
157
+
158
+ # Engine-side inclusive C14N delegation: adapters whose
159
+ # engine canonicalizes byte-identically to the Ruby reference
160
+ # answer the String here; others (and unsupported shapes)
161
+ # return nil and the Ruby reference runs. Capability probe —
162
+ # same reasoning as expanded_attr_reads? (issue #242).
163
+ def native_inclusive10(_native)
164
+ nil
165
+ end
166
+
144
167
  # Subtree walk capability: an adapter with a C-side pre-order
145
168
  # traversal (leptris >= 1.9.174.6 visit) walks descendants in
146
169
  # one dispatch; nil keeps the recursive children walk. Self
@@ -463,8 +463,27 @@ module Moxml
463
463
  # engine — the same match rule as the resolver (xmlns
464
464
  # declarations invisible, no-namespace never matches a
465
465
  # prefixed name), without materializing the attribute list.
466
+ def expanded_attr_reads?
467
+ true
468
+ end
469
+
470
+ def native_inclusive10(native)
471
+ return nil unless native_c14n_byte_safe?
472
+
473
+ to_binding(native).canonicalize(
474
+ ::Leptris::XML::FFI::C14N_1_0, nil,
475
+ mode: ::Leptris::XML::FFI::C14N_MODE_CANONICAL
476
+ )
477
+ end
478
+
466
479
  def expanded_attr_value(element, uri, local)
467
- element.attribute_ns(uri, local)
480
+ # Bridge first: identity-mode wrappers hand a NativeNode
481
+ # (no attribute_ns); binding elements pass through as-is.
482
+ # The class-receiver is_a? this method replaced was always
483
+ # false — element.adapter IS the adapter class — so the
484
+ # branch sat dead since identity mode and the binding-only
485
+ # assumption went unnoticed (issue #242).
486
+ to_binding(element).attribute_ns(uri, local)
468
487
  end
469
488
 
470
489
  # Fast bare-name read: the binding call plus marker
@@ -42,9 +42,7 @@ module Moxml
42
42
  return nil if uri.nil?
43
43
 
44
44
  adapter = element.adapter
45
- if adapter.is_a?(Moxml::Adapter::Leptris)
46
- return adapter.expanded_attr_value(element.native, uri, local)
47
- end
45
+ return adapter.expanded_attr_value(element.native, uri, local) if adapter.expanded_attr_reads?
48
46
 
49
47
  attr = resolve(element, name)
50
48
  attr&.value
data/lib/moxml/c14n.rb CHANGED
@@ -62,14 +62,7 @@ module Moxml
62
62
  return nil if with_comments || !inclusive_namespaces.empty?
63
63
  return nil unless algorithm_shape_inclusive10?(node_or_xml)
64
64
 
65
- adapter = node_or_xml.context.config.adapter
66
- return nil unless adapter == Moxml::Adapter::Leptris &&
67
- Moxml::Adapter::Leptris.native_c14n_byte_safe?
68
-
69
- Moxml::Adapter::Leptris.to_binding(node_or_xml.native).canonicalize(
70
- ::Leptris::XML::FFI::C14N_1_0, nil,
71
- mode: ::Leptris::XML::FFI::C14N_MODE_CANONICAL
72
- )
65
+ node_or_xml.context.config.adapter.native_inclusive10(node_or_xml.native)
73
66
  end
74
67
 
75
68
  def self.algorithm_shape_inclusive10?(node_or_xml)
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.54"
4
+ VERSION = "0.5.55"
5
5
  end
@@ -105,4 +105,22 @@ RSpec.describe Moxml::AttributeResolver do
105
105
  )).to be(false)
106
106
  end
107
107
  end
108
+
109
+ describe ".resolve_value capability dispatch (issue #242)" do
110
+ it "answers prefixed values through the adapter capability, not class identity" do
111
+ doc = Moxml.new(:nokogiri).parse(
112
+ '<w:f xmlns:w="urn:w"><w:n w:val="Arial"/></w:f>',
113
+ )
114
+ node = doc.root.children.first
115
+
116
+ expect(Moxml::Adapter::Base.expanded_attr_reads?).to be(false)
117
+ expect(Moxml::Adapter::Nokogiri.expanded_attr_reads?).to be(false)
118
+ expect(node["w:val"]).to eq("Arial")
119
+ end
120
+
121
+ it "keeps native c14n delegation behind the adapter protocol" do
122
+ expect(Moxml::Adapter::Base.native_inclusive10(nil)).to be_nil
123
+ expect(Moxml::Adapter::Nokogiri.native_inclusive10(nil)).to be_nil
124
+ end
125
+ end
108
126
  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.54
4
+ version: 0.5.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.