lutaml-model 0.8.174 → 0.8.176

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: d5c88e0fabb05c803bd90e90e239491b158506fbc28a400a5c622947c6b6660f
4
- data.tar.gz: 6963e7357fb635c514dcb65844ca6fba6a72e4db19a254b744dcc43ac38ddade
3
+ metadata.gz: 043fe4dafbc491dfa1b3e2e721df51acc6cc826804a85775629f168b7fbbaed3
4
+ data.tar.gz: 5d1872c2d4f3007ea1622eedb4ca10511cd01e1018df86343be8eee713e46eea
5
5
  SHA512:
6
- metadata.gz: aac56768d97444e04fe6e92ff1c9e4802daf1dc2d974028a972245db3b83b9c77d81993e13733393d2c0b6024329eb31cb4f36b5af1362c88c6faec41c734488
7
- data.tar.gz: b999e90b67a01d971f782e906863e35c3d17ed6da0fb1f37f2c757d473d27d1b30f7385903dd94d4f0bea8dfc88a3209be24f5b2a45c17a70362c9047912f05e
6
+ metadata.gz: 1ffa5704a97039111b3cb302acdf7528dffb5a21638bb9f89be872f1111ec251aafc142effd4927c5c086872a44b91ced016dd49de061cc6737b69f93258720d
7
+ data.tar.gz: e249dbac3b7ced1716aefb6c85c46395ae44a330e29ab881d5e2309d15bdfd1f0ca006456af5d6065532786c5de41c52e21afb9f26f00f2ee5fa72f4863ca3cc
@@ -12,6 +12,12 @@ on:
12
12
  default: 'skip'
13
13
  repository_dispatch:
14
14
  types: [ do-release ]
15
+ # The publish leg: when the release PR (head branch release/v*) merges,
16
+ # metanorma/ci tags the merge commit and publishes (metanorma/ci#515).
17
+ # Ordinary PR closes are skipped inside the reusable workflow.
18
+ pull_request:
19
+ types:
20
+ - closed
15
21
 
16
22
  # Least-privilege ceiling for the called rubygems-release.yml: its release job
17
23
  # needs contents:write (git tag push) and id-token:write (OIDC Trusted Publishing).
@@ -19,6 +25,7 @@ on:
19
25
  permissions:
20
26
  contents: write
21
27
  id-token: write
28
+ pull-requests: write
22
29
 
23
30
  # One release at a time: concurrent bumps race the version commit
24
31
  # and half-published gems are worse than a queued release.
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "complex1-46KB": {
3
- "avg_time": 0.05412612500000099,
4
- "min_time": 0.0533452209999723,
5
- "max_time": 0.05472530600002301,
6
- "allocations": 51133,
7
- "ips": 18.475366562819374
3
+ "avg_time": 0.038987152000004244,
4
+ "min_time": 0.03892064699999764,
5
+ "max_time": 0.0390598830000215,
6
+ "allocations": 51960,
7
+ "ips": 25.649475499002623
8
8
  },
9
9
  "complex4-50KB": {
10
- "avg_time": 0.07426971533332487,
11
- "min_time": 0.07386825400004682,
12
- "max_time": 0.07480207200001132,
13
- "allocations": 71910,
14
- "ips": 13.464438304522481
10
+ "avg_time": 0.054956423999991934,
11
+ "min_time": 0.054518438000002334,
12
+ "max_time": 0.055492561999983536,
13
+ "allocations": 73271,
14
+ "ips": 18.1962348933065
15
15
  },
16
16
  "size1000-245KB": {
17
- "avg_time": 0.4342841280000016,
18
- "min_time": 0.4245886159999941,
19
- "max_time": 0.443060408000008,
20
- "allocations": 406451,
21
- "ips": 2.302639989642901
17
+ "avg_time": 0.30703477966667,
18
+ "min_time": 0.3045259649999821,
19
+ "max_time": 0.30771317600002135,
20
+ "allocations": 414471,
21
+ "ips": 3.2569600130826957
22
22
  },
23
23
  "complex3-567KB": {
24
- "avg_time": 0.6035884146666604,
25
- "min_time": 0.5935764820000031,
26
- "max_time": 0.6103887489999806,
27
- "allocations": 587536,
28
- "ips": 1.6567581081758556
24
+ "avg_time": 0.42949195166667664,
25
+ "min_time": 0.4193377539999972,
26
+ "max_time": 0.433647494000013,
27
+ "allocations": 594058,
28
+ "ips": 2.3283323380552834
29
29
  }
