moxml 0.5.55 → 0.5.56
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/base.rb +8 -0
- data/lib/moxml/adapter/leptris.rb +12 -0
- data/lib/moxml/node.rb +8 -0
- data/lib/moxml/version.rb +1 -1
- data/spec/moxml/adapter/leptris_spec.rb +19 -0
- 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: 30ad2e1e2f91d4d31eb467d5a2beee85bc3112585d6383bf37b0a66e6d1bca40
|
|
4
|
+
data.tar.gz: ff7ef79362aa97205ce0b16c7161a9c5d7f25720a3794a967cfb9dbf4afa3a5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 580fe3a426ebf5d37017fa727527518a76e2221c34543e58c22a08c41d92300e23dbc8bfc391d7f39b09ffd9b78921b1434dc2a51154af4e507e2be409935e08
|
|
7
|
+
data.tar.gz: 15cbb5eb0ca6795715aea82f2b05e017c6d5726c0b6e814713955aa4da0c7e045b21afd9304b7fd1bfdc1cc685f9b45ee743d80f5e06025770218ae383d76060
|
data/Gemfile
CHANGED
data/lib/moxml/adapter/base.rb
CHANGED
|
@@ -164,6 +164,14 @@ module Moxml
|
|
|
164
164
|
nil
|
|
165
165
|
end
|
|
166
166
|
|
|
167
|
+
# Source position {line, col_start, col_end} for a node where
|
|
168
|
+
# the engine exposes it (leptris 1.9.181+ source_position);
|
|
169
|
+
# nil elsewhere and for nodes without a position (created
|
|
170
|
+
# nodes answer zeros upstream — pass those through as-is).
|
|
171
|
+
def source_position(_native)
|
|
172
|
+
nil
|
|
173
|
+
end
|
|
174
|
+
|
|
167
175
|
# Subtree walk capability: an adapter with a C-side pre-order
|
|
168
176
|
# traversal (leptris >= 1.9.174.6 visit) walks descendants in
|
|
169
177
|
# one dispatch; nil keeps the recursive children walk. Self
|
|
@@ -103,6 +103,12 @@ module Moxml
|
|
|
103
103
|
NN_ADD_CHILD = NN.instance_method(:add_child)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
+
# 1.9.181 (lockstep): Node#source_position — {line, col_start,
|
|
107
|
+
# col_end} from the engine's source-position API (upstream
|
|
108
|
+
# #1124); created nodes report zeros.
|
|
109
|
+
NATIVE_SOURCE_POSITION =
|
|
110
|
+
Gem::Version.new(::Leptris::VERSION) >= Gem::Version.new("1.9.181")
|
|
111
|
+
|
|
106
112
|
# Entity-reference preservation (leptris-ruby#212 / upstream
|
|
107
113
|
# #1094): 1.9.177 ships ParseOptions.keep_entity_refs plus
|
|
108
114
|
# first-class EntityReference nodes — the marker machinery
|
|
@@ -1238,6 +1244,12 @@ module Moxml
|
|
|
1238
1244
|
r
|
|
1239
1245
|
end
|
|
1240
1246
|
|
|
1247
|
+
def source_position(node)
|
|
1248
|
+
return nil unless NATIVE_SOURCE_POSITION
|
|
1249
|
+
|
|
1250
|
+
to_binding(node).source_position
|
|
1251
|
+
end
|
|
1252
|
+
|
|
1241
1253
|
def line_number(node)
|
|
1242
1254
|
if NATIVE_MUTATIONS_COHERENT &&
|
|
1243
1255
|
node.is_a?(::Leptris::XML::NativeNode)
|
data/lib/moxml/node.rb
CHANGED
|
@@ -402,6 +402,14 @@ module Moxml
|
|
|
402
402
|
adapter.line_number(@native)
|
|
403
403
|
end
|
|
404
404
|
|
|
405
|
+
# {line, col_start, col_end} where the engine exposes source
|
|
406
|
+
# positions (leptris 1.9.181+); nil elsewhere. Created nodes
|
|
407
|
+
# answer zeros upstream — distinguishable from nil by callers
|
|
408
|
+
# that care.
|
|
409
|
+
def source_position
|
|
410
|
+
adapter.source_position(@native)
|
|
411
|
+
end
|
|
412
|
+
|
|
405
413
|
# Content-defined Merkle digest of this subtree (issue #173,
|
|
406
414
|
# companion to leptris#869): a u64 Integer where the backend
|
|
407
415
|
# computes one, nil everywhere else. Consumers gate on nil and
|
data/lib/moxml/version.rb
CHANGED
|
@@ -694,6 +694,25 @@ RSpec.describe Moxml::Adapter::Leptris do
|
|
|
694
694
|
end
|
|
695
695
|
end
|
|
696
696
|
|
|
697
|
+
describe "source_position (leptris 1.9.181+, upstream #1124)" do
|
|
698
|
+
let(:ctx) { Moxml.new(:leptris) }
|
|
699
|
+
|
|
700
|
+
it "answers engine source positions for parsed nodes" do
|
|
701
|
+
skip "requires leptris 1.9.181" unless described_class::NATIVE_SOURCE_POSITION
|
|
702
|
+
|
|
703
|
+
doc = ctx.parse("<root>\n <child>text</child>\n</root>")
|
|
704
|
+
expect(doc.root.source_position).to include(line: 1)
|
|
705
|
+
expect(doc.root.source_position).to be_a(Hash)
|
|
706
|
+
end
|
|
707
|
+
|
|
708
|
+
it "answers nil below the gate and on other adapters" do
|
|
709
|
+
expect(Moxml::Adapter::Base.source_position(nil)).to be_nil
|
|
710
|
+
expect(Moxml::Adapter::Nokogiri.source_position(nil)).to be_nil
|
|
711
|
+
noko = Moxml.new(:nokogiri).parse("<root><a/></root>")
|
|
712
|
+
expect(noko.root.children.first.source_position).to be_nil
|
|
713
|
+
end
|
|
714
|
+
end
|
|
715
|
+
|
|
697
716
|
describe "subtree digest (issue #173, leptris#869)" do
|
|
698
717
|
let(:ctx) { Moxml.new(:leptris) }
|
|
699
718
|
|