lutaml-model 0.8.154 → 0.8.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/.github/workflows/dependent-tests.yml +5 -1
- data/.github/workflows/downstream-performance.yml +6 -0
- data/.github/workflows/opal.yml +10 -2
- data/lib/lutaml/model/compiled_rule.rb +8 -6
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/decisions/decision.rb +23 -6
- data/lib/lutaml/xml/leptris/plan_hydrator.rb +9 -2
- data/lib/lutaml/xml/model_transform.rb +9 -2
- data/lib/lutaml/xml/namespace_collector.rb +19 -9
- data/lib/lutaml/xml/namespace_needs.rb +15 -1
- data/lib/lutaml/xml/transformation/ordered_applier.rb +9 -6
- data/lib/lutaml/xml/xml_attribute.rb +1 -1
- data/lutaml-model.gemspec +5 -5
- metadata +5 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aea44d04f4ea5075f73510466aebf1b3bc292a54cab063e9cffc79d05c0e4eb9
|
|
4
|
+
data.tar.gz: 1048189e193d315c9f72e61642e74480f68c1017d4114bff0e840b86d69f0d8a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36ab80411f6db38bf0b8caa500f676a9facdb7bcbd4faf1b5181fde640bd1772b4627df71f6a35c8995dbe5d59c53a16ff1413b4365cd1fc5fa50b47d341460c
|
|
7
|
+
data.tar.gz: 3a83803c58cfd44d76baa13572285349c682484d8e501c86a51144c03f69b09fc3afd3edcff68df68d5a6ff4d619a4273a894162bc688debd501727c4e1785b9
|
|
@@ -30,7 +30,11 @@ jobs:
|
|
|
30
30
|
# in-process exit (green summary, nonzero code) from test failures.
|
|
31
31
|
# set +e keeps the capture alive under the runner's errexit; the
|
|
32
32
|
# final exit preserves rspec's own status — nothing is masked.
|
|
33
|
-
|
|
33
|
+
# The Failure/Error excerpts follow the list: tail -25 shows only
|
|
34
|
+
# the failed-example names, and a deterministic CI-only failure
|
|
35
|
+
# (the glossarist/iev leg, 2026-10-31) cannot be diagnosed from
|
|
36
|
+
# names alone.
|
|
37
|
+
command: set +e; echo "spec-files=$(find spec -name '*_spec.rb' 2>/dev/null | wc -l)"; bundle exec rspec > rspec-run.log 2>&1; code=$?; echo "rspec-exit=$code"; tail -25 rspec-run.log; grep -B2 -A14 "Failure/Error" rspec-run.log | head -160; exit $code
|
|
34
38
|
repos-json-file: .github/workflows/dependent-repos.json
|
|
35
39
|
after-setup-ruby: |
|
|
36
40
|
if [ -f frontend/package.json ]; then cd frontend && npm install && npm run build; fi
|
|
@@ -181,7 +181,13 @@ jobs:
|
|
|
181
181
|
runs-on: ubuntu-latest
|
|
182
182
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
183
183
|
steps:
|
|
184
|
+
# persist-credentials: false — checkout's persisted Authorization
|
|
185
|
+
# extraheader collides with create-pull-request's own token on the
|
|
186
|
+
# action's `git remote prune` ("Duplicate header: Authorization",
|
|
187
|
+
# HTTP 400), killing every main-push baseline PR.
|
|
184
188
|
- uses: actions/checkout@v6
|
|
189
|
+
with:
|
|
190
|
+
persist-credentials: false
|
|
185
191
|
- name: Download all benchmark results
|
|
186
192
|
uses: actions/download-artifact@v4
|
|
187
193
|
with:
|
data/.github/workflows/opal.yml
CHANGED
|
@@ -62,8 +62,16 @@ jobs:
|
|
|
62
62
|
# until it migrates to the moxml-ts wasm binding. The gemspec
|
|
63
63
|
# admits both lines (>= 0.5.139, < 0.7), so this lockfile-local
|
|
64
64
|
# pin selects the Opal-compatible one without restricting
|
|
65
|
-
# CRuby consumers.
|
|
66
|
-
|
|
65
|
+
# CRuby consumers. The constraint rides a workspace-local
|
|
66
|
+
# Gemfile append — `bundle update` has no --version switch, and
|
|
67
|
+
# the repo's Gemfile/gemspec must stay dual-line for CRuby.
|
|
68
|
+
run: |
|
|
69
|
+
cat >> Gemfile <<'EOF'
|
|
70
|
+
|
|
71
|
+
# CI-local pin (opal.yml): the Opal boot needs moxml 0.5.x.
|
|
72
|
+
gem "moxml", "~> 0.5.139"
|
|
73
|
+
EOF
|
|
74
|
+
bundle update moxml
|
|
67
75
|
|
|
68
76
|
- name: Run Opal tests
|
|
69
77
|
run: bundle exec rake spec:opal
|
|
@@ -74,6 +74,11 @@ module Lutaml
|
|
|
74
74
|
@custom_methods = custom_methods || {}
|
|
75
75
|
@alias_names = alias_names
|
|
76
76
|
@options = options
|
|
77
|
+
# Static per rule; computed here because compiled rules are frozen.
|
|
78
|
+
rule_name = attribute_name.to_s
|
|
79
|
+
@custom_method_only = (rule_name.start_with?("__") &&
|
|
80
|
+
rule_name.end_with?("__")) ||
|
|
81
|
+
(!@custom_methods.empty? && attribute_type.nil?)
|
|
77
82
|
freeze
|
|
78
83
|
end
|
|
79
84
|
|
|
@@ -208,13 +213,10 @@ module Lutaml
|
|
|
208
213
|
# @param args [Array] Arguments (ignored for options)
|
|
209
214
|
# @param block [Proc] Block (ignored for options)
|
|
210
215
|
# @return [Object] The option value or nil
|
|
211
|
-
# Static per rule (
|
|
212
|
-
#
|
|
213
|
-
# to_s instead of the historical two.
|
|
216
|
+
# Static per rule, precomputed at construction (compiled rules are
|
|
217
|
+
# frozen, so it cannot be memoized afterwards).
|
|
214
218
|
def custom_method_only?
|
|
215
|
-
|
|
216
|
-
(name.start_with?("__") && name.end_with?("__")) ||
|
|
217
|
-
(!custom_methods.empty? && attribute_type.nil?)
|
|
219
|
+
@custom_method_only
|
|
218
220
|
end
|
|
219
221
|
|
|
220
222
|
def method_missing(method_name, *args, &block)
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -41,23 +41,40 @@ reason: nil)
|
|
|
41
41
|
freeze
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
# Interned frozen decisions, nested reason → namespace class →
|
|
45
|
+
# prefix, so the hot per-element factory calls reuse one frozen
|
|
46
|
+
# instance per distinct combination instead of rebuilding one.
|
|
47
|
+
@interned = {}
|
|
48
|
+
|
|
49
|
+
class << self
|
|
50
|
+
def interned
|
|
51
|
+
@interned
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
44
55
|
# Convenience factory for prefix format decisions
|
|
45
56
|
def self.prefix(prefix:, namespace_class:, reason:)
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
by_class = (interned[reason] ||= {})[namespace_class] ||= {}
|
|
58
|
+
by_class[prefix] ||= new(format: :prefix, prefix: prefix,
|
|
59
|
+
namespace_class: namespace_class,
|
|
60
|
+
reason: reason)
|
|
48
61
|
end
|
|
49
62
|
|
|
50
63
|
# Convenience factory for default format decisions
|
|
51
64
|
def self.default(namespace_class:, reason:)
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
by_class = (interned[reason] ||= {})[namespace_class] ||= {}
|
|
66
|
+
by_class[nil] ||= new(format: :default, prefix: nil,
|
|
67
|
+
namespace_class: namespace_class,
|
|
68
|
+
reason: reason)
|
|
54
69
|
end
|
|
55
70
|
|
|
56
71
|
# Convenience factory for blank namespace decisions
|
|
57
72
|
# Blank namespace means no xmlns attribute (element not in any namespace)
|
|
58
73
|
def self.blank(namespace_class:, reason:)
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
by_class = (interned[reason] ||= {})[namespace_class] ||= {}
|
|
75
|
+
by_class[nil] ||= new(format: :blank, prefix: nil,
|
|
76
|
+
namespace_class: namespace_class,
|
|
77
|
+
reason: reason)
|
|
61
78
|
end
|
|
62
79
|
|
|
63
80
|
# Check if this decision uses prefix format
|
|
@@ -222,11 +222,18 @@ module Lutaml
|
|
|
222
222
|
def ambiguous_local_spellings?(node, local_name)
|
|
223
223
|
return false unless node.respond_to?(:attributes)
|
|
224
224
|
|
|
225
|
+
# Allocation-free: the local part is compared as a suffix of
|
|
226
|
+
# the raw name instead of splitting out a fresh substring.
|
|
227
|
+
llen = local_name.length
|
|
225
228
|
seen = false
|
|
226
229
|
node.attributes.each_value do |attr|
|
|
227
230
|
name = attr.name.to_s
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
if (colon = name.rindex(":"))
|
|
232
|
+
next unless name.length - colon - 1 == llen &&
|
|
233
|
+
name.end_with?(local_name)
|
|
234
|
+
elsif name != local_name
|
|
235
|
+
next
|
|
236
|
+
end
|
|
230
237
|
|
|
231
238
|
return true if seen
|
|
232
239
|
|
|
@@ -737,8 +737,15 @@ _effective_register)
|
|
|
737
737
|
# prefix + local suffix so prefixed attributes (whose
|
|
738
738
|
# namespaced_name is "prefix:local", never "uri:local") still
|
|
739
739
|
# match, and unprefixed_name is not called per attribute
|
|
740
|
-
# (it splits prefixed names and allocates).
|
|
741
|
-
|
|
740
|
+
# (it splits prefixed names and allocates). The split reuses
|
|
741
|
+
# match_attribute_by_local_name's per-spelling memo.
|
|
742
|
+
parts = NAMESPACED_NAME_PARTS[rule_name]
|
|
743
|
+
unless parts
|
|
744
|
+
parts = [rule_name[(last_colon_index + 1)..],
|
|
745
|
+
rule_name[0...last_colon_index]]
|
|
746
|
+
NAMESPACED_NAME_PARTS[rule_name] = parts
|
|
747
|
+
end
|
|
748
|
+
local_name = parts[0]
|
|
742
749
|
if session
|
|
743
750
|
candidates = session.element_local_attribute_index(doc.root)[local_name]
|
|
744
751
|
# No candidate carries this local name: nothing in the
|
|
@@ -533,7 +533,9 @@ module Lutaml
|
|
|
533
533
|
|
|
534
534
|
if attributes.any?
|
|
535
535
|
# ✅ INSTANCE-AWARE FIX: Build set of actual attribute names
|
|
536
|
-
|
|
536
|
+
# (single pass — no intermediate map Array per element)
|
|
537
|
+
actual_attr_names = Set.new
|
|
538
|
+
element.attributes.each { |attr| actual_attr_names << attr.name }
|
|
537
539
|
|
|
538
540
|
# Collect Type refs for XML attributes (instance-aware)
|
|
539
541
|
mapping.attributes.each do |attr_rule|
|
|
@@ -554,7 +556,10 @@ module Lutaml
|
|
|
554
556
|
|
|
555
557
|
# Collect Type refs for XML elements (only for present elements)
|
|
556
558
|
# Get actual element names from XmlElement children
|
|
557
|
-
actual_elem_names = Set.new
|
|
559
|
+
actual_elem_names = Set.new
|
|
560
|
+
element.children.each do |child|
|
|
561
|
+
actual_elem_names << child.name if child.is_a?(Lutaml::Xml::DataModel::XmlElement)
|
|
562
|
+
end
|
|
558
563
|
mapping.elements.each do |elem_rule|
|
|
559
564
|
# Skip if element not present in XmlElement tree
|
|
560
565
|
next unless actual_elem_names.include?(elem_rule.name.to_s)
|
|
@@ -584,14 +589,17 @@ module Lutaml
|
|
|
584
589
|
end
|
|
585
590
|
|
|
586
591
|
# Recursively collect from children in XmlElement tree
|
|
592
|
+
rules_by_name = nil
|
|
587
593
|
element.children.each do |child|
|
|
588
594
|
if child.is_a?(Lutaml::Xml::DataModel::XmlElement)
|
|
589
595
|
# ✅ FIX: Match child XmlElement to its corresponding element rule
|
|
590
|
-
# to get the correct child mapping
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
rule.name.to_s
|
|
596
|
+
# to get the correct child mapping. The name→rule index is built
|
|
597
|
+
# once per collection instead of a linear find per child.
|
|
598
|
+
rules_by_name ||= mapping.elements.each_with_object({}) do |rule, index|
|
|
599
|
+
index[rule.name.to_s] ||= rule
|
|
594
600
|
end
|
|
601
|
+
child_name = child.name
|
|
602
|
+
matching_rule = rules_by_name[child_name]
|
|
595
603
|
|
|
596
604
|
if matching_rule && attributes.any?
|
|
597
605
|
# Get child's mapper_class and mapping
|
|
@@ -606,9 +614,11 @@ module Lutaml
|
|
|
606
614
|
if child_mapping
|
|
607
615
|
# Recursively collect with child's mapping and register context
|
|
608
616
|
child_needs = NamespaceNeeds.new
|
|
609
|
-
child_options = options
|
|
610
|
-
|
|
611
|
-
|
|
617
|
+
child_options = if options[:mapper_class] == child_type
|
|
618
|
+
options
|
|
619
|
+
else
|
|
620
|
+
options.merge(mapper_class: child_type)
|
|
621
|
+
end
|
|
612
622
|
collect_from_xml_element(child, child_mapping,
|
|
613
623
|
child_needs, **child_options)
|
|
614
624
|
|
|
@@ -58,6 +58,7 @@ module Lutaml
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
(@namespaces ||= {})[key] = usage
|
|
61
|
+
@class_set_version = @class_set_version.to_i + 1
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
# Track a type namespace for a specific attribute
|
|
@@ -66,6 +67,7 @@ module Lutaml
|
|
|
66
67
|
def add_type_namespace(attr_name, ns_class)
|
|
67
68
|
(@type_namespaces ||= {})[attr_name] = ns_class
|
|
68
69
|
(@type_namespace_classes ||= ::Set.new) << ns_class
|
|
70
|
+
@class_set_version = @class_set_version.to_i + 1
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
# Add type attribute namespace to tracking set
|
|
@@ -73,6 +75,7 @@ module Lutaml
|
|
|
73
75
|
def add_type_attribute_namespace(ns_class)
|
|
74
76
|
(@type_attribute_namespaces ||= ::Set.new) << ns_class
|
|
75
77
|
(@type_namespace_classes ||= ::Set.new) << ns_class
|
|
78
|
+
@class_set_version = @class_set_version.to_i + 1
|
|
76
79
|
end
|
|
77
80
|
|
|
78
81
|
# Add type element namespace to tracking set
|
|
@@ -80,6 +83,7 @@ module Lutaml
|
|
|
80
83
|
def add_type_element_namespace(ns_class)
|
|
81
84
|
(@type_element_namespaces ||= ::Set.new) << ns_class
|
|
82
85
|
(@type_namespace_classes ||= ::Set.new) << ns_class
|
|
86
|
+
@class_set_version = @class_set_version.to_i + 1
|
|
83
87
|
end
|
|
84
88
|
|
|
85
89
|
# Add a type reference for lazy resolution
|
|
@@ -136,6 +140,7 @@ module Lutaml
|
|
|
136
140
|
@namespaces[key].merge(usage)
|
|
137
141
|
else
|
|
138
142
|
@namespaces[key] = usage
|
|
143
|
+
@class_set_version = @class_set_version.to_i + 1
|
|
139
144
|
end
|
|
140
145
|
end
|
|
141
146
|
|
|
@@ -156,6 +161,7 @@ module Lutaml
|
|
|
156
161
|
.merge(other.type_attribute_namespaces)
|
|
157
162
|
(@type_element_namespaces ||= ::Set.new)
|
|
158
163
|
.merge(other.type_element_namespaces)
|
|
164
|
+
@class_set_version = @class_set_version.to_i + 1
|
|
159
165
|
|
|
160
166
|
# Merge type refs
|
|
161
167
|
(@type_refs ||= []).concat(other.type_refs)
|
|
@@ -205,11 +211,19 @@ module Lutaml
|
|
|
205
211
|
end
|
|
206
212
|
end
|
|
207
213
|
|
|
208
|
-
# Get all namespace classes (from usage and type namespaces)
|
|
214
|
+
# Get all namespace classes (from usage and type namespaces).
|
|
215
|
+
# Memoized behind a mutation version: the planner asks repeatedly
|
|
216
|
+
# per walk while collection mutates the containers.
|
|
209
217
|
# @return [Set<Class>]
|
|
210
218
|
def all_namespace_classes
|
|
219
|
+
version = @class_set_version.to_i
|
|
220
|
+
cached = @all_namespace_classes_memo
|
|
221
|
+
return cached[1] if cached && cached[0] == version
|
|
222
|
+
|
|
211
223
|
classes = Set.new(namespaces.values.map(&:namespace_class))
|
|
212
224
|
classes.merge(type_namespace_classes)
|
|
225
|
+
@all_namespace_classes_memo = [version, classes]
|
|
226
|
+
classes
|
|
213
227
|
end
|
|
214
228
|
|
|
215
229
|
# Validate internal consistency
|
|
@@ -15,7 +15,7 @@ module Lutaml
|
|
|
15
15
|
# (class, register), bounding the registry; the host object is
|
|
16
16
|
# the frozen Transformation, so the memo cannot live on it.
|
|
17
17
|
def element_rule_candidates_registry
|
|
18
|
-
@element_rule_candidates_registry ||= {}
|
|
18
|
+
@element_rule_candidates_registry ||= {}.compare_by_identity
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
# Apply rules in the order specified by element_order
|
|
@@ -170,15 +170,18 @@ model_class, register_id)
|
|
|
170
170
|
# module-level registry keyed by the compiled-rules identity: the
|
|
171
171
|
# reconciler host is the (frozen) Transformation itself, so the
|
|
172
172
|
# memo lives here. Transformations are cached per (class,
|
|
173
|
-
# register), bounding the registry.
|
|
173
|
+
# register), bounding the registry. The lookup is nested
|
|
174
|
+
# (rules identity → element name → namespace URI) so the hit
|
|
175
|
+
# path allocates no key Array.
|
|
174
176
|
def element_rule_candidates(object, compiled_rules)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
by_rules = OrderedApplier
|
|
178
|
+
.element_rule_candidates_registry[compiled_rules] ||= {}
|
|
179
|
+
by_ns = (by_rules[object.name] ||= {})
|
|
180
|
+
cached = by_ns[object.namespace_uri]
|
|
178
181
|
return cached if cached
|
|
179
182
|
|
|
180
183
|
object_ns_uri = object.namespace_uri # nil if old element_order (backward compat)
|
|
181
|
-
|
|
184
|
+
by_ns[object_ns_uri] = compiled_rules.select do |r|
|
|
182
185
|
r.is_a?(::Lutaml::Model::CompiledRule) &&
|
|
183
186
|
r.option(:mapping_type) == :element &&
|
|
184
187
|
matches_element_rule?(r, object.name, object_ns_uri)
|
data/lutaml-model.gemspec
CHANGED
|
@@ -44,11 +44,11 @@ Gem::Specification.new do |spec|
|
|
|
44
44
|
# moxml 0.6.0 removed the Opal surface (lutaml/moxml#516, the
|
|
45
45
|
# cross-language program's phase 4); the CRuby facade faces this
|
|
46
46
|
# gem uses are unchanged, and the full suite is green on the 0.6
|
|
47
|
-
# line
|
|
48
|
-
# the
|
|
49
|
-
#
|
|
50
|
-
# binding.
|
|
51
|
-
spec.add_dependency "moxml", "
|
|
47
|
+
# line (6386/0 with 0.6.0 resolved). Owner call (2026-10-31):
|
|
48
|
+
# forward-pin the 0.6 series, matching canon (lutaml/canon#298).
|
|
49
|
+
# The Opal boot lane (#914) keeps its own moxml ~> 0.5.x pin until
|
|
50
|
+
# it migrates to the moxml-ts wasm binding.
|
|
51
|
+
spec.add_dependency "moxml", "~> 0.6.0"
|
|
52
52
|
spec.add_dependency "ostruct"
|
|
53
53
|
spec.add_dependency "rubyzip", "~> 3.7"
|
|
54
54
|
spec.add_dependency "thor", "~> 1.4"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.156
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -90,22 +90,16 @@ dependencies:
|
|
|
90
90
|
name: moxml
|
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
|
-
- - "
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.5.139
|
|
96
|
-
- - "<"
|
|
93
|
+
- - "~>"
|
|
97
94
|
- !ruby/object:Gem::Version
|
|
98
|
-
version:
|
|
95
|
+
version: 0.6.0
|
|
99
96
|
type: :runtime
|
|
100
97
|
prerelease: false
|
|
101
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
102
99
|
requirements:
|
|
103
|
-
- - "
|
|
104
|
-
- !ruby/object:Gem::Version
|
|
105
|
-
version: 0.5.139
|
|
106
|
-
- - "<"
|
|
100
|
+
- - "~>"
|
|
107
101
|
- !ruby/object:Gem::Version
|
|
108
|
-
version:
|
|
102
|
+
version: 0.6.0
|
|
109
103
|
- !ruby/object:Gem::Dependency
|
|
110
104
|
name: ostruct
|
|
111
105
|
requirement: !ruby/object:Gem::Requirement
|