30
30
  }
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "metrology-4KB": {
3
- "avg_time": 0.00901943666666701,
4
- "min_time": 0.008446076000012681,
5
- "max_time": 0.009944491999988259,
3
+ "avg_time": 0.014322055000017523,
4
+ "min_time": 0.01403489000006175,
5
+ "max_time": 0.014681618999929924,
6
6
  "allocations": 7544,
7
- "ips": 110.87166936885141
7
+ "ips": 69.82238233261752
8
8
  },
9
9
  "bmj-49KB": {
10
- "avg_time": 0.08010254133333206,
11
- "min_time": 0.07855880500000012,
12
- "max_time": 0.08229944900000419,
10
+ "avg_time": 0.135603055000009,
11
+ "min_time": 0.13427724500002114,
12
+ "max_time": 0.136363015000029,
13
13
  "allocations": 72378,
14
- "ips": 12.483998426949816
14
+ "ips": 7.374465125434923
15
15
  },
16
16
  "pnas-152KB": {
17
- "avg_time": 0.37417935833332194,
18
- "min_time": 0.3672698569999966,
19
- "max_time": 0.37714925399998833,
17
+ "avg_time": 0.6455222233333492,
18
+ "min_time": 0.6338481379999621,
19
+ "max_time": 0.6546388550000302,
20
20
  "allocations": 259437,
21
- "ips": 2.6725151394086044
21
+ "ips": 1.5491333432894032
22
22
  }
23
23
  }
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "feature-doc-23KB": {
3
- "avg_time": 0.06622223333332992,
4
- "min_time": 0.06541184899998598,
5
- "max_time": 0.06742671500001052,
3
+ "avg_time": 0.04434376266667073,
4
+ "min_time": 0.04373320800002034,
5
+ "max_time": 0.04516191199999753,
6
6
  "allocations": 32998,
7
- "ips": 15.100668607271146
7
+ "ips": 22.55108587687827
8
8
  },
9
9
  "tbx-nisosts-101KB": {
10
- "avg_time": 0.18845745966666527,
11
- "min_time": 0.1869356610000068,
12
- "max_time": 0.18972858899999778,
10
+ "avg_time": 0.12491149966665678,
11
+ "min_time": 0.12318977799998265,
12
+ "max_time": 0.12502275199997825,
13
13
  "allocations": 134786,
14
- "ips": 5.306237289671383
14
+ "ips": 8.005668034317377
15
15
  },
16
16
  "iso-13849-1MB": {
17
- "avg_time": 7.070507873666647,
18
- "min_time": 7.02138297999997,
19
- "max_time": 7.105545188000008,
17
+ "avg_time": 4.2393353286666695,
18
+ "min_time": 4.14070454900002,
19
+ "max_time": 4.346694972999984,
20
20
  "allocations": 1733464,
21
- "ips": 0.1414325558881553
21
+ "ips": 0.23588603459554922
22
22
  },
23
23
  "din-iso-1.1MB": {
24
- "avg_time": 0.7734601796666615,
25
- "min_time": 0.7701626870000098,
26
- "max_time": 0.7775508419999824,
27
- "allocations": 883501,
28
- "ips": 1.292891381209787
24
+ "avg_time": 0.553708032666672,
25
+ "min_time": 0.5457309070000065,
26
+ "max_time": 0.5579077530000234,
27
+ "allocations": 890629,
28
+ "ips": 1.8060059471847907
29
29
  }
30
30
  }
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "800-expressions": {
3
- "avg_time": 0.3305013003333386,
4
- "min_time": 0.32859900500000094,
5
- "max_time": 0.331687751000004,
3
+ "avg_time": 0.20656500466666708,
4
+ "min_time": 0.20511490399999843,
5
+ "max_time": 0.20850260099999218,
6
6
  "allocations": 134002,
7
- "ips": 3.0257067036995475
7
+ "ips": 4.84109107258364
8
8
  }
9
9
  }
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "ea251": {
3
- "avg_time": 0.17868011099999612,
4
- "min_time": 0.17459571999998502,
5
- "max_time": 0.18370481700000596,
6
- "allocations": 183152,
7
- "ips": 5.596593792131804
3
+ "avg_time": 0.19469534333334573,
4
+ "min_time": 0.19171984600001224,
5
+ "max_time": 0.19764657100000704,
6
+ "allocations": 183576,
7
+ "ips": 5.136229674933004
8
8
  },
