lutaml-model 0.8.150 → 0.8.151
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/opal.yml +9 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/transformation/ordered_applier.rb +38 -21
- data/lutaml-model.gemspec +8 -1
- metadata +9 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: adfeae6e61819206738de78eb4929879eccf78883e990f316693fcaa6e6ab6f5
|
|
4
|
+
data.tar.gz: 99579af55daa357c72ce11b78d10839c4ceb02828f45f8b2bbd35eae735ba0ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53c2c071eb6ee0fd327f7f0defbf5be45812289c468cdec6441ea9b20f52c6605bed1d593de9b2031d6c6b8870229f358eed072b800c122f16d28bdb9991f1ac
|
|
7
|
+
data.tar.gz: 17467fa3f3f51db8bde7ae876b9707f06bb45148cbdfae7a1e8637a188162fcf0c1b5d0baab8612c04931423fec39ba9dbcd972d2f9497822571b77af308c576
|
data/.github/workflows/opal.yml
CHANGED
|
@@ -56,5 +56,14 @@ jobs:
|
|
|
56
56
|
- name: Install dependencies
|
|
57
57
|
run: bundle install
|
|
58
58
|
|
|
59
|
+
- name: Pin moxml to the 0.5 line for the Opal boot
|
|
60
|
+
# moxml 0.6 deleted lib/compat/opal (moxml#516) and the boot
|
|
61
|
+
# manifest appends that path (#914); the lane stays on 0.5.x
|
|
62
|
+
# until it migrates to the moxml-ts wasm binding. The gemspec
|
|
63
|
+
# admits both lines (>= 0.5.139, < 0.7), so this lockfile-local
|
|
64
|
+
# pin selects the Opal-compatible one without restricting
|
|
65
|
+
# CRuby consumers.
|
|
66
|
+
run: bundle update moxml --version '~> 0.5.139'
|
|
67
|
+
|
|
59
68
|
- name: Run Opal tests
|
|
60
69
|
run: bundle exec rake spec:opal
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -9,6 +9,15 @@ module Lutaml
|
|
|
9
9
|
# from XML) AND the mapping is marked as ordered, this module ensures
|
|
10
10
|
# the original XML structure is preserved during serialization.
|
|
11
11
|
module OrderedApplier
|
|
12
|
+
class << self
|
|
13
|
+
# Memo registry for the ordered reconcile (see
|
|
14
|
+
# #element_rule_candidates). Transformations are cached per
|
|
15
|
+
# (class, register), bounding the registry; the host object is
|
|
16
|
+
# the frozen Transformation, so the memo cannot live on it.
|
|
17
|
+
def element_rule_candidates_registry
|
|
18
|
+
@element_rule_candidates_registry ||= {}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
12
21
|
# Apply rules in the order specified by element_order
|
|
13
22
|
#
|
|
14
23
|
# This ensures round-trip serialization preserves the original XML structure.
|
|
@@ -143,25 +152,37 @@ model_class, register_id)
|
|
|
143
152
|
return nil unless order_entry?(object)
|
|
144
153
|
return nil unless object.type == "Element"
|
|
145
154
|
|
|
146
|
-
|
|
155
|
+
# The matching candidate list is deterministic per (compiled
|
|
156
|
+
# rules, name, namespace) — memoize it so each distinct element
|
|
157
|
+
# spelling pays the rule scan once per serialize, not once per
|
|
158
|
+
# element object (#1059-era ordered reconciles scan linearly
|
|
159
|
+
# otherwise).
|
|
160
|
+
candidates = element_rule_candidates(object, compiled_rules)
|
|
161
|
+
|
|
162
|
+
first = candidates.first
|
|
163
|
+
return nil unless first
|
|
164
|
+
return first if candidates.size == 1
|
|
165
|
+
|
|
166
|
+
resolve_shared_name_rule(object, candidates)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Matching element rules for one element spelling, memoized in a
|
|
170
|
+
# module-level registry keyed by the compiled-rules identity: the
|
|
171
|
+
# reconciler host is the (frozen) Transformation itself, so the
|
|
172
|
+
# memo lives here. Transformations are cached per (class,
|
|
173
|
+
# register), bounding the registry.
|
|
174
|
+
def element_rule_candidates(object, compiled_rules)
|
|
175
|
+
registry = OrderedApplier.element_rule_candidates_registry
|
|
176
|
+
key = [compiled_rules.object_id, object.name, object.namespace_uri]
|
|
177
|
+
cached = registry[key]
|
|
178
|
+
return cached if cached
|
|
147
179
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
next unless r.is_a?(::Lutaml::Model::CompiledRule) &&
|
|
180
|
+
object_ns_uri = object.namespace_uri # nil if old element_order (backward compat)
|
|
181
|
+
registry[key] = compiled_rules.select do |r|
|
|
182
|
+
r.is_a?(::Lutaml::Model::CompiledRule) &&
|
|
152
183
|
r.option(:mapping_type) == :element &&
|
|
153
184
|
matches_element_rule?(r, object.name, object_ns_uri)
|
|
154
|
-
|
|
155
|
-
if first.nil?
|
|
156
|
-
first = r
|
|
157
|
-
else
|
|
158
|
-
shared_name = true
|
|
159
|
-
break
|
|
160
|
-
end
|
|
161
185
|
end
|
|
162
|
-
return first unless shared_name
|
|
163
|
-
|
|
164
|
-
resolve_shared_name_rule(object, compiled_rules, object_ns_uri)
|
|
165
186
|
end
|
|
166
187
|
|
|
167
188
|
private
|
|
@@ -210,13 +231,9 @@ model_class, register_id)
|
|
|
210
231
|
# ones. Entries matching no discriminator pair — an unknown value,
|
|
211
232
|
# or an entry without attributes — fall back to the first plain
|
|
212
233
|
# rule.
|
|
213
|
-
def resolve_shared_name_rule(object,
|
|
234
|
+
def resolve_shared_name_rule(object, candidates)
|
|
214
235
|
plain = nil
|
|
215
|
-
|
|
216
|
-
next unless r.is_a?(::Lutaml::Model::CompiledRule) &&
|
|
217
|
-
r.option(:mapping_type) == :element &&
|
|
218
|
-
matches_element_rule?(r, object.name, object_ns_uri)
|
|
219
|
-
|
|
236
|
+
candidates.each do |r|
|
|
220
237
|
pairs = rule_discriminator(r)
|
|
221
238
|
return r if pairs && entry_matches_when_attribute?(object, pairs)
|
|
222
239
|
|
data/lutaml-model.gemspec
CHANGED
|
@@ -41,7 +41,14 @@ Gem::Specification.new do |spec|
|
|
|
41
41
|
# 0.5.84 always passes XML_PARSE_HUGE to libxml2: very large documents
|
|
42
42
|
# parse completely instead of being silently truncated at the 10 MB
|
|
43
43
|
# input-buffer cap (lutaml-model#871).
|
|
44
|
-
|
|
44
|
+
# moxml 0.6.0 removed the Opal surface (lutaml/moxml#516, the
|
|
45
|
+
# cross-language program's phase 4); the CRuby facade faces this
|
|
46
|
+
# gem uses are unchanged, and the full suite is green on the 0.6
|
|
47
|
+
# line. Admit BOTH lines so CRuby consumers resolve 0.6.x while
|
|
48
|
+
# the Opal boot lane (#914) pins its own ~> 0.5.x (lib/compat/opal
|
|
49
|
+
# exists only on 0.5) until it migrates to the moxml-ts wasm
|
|
50
|
+
# binding.
|
|
51
|
+
spec.add_dependency "moxml", ">= 0.5.139", "< 0.7"
|
|
45
52
|
spec.add_dependency "ostruct"
|
|
46
53
|
spec.add_dependency "rubyzip", "~> 3.7"
|
|
47
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.151
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -90,16 +90,22 @@ dependencies:
|
|
|
90
90
|
name: moxml
|
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
|
-
- - "
|
|
93
|
+
- - ">="
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: 0.5.139
|
|
96
|
+
- - "<"
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0.7'
|
|
96
99
|
type: :runtime
|
|
97
100
|
prerelease: false
|
|
98
101
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
102
|
requirements:
|
|
100
|
-
- - "
|
|
103
|
+
- - ">="
|
|
101
104
|
- !ruby/object:Gem::Version
|
|
102
105
|
version: 0.5.139
|
|
106
|
+
- - "<"
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0.7'
|
|
103
109
|
- !ruby/object:Gem::Dependency
|
|
104
110
|
name: ostruct
|
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|