lutaml-model 0.8.24 → 0.8.28

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.
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "lutaml/xml/plan_walk"
5
+
6
+ RSpec.describe "XML PlanWalk consumer surface" do
7
+ around do |example|
8
+ Lutaml::Model::Config.with_adapter(xml: :leptris) { example.run }
9
+ end
10
+
11
+ let(:item_class) do
12
+ Class.new(Lutaml::Model::Serializable) do
13
+ attribute :id, :integer
14
+ attribute :name, :string
15
+ attribute :tags, :string, collection: true
16
+
17
+ xml do
18
+ element "row"
19
+ map_attribute "id", to: :id
20
+ map_element "name", to: :name
21
+ map_element "tags", to: :tags
22
+ end
23
+ end
24
+ end
25
+
26
+ it "hydrates equal to the interpretive path on a single-row document" do
27
+ xml = %(<row id="7"><name>Alice</name><tags>x</tags><tags>y</tags></row>)
28
+ walked = Lutaml::Xml::PlanWalk.call(item_class, xml)
29
+ expected = item_class.from_xml(xml)
30
+
31
+ expect(walked).to be_a(item_class)
32
+ expect(walked.id).to eq(expected.id)
33
+ expect(walked.name).to eq(expected.name)
34
+ expect(walked.tags).to eq(expected.tags)
35
+ end
36
+
37
+ it "returns an Array for collection roots" do
38
+ xml = %(<root><row id="1"><name>a</name></row><row id="2"><name>b</name></row></root>)
39
+ item_type = item_class
40
+ root_class = Class.new(Lutaml::Model::Serializable) do
41
+ attribute :item, item_type, collection: true
42
+
43
+ xml do
44
+ element "root"
45
+ map_element "row", to: :item
46
+ end
47
+ end
48
+
49
+ walked = Lutaml::Xml::PlanWalk.call(root_class, xml)
50
+ expected = root_class.from_xml(xml)
51
+
52
+ expect(walked.item).to be_an(Array)
53
+ expect(walked.item.map(&:id)).to eq(expected.item.map(&:id))
54
+ expect(walked.item.map(&:name)).to eq(expected.item.map(&:name))
55
+ end
56
+
57
+ it "walks and hydrates a 5000-row document in under the interpretive cost" do
58
+ xml = +"<root>"
59
+ 5000.times do |i|
60
+ xml << %(<row id="#{i}"><name>r-#{i}</name><tags>a</tags><tags>b</tags></row>)
61
+ end
62
+ xml << "</root>"
63
+
64
+ item_type = item_class
65
+ root_class = Class.new(Lutaml::Model::Serializable) do
66
+ attribute :item, item_type, collection: true
67
+
68
+ xml do
69
+ element "root"
70
+ map_element "row", to: :item
71
+ end
72
+ end
73
+
74
+ walked = Lutaml::Xml::PlanWalk.call(root_class, xml)
75
+ interpretive = root_class.from_xml(xml)
76
+ expect(walked.item.size).to eq(interpretive.item.size)
77
+ expect(walked.item.map(&:id)).to eq(interpretive.item.map(&:id))
78
+ end
79
+
80
+ it "compiles delegate mappings for post-instance routing" do
81
+ # delegates compile and route after the target instance exists
82
+ target = Class.new(Lutaml::Model::Serializable) do
83
+ attribute :note, :string
84
+ xml do
85
+ element "tgt"
86
+ map_element "note", to: :note
87
+ end
88
+ end
89
+ klass = Class.new(Lutaml::Model::Serializable) do
90
+ attribute :tgt, target
91
+ xml do
92
+ element "doc"
93
+ map_element "note", to: :note, delegate: :tgt
94
+ end
95
+ end
96
+
97
+ expect(Lutaml::Xml::PlanCompiler.compile(klass,
98
+ Lutaml::Model::Config.default_register)).not_to be_nil
99
+ expect(Lutaml::Xml::PlanWalk.call(klass, "<doc><note>x</note></doc>").tgt.note)
100
+ .to eq("x")
101
+ end
102
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.24
4
+ version: 0.8.28
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-09-15 00:00:00.000000000 Z
11
+ date: 2026-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 0.5.34
95
+ version: 0.5.56
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 0.5.34
102
+ version: 0.5.56
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: ostruct
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -791,6 +791,9 @@ files:
791
791
  - lib/lutaml/xml/parsed_namespace_set.rb
792
792
  - lib/lutaml/xml/plan_compiler.rb
793
793
  - lib/lutaml/xml/plan_hydrator.rb
794
+ - lib/lutaml/xml/plan_order.rb
795
+ - lib/lutaml/xml/plan_serializer.rb
796
+ - lib/lutaml/xml/plan_walk.rb
794
797
  - lib/lutaml/xml/polymorphic_value_handler.rb
795
798
  - lib/lutaml/xml/qualified_inheritance_strategy.rb
796
799
  - lib/lutaml/xml/rexml.rb
@@ -940,6 +943,7 @@ files:
940
943
  - lib/tasks/performance_helpers.rb
941
944
  - lib/tasks/performance_probe.rake
942
945
  - lib/tasks/performance_probe.rb
946
+ - lib/tasks/performance_probe_plan_walk.rb
943
947
  - lib/tasks/performance_probe_xml.rb
944
948
  - lib/tasks/xml_compiler_benchmark.rb
945
949
  - lib/tasks/xml_optimization_benchmark.rb
@@ -1911,6 +1915,7 @@ files:
1911
1915
  - spec/lutaml/xml/out_of_namespace_parsing_spec.rb
1912
1916
  - spec/lutaml/xml/pipeline_integration_spec.rb
1913
1917
  - spec/lutaml/xml/plan_fast_path_spec.rb
1918
+ - spec/lutaml/xml/plan_walk_spec.rb
1914
1919
  - spec/lutaml/xml/prefix_control_spec.rb
1915
1920
  - spec/lutaml/xml/register_spec.rb
1916
1921
  - spec/lutaml/xml/reusable_mapping_spec.rb