9
9
  "medium": {
10
- "avg_time": 0.44010202266666926,
11
- "min_time": 0.43002588400000263,
12
- "max_time": 0.4478196080000032,
13
- "allocations": 474403,
14
- "ips": 2.272200418304813
10
+ "avg_time": 0.48711105866667026,
11
+ "min_time": 0.4837137160000111,
12
+ "max_time": 0.4910841039999809,
13
+ "allocations": 475118,
14
+ "ips": 2.052919929055233
15
15
  },
16
16
  "citygml": {
17
- "avg_time": 0.5005277433333314,
18
- "min_time": 0.49570570700001326,
19
- "max_time": 0.5039381569999932,
20
- "allocations": 586804,
21
- "ips": 1.9978912524216268
17
+ "avg_time": 0.5485396233333404,
18
+ "min_time": 0.5461445280000135,
19
+ "max_time": 0.5517981899999995,
20
+ "allocations": 587519,
21
+ "ips": 1.8230223624015454
22
22
  },
23
23
  "large": {
24
- "avg_time": 4.091806745666673,
25
- "min_time": 4.049281349000012,
26
- "max_time": 4.164525467999994,
27
- "allocations": 4531263,
28
- "ips": 0.24439081856908937
24
+ "avg_time": 4.595026431666658,
25
+ "min_time": 4.556988206999989,
26
+ "max_time": 4.632750786000003,
27
+ "allocations": 4538888,
28
+ "ips": 0.2176266045192891
29
29
  }
30
30
  }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.174"
5
+ VERSION = "0.8.176"
6
6
  end
7
7
  end
@@ -125,6 +125,16 @@ module Lutaml
125
125
  # Wildcard attribute families ride the interpretive path too
126
126
  return opt_out!(:all_attributes) if mapping.all_attributes_rule
127
127
 
128
+ # map_all (map_all_content) under a declared element
129
+ # hydrates content nil on the plan lane: the engine
130
+ # materializes raw captures only for element-less models,
131
+ # so the shape silently dropped content (lutaml-model#1167).
132
+ # The interpretive path's scoped capture handles it;
133
+ # per-element raw captures (map_element with raw: :element)
134
+ # keep the fast lane.
135
+ return opt_out!(:element_with_raw) if mapping.element_name &&
136
+ mapping.raw_mapping
137
+
128
138
  rows = []
129
139
  attr_rows = [] # [[rule, attr, row_name]] hydration metadata
130
140
  plan_attrs = [] # [{name:, kind:}] rows for the engine plan
@@ -90,16 +90,72 @@ module Lutaml
90
90
  end
91
91
  private_class_method :syntax_error
92
92
 
