lutaml-model 0.8.107 → 0.8.109
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/lib/lutaml/json/adapter/yeptris_adapter.rb +11 -0
- data/lib/lutaml/model/attribute.rb +16 -0
- data/lib/lutaml/model/configuration.rb +5 -1
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/yaml/adapter/yeptris_adapter.rb +11 -0
- data/spec/lutaml/json/yeptris_adapter_spec.rb +3 -10
- data/spec/lutaml/model/adapter_resolver_configured_spec.rb +31 -8
- data/spec/lutaml/model/collection_strict_assignment_spec.rb +55 -0
- data/spec/lutaml/yaml/yeptris_adapter_spec.rb +3 -10
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 45a348d47b61525553682dc4a12be7cde6239ba3d8367e1338e8a266c59ad806
|
|
4
|
+
data.tar.gz: 1a3816081d045d022bf6fcb94a6a82bdfe335644bdbc925d3bcf7676522b433c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b0e82b390f6d56ae98f9f98c9c16b121e8c96290cb79c8db0c31723104a0e940d4bfe798f3facee8493b2257f47c4597b91920cf6dff93dfa89e0875970746b
|
|
7
|
+
data.tar.gz: c5e85f1a1a613112a08795db1e299bfda7ba41057091da39e371f24d03759ff739f56ad96b929c7d41b50ecd4bbbf41f87543205e850239c6494d89f3d334398
|
|
@@ -26,6 +26,17 @@ module Lutaml
|
|
|
26
26
|
end
|
|
27
27
|
private_class_method :require_engine
|
|
28
28
|
|
|
29
|
+
# True where the yeptris engine loads (libyeptris present for
|
|
30
|
+
# this platform). Idempotent; a missing or broken install
|
|
31
|
+
# reports false instead of raising, so optional-engine callers
|
|
32
|
+
# can gate on it.
|
|
33
|
+
def self.available?
|
|
34
|
+
require_engine
|
|
35
|
+
true
|
|
36
|
+
rescue LoadError
|
|
37
|
+
false
|
|
38
|
+
end
|
|
39
|
+
|
|
29
40
|
# The parse-error contract is the standard adapter's: invalid
|
|
30
41
|
# input raises JSON::ParserError regardless of the engine, so
|
|
31
42
|
# consumers' rescue ladders (and this gem's own
|
|
@@ -398,11 +398,27 @@ module Lutaml
|
|
|
398
398
|
# cast_items already returns a fresh array, so the plain-Array
|
|
399
399
|
# collection needs no re-wrap — build_collection's
|
|
400
400
|
# collection_class.new would copy it again.
|
|
401
|
+
assert_flat_collection_items!(items)
|
|
401
402
|
return items if !custom_collection? && collection_class == ::Array
|
|
402
403
|
|
|
403
404
|
build_collection(items, register: register)
|
|
404
405
|
end
|
|
405
406
|
|
|
407
|
+
# Fail loudly on nested arrays. A collection's declared element
|
|
408
|
+
# type never admits an Array as an item; the legacy
|
|
409
|
+
# build_collection flatten silently absorbed mis-spliced builder
|
|
410
|
+
# output (expressir#506 surfaced it three frames away in a
|
|
411
|
+
# formatter). The error must land at the assignment boundary.
|
|
412
|
+
def assert_flat_collection_items!(items)
|
|
413
|
+
return unless items.any?(::Array)
|
|
414
|
+
|
|
415
|
+
raise TypeError,
|
|
416
|
+
"collection '#{name}': item " \
|
|
417
|
+
"#{items.index { |item| item.is_a?(::Array) }} is an Array " \
|
|
418
|
+
"where the declared element type is expected; nested arrays " \
|
|
419
|
+
"are not flattened — splice list results before assignment"
|
|
420
|
+
end
|
|
421
|
+
|
|
406
422
|
# Plain Arrays count as list input. On singular attributes
|
|
407
423
|
# collection_instance? matches Arrays too (their collection class is
|
|
408
424
|
# Array), preserving the Array so strict cardinality can flag it.
|
|
@@ -37,7 +37,11 @@ module Lutaml
|
|
|
37
37
|
@conversion_cache = nil
|
|
38
38
|
@configured = false
|
|
39
39
|
@xml_plan_fast_path = true
|
|
40
|
-
|
|
40
|
+
# Opt-in until leptris#1743 lands: the native ordered lane
|
|
41
|
+
# runs away (28+ CPU-min / 14GB RSS on sts-ruby's
|
|
42
|
+
# ISO_13849-1 document) — flipping this on by default regressed
|
|
43
|
+
# the sts bench cell from 4m41s to a 10-minute kill.
|
|
44
|
+
@xml_plan_ordered_path = false
|
|
41
45
|
@element_order_tracking = true
|
|
42
46
|
end
|
|
43
47
|
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -40,6 +40,17 @@ module Lutaml
|
|
|
40
40
|
end
|
|
41
41
|
private_class_method :require_engine
|
|
42
42
|
|
|
43
|
+
# True where the yeptris engine loads (libyeptris present for
|
|
44
|
+
# this platform). Idempotent; a missing or broken install
|
|
45
|
+
# reports false instead of raising, so optional-engine callers
|
|
46
|
+
# can gate on it.
|
|
47
|
+
def self.available?
|
|
48
|
+
require_engine
|
|
49
|
+
true
|
|
50
|
+
rescue LoadError
|
|
51
|
+
false
|
|
52
|
+
end
|
|
53
|
+
|
|
43
54
|
# The parse-error contract is the standard adapter's: invalid
|
|
44
55
|
# input raises Psych::SyntaxError regardless of the engine, so
|
|
45
56
|
# consumers' rescue ladders (and this gem's own
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
4
|
-
begin
|
|
5
|
-
require "lutaml/json/adapter/yeptris_adapter"
|
|
6
|
-
rescue LoadError
|
|
7
|
-
# yeptris ships no platform gem here (e.g. Windows): every example skips.
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
YEPTRIS_AVAILABLE = defined?(Yeptris)
|
|
3
|
+
require "lutaml/json/adapter/yeptris_adapter"
|
|
11
4
|
|
|
12
|
-
RSpec.describe
|
|
13
|
-
before { skip "yeptris is not available on this platform" unless
|
|
5
|
+
RSpec.describe Lutaml::Json::Adapter::YeptrisAdapter do
|
|
6
|
+
before { skip "yeptris is not available on this platform" unless described_class.available? }
|
|
14
7
|
|
|
15
8
|
let(:attributes) { { "name" => "John", "age" => 30, "roles" => %w[admin dev] } }
|
|
16
9
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
|
+
require "open3"
|
|
4
5
|
|
|
5
6
|
RSpec.describe Lutaml::Model::AdapterResolver, ".adapter_for with a configured type" do
|
|
6
7
|
after do
|
|
@@ -22,17 +23,39 @@ RSpec.describe Lutaml::Model::AdapterResolver, ".adapter_for with a configured t
|
|
|
22
23
|
expect(adapter.name).to include("Json::Standard")
|
|
23
24
|
end
|
|
24
25
|
|
|
26
|
+
# Runs in a subprocess: whether the engine is already loaded is a
|
|
27
|
+
# process-global fact, so any in-process assertion would depend on
|
|
28
|
+
# spec file order (the yeptris adapter faces load it).
|
|
25
29
|
it "does not load the optional yeptris engine when a standard adapter is configured" do
|
|
26
|
-
|
|
30
|
+
probe = <<~RUBY
|
|
31
|
+
require "lutaml/model"
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
Lutaml::Model::Config.configure do |config|
|
|
34
|
+
config.yaml_adapter_type = :standard
|
|
35
|
+
config.json_adapter_type = :standard
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
adapter_yaml = Lutaml::Model::AdapterResolver.adapter_for(:yaml)
|
|
39
|
+
adapter_json = Lutaml::Model::AdapterResolver.adapter_for(:json)
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
# Parsing through the configured adapters must likewise stay on
|
|
42
|
+
# the standard engines.
|
|
43
|
+
adapter_yaml.parse("a: 1")
|
|
44
|
+
adapter_json.parse('{"a":1}')
|
|
45
|
+
|
|
46
|
+
exit(Object.const_defined?(:Yeptris) ? 1 : 0)
|
|
47
|
+
RUBY
|
|
48
|
+
|
|
49
|
+
_stdout, stderr, status = Open3.capture3(RbConfig.ruby, "-I", "lib", "-e", probe)
|
|
50
|
+
expect(status).to be_success, stderr
|
|
51
|
+
end
|
|
52
|
+
end
|
|
35
53
|
|
|
36
|
-
|
|
54
|
+
RSpec.describe "plan lane defaults" do
|
|
55
|
+
it "ships the ordered plan lane opt-in until leptris#1743 is fixed" do
|
|
56
|
+
# The native ordered lane runs away on sts-ruby's ISO_13849-1
|
|
57
|
+
# document (leptris#1743): 28+ CPU-min / 14 GB RSS vs 6.36s on the
|
|
58
|
+
# same parse with the lane off. Opt-in until the engine fix ships.
|
|
59
|
+
expect(Lutaml::Model::Config.instance.xml_plan_ordered_path).to be(false)
|
|
37
60
|
end
|
|
38
61
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe "strict collection assignment" do
|
|
6
|
+
let(:node_class) do
|
|
7
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
8
|
+
attribute :id, :string
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:holder_class) do
|
|
13
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
14
|
+
attribute :items, "Node", collection: true
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
before do
|
|
19
|
+
stub_const("Node", node_class)
|
|
20
|
+
stub_const("Holder", holder_class)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "raises at the constructor boundary" do
|
|
24
|
+
expect do
|
|
25
|
+
Holder.new(items: [[Node.new(id: "a")], Node.new(id: "b")])
|
|
26
|
+
end.to raise_error(Lutaml::Model::TypeError, /item 0 is an Array/)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "raises at the writer boundary" do
|
|
30
|
+
holder = Holder.new
|
|
31
|
+
expect do
|
|
32
|
+
holder.items = [Node.new, [Node.new]]
|
|
33
|
+
end.to raise_error(Lutaml::Model::TypeError, /item 1 is an Array/)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "raises for a custom collection class" do
|
|
37
|
+
custom = Class.new(Lutaml::Model::Collection) do
|
|
38
|
+
instances :node, "Node"
|
|
39
|
+
end
|
|
40
|
+
stub_const("NodeBag", custom)
|
|
41
|
+
wrapper = Class.new(Lutaml::Model::Serializable) do
|
|
42
|
+
attribute :bag, "NodeBag"
|
|
43
|
+
end
|
|
44
|
+
stub_const("BagHolder", wrapper)
|
|
45
|
+
|
|
46
|
+
expect do
|
|
47
|
+
BagHolder.new(bag: [[Node.new]])
|
|
48
|
+
end.to raise_error(Lutaml::Model::TypeError, /nested arrays are not flattened/)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "keeps flat assignment untouched" do
|
|
52
|
+
holder = Holder.new(items: [Node.new(id: "x")])
|
|
53
|
+
expect(holder.items.map(&:id)).to eq(["x"])
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
4
|
-
begin
|
|
5
|
-
require "lutaml/yaml/adapter/yeptris_adapter"
|
|
6
|
-
rescue LoadError
|
|
7
|
-
# yeptris ships no platform gem here (e.g. Windows): every example skips.
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
YEPTRIS_AVAILABLE = defined?(Yeptris)
|
|
3
|
+
require "lutaml/yaml/adapter/yeptris_adapter"
|
|
11
4
|
|
|
12
|
-
RSpec.describe
|
|
13
|
-
before { skip "yeptris is not available on this platform" unless
|
|
5
|
+
RSpec.describe Lutaml::Yaml::Adapter::YeptrisAdapter do
|
|
6
|
+
before { skip "yeptris is not available on this platform" unless described_class.available? }
|
|
14
7
|
|
|
15
8
|
let(:attributes) { { "name" => "John", "roles" => %w[admin dev] } }
|
|
16
9
|
|
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.
|
|
4
|
+
version: 0.8.109
|
|
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-10-
|
|
11
|
+
date: 2026-10-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -1724,6 +1724,7 @@ files:
|
|
|
1724
1724
|
- spec/lutaml/model/collection_single_value_coercion_spec.rb
|
|
1725
1725
|
- spec/lutaml/model/collection_spec.rb
|
|
1726
1726
|
- spec/lutaml/model/collection_state_nesting_spec.rb
|
|
1727
|
+
- spec/lutaml/model/collection_strict_assignment_spec.rb
|
|
1727
1728
|
- spec/lutaml/model/collection_validation_spec.rb
|
|
1728
1729
|
- spec/lutaml/model/comparable_model_spec.rb
|
|
1729
1730
|
- spec/lutaml/model/comparison_family_spec.rb
|