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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ded5e928e12262125965a33ed378e35d8ecc85c3e65de4d514a1fefe0ddd9458
4
- data.tar.gz: b86296c3c0402915fc455696b9bd76b7892a08f58ec8fa9d8ac043fcd36784f4
3
+ metadata.gz: 30ad2e1e2f91d4d31eb467d5a2beee85bc3112585d6383bf37b0a66e6d1bca40
4
+ data.tar.gz: ff7ef79362aa97205ce0b16c7161a9c5d7f25720a3794a967cfb9dbf4afa3a5e
5
5
  SHA512:
6
- metadata.gz: 8a29c038b4e5290a47acab859cf99796e9b653eb991f12e34539871e3dc8f02a6d3e2c66b312db64d87488a308bbb93f365dd5e4294e75fa329a5bfcb77bb174
7
- data.tar.gz: ddfecce2232d70546ed2ac42c9ba5eb000e1d98cee79a00047f0a2927fcb47e40b27b4b35fb282f8086b805428062e664a3652673195e67a6fa7596907579063
6
+ metadata.gz: 580fe3a426ebf5d37017fa727527518a76e2221c34543e58c22a08c41d92300e23dbc8bfc391d7f39b09ffd9b78921b1434dc2a51154af4e507e2be409935e08
7
+ data.tar.gz: 15cbb5eb0ca6795715aea82f2b05e017c6d5726c0b6e814713955aa4da0c7e045b21afd9304b7fd1bfdc1cc685f9b45ee743d80f5e06025770218ae383d76060
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gemspec
9
9
  gem "benchmark"
10
10
  gem "benchmark-ips"
11
11
  gem "get_process_mem"
12
- gem "leptris", "~> 1.9.174.1"
12
+ gem "leptris", "~> 1.9.174"
13
13
  gem "libxml-ruby", ">= 5.0"
14
14
  gem "nokogiri", "~> 1.18"
15
15
  gem "openssl", "~> 3.0"
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moxml
4
- VERSION = "0.5.55"
4
+ VERSION = "0.5.56"
5
5
  end
@@ -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
 
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.55
4
+ version: 0.5.56
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.