moxml 0.5.133 → 0.5.135
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/Gemfile +1 -1
- data/lib/moxml/adapter/leptris.rb +10 -0
- data/lib/moxml/version.rb +1 -1
- data/spec/moxml/adapter/leptris_attribute_snapshot_spec.rb +78 -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: 918bd8b9313280260ce7648f0f2a178bec9325143ad68aecdabfcf27f21b0b24
|
|
4
|
+
data.tar.gz: 6b6ebff0e81aca94b07ee71e81a30d40d9fc2bbf74c1a5a27b9f262a51dd30ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 30addc534fe9cdd914a4f8e932aafdcfc6b16cf41f1de807b48311a7daee62e2378cfa6ed6cb09609944db41daa2003723432cf944369b69404b1bdf31af481d
|
|
7
|
+
data.tar.gz: 070ba5d0faf6ab33330db7e8253310e73b87134a350b7962ddea0bd651cf9286baefaaf7c049b48619848f1449265dc46f6a559751af5c6b911b7d643726f490
|
data/Gemfile
CHANGED
|
@@ -194,6 +194,15 @@ module Moxml
|
|
|
194
194
|
::Leptris::XML::ParseOptions.instance_method(:initialize)
|
|
195
195
|
.parameters.any? { |_, key| key == :recover }
|
|
196
196
|
|
|
197
|
+
# moxml#375 — the element-attribute snapshot (binding
|
|
198
|
+
# 1.9.353.0, engine leptris#1689): every attribute's
|
|
199
|
+
# qualified name and value in ONE crossing, replacing the
|
|
200
|
+
# per-attribute reads behind ::Leptris::XML::Element
|
|
201
|
+
# #attribute_pairs.
|
|
202
|
+
ELEMENT_ATTR_SNAPSHOT =
|
|
203
|
+
Gem::Version.new(::Leptris::VERSION) >= Gem::Version.new("1.9.353.0") &&
|
|
204
|
+
::Leptris::XML::Element.method_defined?(:attributes_snapshot)
|
|
205
|
+
|
|
197
206
|
# Markup-accumulating builder face (leptris-ruby#374 lever 2,
|
|
198
207
|
# binding 1.9.313): the DSL accumulates markup in a plain
|
|
199
208
|
# String and ONE native crossing (parse + attach) flushes the
|
|
@@ -2059,6 +2068,7 @@ module Moxml
|
|
|
2059
2068
|
def attribute_pairs(element)
|
|
2060
2069
|
binding_element = to_binding(element)
|
|
2061
2070
|
return super unless binding_element.respond_to?(:attribute_pairs)
|
|
2071
|
+
return binding_element.attributes_snapshot.to_a if ELEMENT_ATTR_SNAPSHOT
|
|
2062
2072
|
|
|
2063
2073
|
binding_element.attribute_pairs
|
|
2064
2074
|
end
|
data/lib/moxml/version.rb
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# moxml#375 — element hydration through the binding's
|
|
6
|
+
# attributes_snapshot face (libleptris 1.9.353, engine
|
|
7
|
+
# leptris#1689): one crossing for every attribute instead of one
|
|
8
|
+
# per attribute. The output contract is stride-identical to the
|
|
9
|
+
# binding's per-attribute face: qualified names, document order,
|
|
10
|
+
# fresh values.
|
|
11
|
+
RSpec.describe "leptris element-attribute snapshot hydration" do
|
|
12
|
+
let(:ctx) { Moxml.new(:leptris) }
|
|
13
|
+
|
|
14
|
+
context "when the snapshot face is armed (>= 1.9.353.0)" do
|
|
15
|
+
before do
|
|
16
|
+
unless Moxml::Adapter::Leptris::ELEMENT_ATTR_SNAPSHOT
|
|
17
|
+
skip "binding #{Leptris::VERSION} has no attributes_snapshot face"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "matches the binding per-attribute face stride for stride" do
|
|
22
|
+
doc = ctx.parse(
|
|
23
|
+
'<root a="1" xml:lang="en" xmlns:ns="urn:u" ns:p="v"/>',
|
|
24
|
+
)
|
|
25
|
+
binding_element = Moxml::Adapter::Leptris.to_binding(doc.root)
|
|
26
|
+
expected = binding_element.attribute_pairs
|
|
27
|
+
|
|
28
|
+
expect(doc.root.attribute_pairs).to eq(expected)
|
|
29
|
+
expect(doc.root.attribute_pairs).to eq(
|
|
30
|
+
[["a", "1"], ["xml:lang", "en"], ["ns:p", "v"]],
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "keeps document order across plain and prefixed attributes" do
|
|
35
|
+
doc = ctx.parse(
|
|
36
|
+
'<root z="9" xmlns:m="urn:m" m:x="8" k="7"/>',
|
|
37
|
+
)
|
|
38
|
+
expect(doc.root.attribute_pairs.map(&:first)).to eq(
|
|
39
|
+
%w[z m:x k],
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "keeps the per-attribute face's memoized-read semantics" do
|
|
44
|
+
doc = ctx.parse('<root a="1"/>')
|
|
45
|
+
first = doc.root.attribute_pairs
|
|
46
|
+
first[0][1] << "mutated"
|
|
47
|
+
|
|
48
|
+
# The wrapper memoizes attribute reads; the snapshot path
|
|
49
|
+
# preserves that (values are shared across reads exactly as
|
|
50
|
+
# the binding face's memo does).
|
|
51
|
+
expect(doc.root.attribute_pairs).to eq([["a", "1mutated"]])
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "hydrates child elements the same way" do
|
|
55
|
+
doc = ctx.parse('<r><child b="2" c="3"/></r>')
|
|
56
|
+
expect(doc.at("//child").attribute_pairs).to eq(
|
|
57
|
+
[["b", "2"], ["c", "3"]],
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "yields an empty list for attribute-less elements" do
|
|
62
|
+
doc = ctx.parse("<root/>")
|
|
63
|
+
expect(doc.root.attribute_pairs).to eq([])
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context "with any arm state" do
|
|
68
|
+
it "agrees with the binding per-attribute face" do
|
|
69
|
+
doc = ctx.parse(
|
|
70
|
+
'<root a="1" xml:lang="en" xmlns:ns="urn:u" ns:p="v"/>',
|
|
71
|
+
)
|
|
72
|
+
binding_element = Moxml::Adapter::Leptris.to_binding(doc.root)
|
|
73
|
+
expect(doc.root.attribute_pairs).to eq(
|
|
74
|
+
binding_element.attribute_pairs,
|
|
75
|
+
)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
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.5.
|
|
4
|
+
version: 0.5.135
|
|
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-10-
|
|
11
|
+
date: 2026-10-14 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
|
|
@@ -450,6 +450,7 @@ files:
|
|
|
450
450
|
- spec/moxml/adapter/headed_ox_spec.rb
|
|
451
451
|
- spec/moxml/adapter/leptris_adoption_spec.rb
|
|
452
452
|
- spec/moxml/adapter/leptris_append_gc_spec.rb
|
|
453
|
+
- spec/moxml/adapter/leptris_attribute_snapshot_spec.rb
|
|
453
454
|
- spec/moxml/adapter/leptris_binding_cap_spec.rb
|
|
454
455
|
- spec/moxml/adapter/leptris_doc_parts_spec.rb
|
|
455
456
|
- spec/moxml/adapter/leptris_parse_skips_spec.rb
|