moxml 0.5.154 → 0.5.156
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/document_parts.rb +17 -11
- data/lib/moxml/adapter/leptris.rb +32 -18
- data/lib/moxml/version.rb +1 -1
- 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: 578663f0e38750b9e430278d977cdbd765699eec0b9c0f24bf82248dd236f2c9
|
|
4
|
+
data.tar.gz: aed0e246d474008c4608131a0b7eb9059512cddfbf70cb967a24083a351a8ec2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42e75eb3da6b57e6d9be43fa453557dba052d0d885c268fa58ff1e33c95b70e68eab294ca33a568d694e332824061d900312eaaceac933e65b9f1f537cfb9f73
|
|
7
|
+
data.tar.gz: fa0f76bfacf630899d54c1eae31db2c4bdd1fc9fb7e8c2a3f5e6fdbb76509a941fd15c66ab8bdfaaa6755ad3e6bf5041d1dc5ff9d62ca7c0391695ae959f7f23
|
|
@@ -14,6 +14,18 @@ module Moxml
|
|
|
14
14
|
had_source_declaration document_text
|
|
15
15
|
].freeze
|
|
16
16
|
|
|
17
|
+
# The XML declaration kind is not stable across leptris
|
|
18
|
+
# releases: 1.9.345-era builds lack Leptris::XML::Declaration
|
|
19
|
+
# entirely (the pure-Ruby CustomizedLeptris twin carries the
|
|
20
|
+
# declaration then), later builds expose it again (and list it
|
|
21
|
+
# among the document children, leptris-ruby#459). Resolve the
|
|
22
|
+
# kind set once, by feature detection, and filter both kinds —
|
|
23
|
+
# the shim twin is never a listing node either way.
|
|
24
|
+
DECLARATION_KINDS = [
|
|
25
|
+
::Moxml::Adapter::CustomizedLeptris::Declaration,
|
|
26
|
+
(::Leptris::XML::Declaration if ::Leptris::XML.const_defined?(:Declaration)),
|
|
27
|
+
].compact.freeze
|
|
28
|
+
|
|
17
29
|
def free_document(native)
|
|
18
30
|
DOCUMENT_ATTACHMENT_KEYS.each { |key| attachments.delete(native, key) }
|
|
19
31
|
native.free
|
|
@@ -39,17 +51,11 @@ module Moxml
|
|
|
39
51
|
# leptris-ruby#459 lists the declaration among the binding
|
|
40
52
|
# children; the Nokogiri-shaped facade contract never lists
|
|
41
53
|
# it (the declaration is a preamble part, not a child node)
|
|
42
|
-
# — filtered at the listing seam.
|
|
43
|
-
# conditionally: leptris releases before the declaration
|
|
44
|
-
# node class landed (e.g. 1.9.345) carry no Declaration at
|
|
45
|
-
# all, and referencing the constant unconditionally raises
|
|
46
|
-
# NameError on every document-children listing.
|
|
47
|
-
declaration_class =
|
|
48
|
-
if ::Leptris::XML.const_defined?(:Declaration, false)
|
|
49
|
-
::Leptris::XML::Declaration
|
|
50
|
-
end
|
|
54
|
+
# — filtered at the listing seam.
|
|
51
55
|
children.concat(
|
|
52
|
-
doc.children.to_a.
|
|
56
|
+
doc.children.to_a.reject do |child|
|
|
57
|
+
DECLARATION_KINDS.any? { |kind| child.is_a?(kind) }
|
|
58
|
+
end,
|
|
53
59
|
)
|
|
54
60
|
|
|
55
61
|
texts = attachments.get(doc, :document_text)
|
|
@@ -175,7 +181,7 @@ module Moxml
|
|
|
175
181
|
# emission (a second line here duplicates it — and the
|
|
176
182
|
# 1.9.360 0-arity Declaration#to_xml raises under the
|
|
177
183
|
# options-passing call).
|
|
178
|
-
next if child.is_a?(
|
|
184
|
+
next if DECLARATION_KINDS.any? { |kind| child.is_a?(kind) }
|
|
179
185
|
|
|
180
186
|
parts << raw_serialize(child, options) << "\n"
|
|
181
187
|
end
|
|
@@ -1285,27 +1285,41 @@ module Moxml
|
|
|
1285
1285
|
end
|
|
1286
1286
|
end
|
|
1287
1287
|
|
|
1288
|
-
# 1.9.381.0: the children_read face
|
|
1289
|
-
#
|
|
1290
|
-
#
|
|
1291
|
-
#
|
|
1292
|
-
#
|
|
1293
|
-
#
|
|
1294
|
-
#
|
|
1295
|
-
#
|
|
1288
|
+
# 1.9.381.0: the children_read face served a version-stamped
|
|
1289
|
+
# child memo (leptris-ruby#530) that raw-FFI writes did not
|
|
1290
|
+
# advance (leptris-ruby#545) — the adapter bumps the version at
|
|
1291
|
+
# every raw site (leptris-ruby#543), and the binding's own
|
|
1292
|
+
# element splice bumps it in C, so the memo observes splices.
|
|
1293
|
+
# Probe that contract once with a live splice through the same
|
|
1294
|
+
# faces the adapter uses: prime the memo, splice via the
|
|
1295
|
+
# binding's Element face (NativeNode has no add_*_ sibling
|
|
1296
|
+
# method), and require children_read to see the inserted node.
|
|
1297
|
+
# Unsafe builds take the adapter children path; fixed builds
|
|
1298
|
+
# restore the fast path automatically. Bindings without the
|
|
1299
|
+
# memo faces have nothing to go stale.
|
|
1296
1300
|
def children_read_splice_safe?
|
|
1297
1301
|
return @children_read_splice_safe unless @children_read_splice_safe.nil?
|
|
1298
1302
|
|
|
1299
|
-
@children_read_splice_safe =
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1303
|
+
@children_read_splice_safe =
|
|
1304
|
+
if !NN.method_defined?(:children_read) ||
|
|
1305
|
+
!::Leptris::XML::Document.method_defined?(:native_node)
|
|
1306
|
+
true
|
|
1307
|
+
else
|
|
1308
|
+
begin
|
|
1309
|
+
native_doc = ::Leptris::XML::Document.parse("<r><a/>\n<b/></r>")
|
|
1310
|
+
root = native_doc.native_node
|
|
1311
|
+
root.children_read.to_a # prime the version-stamped memo
|
|
1312
|
+
a = root.children.to_a.first
|
|
1313
|
+
bridged = ::Leptris::XML::Node.wrap(
|
|
1314
|
+
::FFI::Pointer.new(a.address), native_doc
|
|
1315
|
+
)
|
|
1316
|
+
bridged.add_next_sibling(native_doc.create_element("x"))
|
|
1317
|
+
names = root.children_read.to_a.map { |n| n.name.to_s }
|
|
1318
|
+
names[0] == "a" && names[1] == "x"
|
|
1319
|
+
rescue StandardError
|
|
1320
|
+
false
|
|
1321
|
+
end
|
|
1322
|
+
end
|
|
1309
1323
|
end
|
|
1310
1324
|
|
|
1311
1325
|
def xpath_index_document(node)
|
data/lib/moxml/version.rb
CHANGED