moxml 0.5.78 → 0.5.79

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: fd28ba8e6db906efd5a53cf65b12b2eee71739b60ca5b318c4c2013235f5ec1d
4
- data.tar.gz: 2e36bde35317ddebb0a90c3b831f0566aa4e7b120ac51b9aead532309d586b28
3
+ metadata.gz: 9314d43b66d5890286b147d882d0200e33adee9e61209e8088674be8205e11ea
4
+ data.tar.gz: 3ec14b4892a6ae2f0dd2a8d2bded06b86a0c86ce742b20f6763478df4a851963
5
5
  SHA512:
6
- metadata.gz: a2042daf1ec389e25b0a2e8896389944e19414c36881deb40d82327dc9025a1962ae6475d73b4e9e412cd787257a7a19403826b5f76ffacbe6a95fb694702250
7
- data.tar.gz: 8259b9003c8085ce46567f4f75dc34502c41ebf15bff9d66b55499e127be8b69ccdcdabf3a3b1d262802684e26f8f2740b032a2dffed32929f3f121bc749090c
6
+ metadata.gz: bb2f60f496656598a90121c56039f620e4a46518753c9062262d4aa21a7c56db6b3d8b1fa5d3d87f4f45773a1de03d63e731e10ee95fc9fbe1c6d8bab5c3122d
7
+ data.tar.gz: 59d27148762e9b3837feb218bd42820a3a17291b8ac266b8868b730b19dc0d4d84abaa238f60e32a279c31673593dfc70f809d4cefd8b60c6deae173e8f63745
data/README.adoc CHANGED
@@ -103,9 +103,10 @@ entity references (`entity_mode: :keep`), 1.9.193.4+ native plan rows
103
103
  executor (`Moxml::StructPlan`; the floor is the varargs-mint fix),
104
104
  1.9.204+ native document-level parts (created DOCTYPEs as native
105
105
  nodes, document-PI removal, declaration clear). Current
106
- recommendation: 1.9.216+ (the plan-ABI train: bound plan rows,
107
- typed scalars, the #1242 iterparse fix; the engine's 1.9.217+
108
- borrowed-text-run wins ride in automatically).
106
+ recommendation: 1.9.228+ (the #318 text-set fix train; carries
107
+ the plan-ABI surface — bound plan rows, typed scalars, fused
108
+ Descriptor#materialize — plus the 1.9.217+ borrowed-text-run and
109
+ 1.9.221+ memory wins).
109
110
  |===
110
111
 
111
112
  NOTE: moxml's dev Gemfile pins `leptris ~> 1.9.174`, `nokogiri ~> 1.18`,
@@ -644,6 +645,42 @@ root.add_child(title)
644
645
  puts doc.to_xml(indent: 2)
645
646
  ----
646
647
 
648
+ === Fast paths and diagnostics
649
+
650
+ Read-only attribute listing without Attribute node objects — the
651
+ walk-hot shape when only names and values are needed (leptris
652
+ answers in one C crossing; document order, duplicates included):
653
+
654
+ [source,ruby]
655
+ ----
656
+ element.attribute_pairs.each do |name, value|
657
+ # names are shared frozen strings; dup before mutating
658
+ end
659
+ ----
660
+
661
+ Typed struct members on `Moxml::StructPlan` — the executor casts
662
+ in C with no intermediate String (unparseable input degrades to
663
+ the raw String):
664
+
665
+ [source,ruby]
666
+ ----
667
+ plan = Moxml::StructPlan.new do
668
+ element "item", Item,
669
+ attrs: { "price" => [:price, :float], "qty" => [:qty, :integer] },
670
+ text: [:label, :integer]
671
+ end
672
+ ----
673
+
674
+ Recover-class parse diagnostics (duplicate-attribute events and
675
+ siblings) on adapters with the surface; `[]` elsewhere. Read
676
+ while the document is alive:
677
+
678
+ [source,ruby]
679
+ ----
680
+ doc.parse_diagnostics
681
+ # => [{ kind: :recover, message: "Attribute a redefined" }]
682
+ ----
683
+
647
684
  == Real-world examples
648
685
 
649
686
  Practical, runnable examples demonstrating Moxml usage in common scenarios are
@@ -353,10 +353,8 @@ module Moxml
353
353
  }.freeze
354
354
 
355
355
  def wrap_binding_node(node, context)
356
- if node.instance_variable_defined?(:@moxml_wrapper)
357
- cached = node.instance_variable_get(:@moxml_wrapper)
358
- return cached if cached
359
- end
356
+ cached = node.instance_variable_get(:@moxml_wrapper)
357
+ return cached if cached
360
358
 
361
359
  entry = BINDING_FAST_WRAP[node.class]
362
360
  return nil unless entry
@@ -294,6 +294,18 @@ module Moxml
294
294
  element[name.to_s] = value.to_s
295
295
  end
296
296
 
297
+ # Cross-adapter parity for Document#parse_diagnostics
298
+ # (#271): Nokogiri's doc.errors already carries recover-
299
+ # mode entries; mapped into the same { kind:, message: }
300
+ # shape. Kind is :error — Nokogiri does not classify.
301
+ def parse_diagnostics(native_doc)
302
+ return [] unless native_doc.respond_to?(:errors)
303
+
304
+ native_doc.errors.map do |e|
305
+ { kind: :error, message: e.message.to_s }
306
+ end
307
+ end
308
+
297
309
  def attributes(element)
298
310
  # attribute_nodes, not attributes.values: the attributes Hash
299
311
  # is keyed by local name, so xmi:type and type collide 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.78"
4
+ VERSION = "0.5.79"
5
5
  end
@@ -40,4 +40,16 @@ RSpec.describe Moxml::Document do
40
40
  rescue StandardError, LoadError
41
41
  skip "rexml adapter unavailable"
42
42
  end
43
+
44
+ it "maps nokogiri doc.errors into the same shape" do
45
+ ctx = Moxml.new(:nokogiri)
46
+ doc = ctx.parse(%(<r a="1" a="2"/>), recover: true) ||
47
+ ctx.parse(%(<r a="1" a="2"/>))
48
+ diags = doc.parse_diagnostics
49
+ expect(diags).not_to be_empty
50
+ expect(diags.first[:kind]).to eq(:error)
51
+ expect(diags.first[:message]).to be_a(String)
52
+ rescue StandardError, LoadError
53
+ skip "nokogiri adapter unavailable"
54
+ end
43
55
  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.78
4
+ version: 0.5.79
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.