93
- # Dump rides the inherited standard (Psych) adapter — this class
94
- # does not override #to_yaml. The native Yeptris::Psych.dump
95
- # does not fold long plain scalars at Psych's 80-column
96
- # boundary, so an override here changes every stored fixture's
97
- # byte format the moment the native lane is selected (the
98
- # 0.8.171 default-flip broke relaton's SAE round-trip spec
99
- # exactly this way: parse parity landed in yeptris 0.6.57+,
100
- # dump folding did not — yeptris#863's remaining scope). Parse
101
- # keeps the native lane, where the parity is real; generation
102
- # returns here when the engine folds at parity.
93
+ # Dump rides the native Yeptris::Psych face when the engine's
94
+ # emitter is byte-parity with the standard adapter, else the
95
+ # inherited standard (Psych) dump. The contract: a stored
96
+ # fixture generated under one adapter must round-trip
97
+ # byte-exactly under the other, or a host whose bundle flips
98
+ # the default engine rewrites every stored YAML (the 0.8.171
99
+ # default-flip broke relaton's SAE suite exactly this way).
100
+ # Parity is capability-based, not version-based: the probe
101
+ # dumps the shape battery through the native face and the
102
+ # standard adapter and compares byte-for-byte. Plain-scalar
103
+ # folding landed in yeptris 0.6.62.1, bare null-valued keys
104
+ # after literal blocks in 0.6.63 (#1264); any engine that
105
+ # misses a shape keeps the standard dump without a version
106
+ # floor.
107
+ def to_yaml(_options = {})
108
+ return super unless self.class.native_dump_parity?
109
+
110
+ require "yeptris/psych"
111
+ Yeptris::Psych.dump(@attributes)
112
+ end
113
+
114
+ # True when the native emitter produces byte-identical output
115
+ # to the standard adapter across the shape battery (the same
116
+ # shapes the adapter spec pins: plain-scalar folding, null
117
+ # keys after literal blocks and quoted siblings, flow, unicode,
118
+ # nesting, multiline). Memoized; any failure — missing psych,
119
+ # engine error, non-parity bytes — reports false so dump rides
120
+ # the standard adapter.
121
+ def self.native_dump_parity?
122
+ return @native_dump_parity unless @native_dump_parity.nil?
123
+
124
+ @native_dump_parity = begin
125
+ require "yeptris/psych"
126
+ dump_parity_shapes.all? do |shape|
127
+ native = Yeptris::Psych.dump(shape)
128
+ # The comparison target is the literal parent class, not
129
+ # this class's to_yaml: the override routes back here
130
+ # while the probe is still unmemoized, recursing to a
131
+ # SystemStackError.
132
+ native == Lutaml::Yaml::Adapter::StandardAdapter.new(shape).to_yaml
133
+ end
134
+ rescue StandardError
135
+ false
136
+ end
137
+ end
138
+
139
+ # The document shapes whose byte treatment historically differs
140
+ # between emitters (leptris/yeptris#863, #1264). Keep in sync
141
+ # with the adapter spec's battery.
142
+ def self.dump_parity_shapes
143
+ [
144
+ {
145
+ "title" => "Taxonomy and Definitions for Terms Related to " \
146
+ "Driving Automation Systems for On-Road Motor " \
147
+ "Vehicles for On-Road Motor Vehicles",
148
+ "roles" => %w[admin dev],
149
+ },
150
+ { "s" => "line1\nline2", "n" => nil },
151
+ { "q" => "has: colon", "n" => nil },
152
+ { "u" => "héllo wörld", "num" => "007", "f" => 1.5, "e" => "" },
153
+ { "deep" => { "deeper" => [{ "x" => "y" }, [4, 5]] } },
154
+ { "multi" => "para one\n\npara two", "dash" => "a - b - c",
155
+ "omitted" => nil },
156
+ { "a" => 1, "b" => [1, 2, 3], "c" => { "d" => true } },
157
+ ]
158
+ end
103
159
  end
104
160
  end
105
161
  end
@@ -185,6 +185,59 @@ module MapAllSpec
185
185
  end
186
186
  end
187
187
 
188
+ # lutaml-model#1167: a root model declaring element + map_all_content
189
+ # hydrates its content and round-trips exactly. The plan lane
190
+ # materializes raw captures only for element-less models, so this
191
+ # shape refuses the plan and rides the interpretive scoped capture.
192
+ it "captures content on a root model declaring element + map_all_content (#1167)" do
193
+ stubbed = Class.new(Lutaml::Model::Serializable) do
194
+ attribute :content, :string
195
+
196
+ xml do
197
+ element "body"
198
+ map_all_content to: :content
199
+ end
200
+ end
201
+
202
+ source = %(<body>hello &lt;b&gt;world&lt;/b&gt;</body>)
203
+ parsed = stubbed.from_xml(source)
204
+ expect(parsed.content).to eq("hello &lt;b&gt;world&lt;/b&gt;")
205
+
206
+ out = stubbed.to_xml(parsed)
207
+ expect(out).to eq(source)
208
+
209
+ reparsed = stubbed.from_xml(out)
210
+ expect(reparsed.content).to eq(parsed.content)
211
+ end
212
+
213
+ it "captures content on an element+raw model embedded through a parent (#1167)" do
214
+ embedded = Class.new(Lutaml::Model::Serializable) do
215
+ attribute :content, :string
216
+
217
+ xml do
218
+ element "body"
219
+ map_all_content to: :content
220
+ end
221
+ end
222
+
223
+ holder = Class.new(Lutaml::Model::Serializable) do
224
+ attribute :body, embedded
225
+
226
+ xml do
227
+ element "holder"
228
+ map_element "body", to: :body
229
+ end
230
+ end
231
+
232
+ source = %(<holder><body>embedded &amp; fine</body></holder>)
233
+ parsed = holder.from_xml(source)
234
+ expect(parsed.body.content).to eq("embedded &amp; fine")
235
+
236
+ out = holder.to_xml(parsed)
237
+ expect(out).to include("embedded &amp; fine")
238
+ expect(out).not_to include("<body/>")
239
+ end
240
+
188
241
  describe "coexistence with other mappings (#223)" do
189
242
  it "captures only unclaimed content alongside mapped elements" do
190
243
  doc_class = Class.new(Lutaml::Model::Serializable) do
@@ -60,9 +60,12 @@ RSpec.describe Lutaml::Yaml::Adapter::YeptrisAdapter do
60
60
  # fixture generated under one adapter must round-trip byte-exactly
61
61
  # under the other, or a host whose bundle flips the default engine
62
62
  # rewrites every stored YAML (relaton's SAE suite caught the
63
- # 0.8.171 default flip this way — the native emitter does not fold
64
- # long plain scalars at Psych's 80-column boundary, so generation
65
- # rides the standard adapter until the engine folds at parity).
63
+ # 0.8.171 default flip this way). Generation rides the native face
64
+ # only when the adapter's capability probe (native_dump_parity?)
65
+ # finds the engine byte-identical across the shape battery —
66
+ # plain-scalar folding landed in yeptris 0.6.62.1, bare null keys
67
+ # after literal blocks in 0.6.63 (leptris/yeptris#863, #1264);
68
+ # engines that miss a shape keep the standard dump.
66
69
  describe "byte parity with the standard adapter" do
67
70
  let(:long_scalar) do
68
71
  "Taxonomy and Definitions for Terms Related to Driving Automation " \
@@ -72,14 +75,42 @@ RSpec.describe Lutaml::Yaml::Adapter::YeptrisAdapter do
72
75
  { "title" => long_scalar, "roles" => %w[admin dev] }
73
76
  end
74
77
 
75
- it "folds long plain scalars exactly like the standard adapter" do
76
- standard = Lutaml::Yaml::Adapter::StandardAdapter.new(wrapped_attributes).to_yaml
77
- expect(described_class.new(wrapped_attributes).to_yaml).to eq(standard)
78
+ # The same shapes the capability probe exercises in
79
+ # yeptris_adapter.rb — keep the two lists in sync.
80
+ let(:parity_shapes) do
81
+ [
82
+ wrapped_attributes,
83
+ { "s" => "line1\nline2", "n" => nil },
84
+ { "q" => "has: colon", "n" => nil },
85
+ { "u" => "héllo wörld", "num" => "007", "f" => 1.5, "e" => "" },
86
+ { "deep" => { "deeper" => [{ "x" => "y" }, [4, 5]] } },
87
+ { "multi" => "para one\n\npara two", "dash" => "a - b - c",
88
+ "omitted" => nil },
89
+ { "a" => 1, "b" => [1, 2, 3], "c" => { "d" => true } },
90
+ ]
78
91
  end
79
92
 
80
- it "parses the standard adapter's folded dump back identically" do
81
- standard = Lutaml::Yaml::Adapter::StandardAdapter.new(wrapped_attributes).to_yaml
82
- expect(described_class.parse(standard)).to eq(wrapped_attributes)
93
+ it "dumps every parity shape byte-identically to the standard adapter" do
94
+ parity_shapes.each do |shape|
95
+ standard = Lutaml::Yaml::Adapter::StandardAdapter.new(shape).to_yaml
96
+ expect(described_class.new(shape).to_yaml).to eq(standard)
97
+ end
98
+ end
99
+
100
+ it "parses the standard adapter's dumps back identically" do
101
+ parity_shapes.each do |shape|
102
+ standard = Lutaml::Yaml::Adapter::StandardAdapter.new(shape).to_yaml
103
+ expect(described_class.parse(standard)).to eq(shape)
104
+ end
105
+ end
106
+
107
+ it "opens the native dump lane when the engine answers the probe" do
108
+ skip "engine not fold-parity on this platform" unless
109
+ described_class.native_dump_parity?
110
+
111
+ first = parity_shapes.first
112
+ expect(described_class.new(first).to_yaml)
113
+ .to eq(Yeptris::Psych.dump(first))
83
114
  end
84
115
  end
85
116
  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.174
4
+ version: 0.8.176
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-11-11 00:00:00.000000000 Z
11
+ date: 2026-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64