lutaml-model 0.8.113 → 0.8.114
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 381cba1519b14ff18965d44164e7d75e4564ac92c803815dad95277b7076ef70
|
|
4
|
+
data.tar.gz: acd3466cbc30ed27ce60ce62b181732ab957abde427da1e609003ced88c47a67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f48a3c4bc8a0242a714d945aae2aaca68ae6c0a8a87cedb038a1229363545bb41f1a3c24f833db86c89e3468cc216c77536af23385cce37e6ce20f8a2e3b142
|
|
7
|
+
data.tar.gz: 9ba5616b479da6952fd44284792ce708712ed6576ba90fa11507581aefd344f30ccd22e5887e3200c714feff15e7e8c95742149f49ac2a5618b2d5ea0f0b742a
|
|
@@ -687,6 +687,10 @@ partition = nil)
|
|
|
687
687
|
# attribute is not a collection, so this guard defers exactly that case
|
|
688
688
|
# to `.validate` while leaving declared ranges checked at parse. A mapped
|
|
689
689
|
# PORO has no `.validate` to defer into, so it keeps the eager check.
|
|
690
|
+
# singular_tolerance: :first on the KV lane (#971): collapse an
|
|
691
|
+
# over-ingested collection before the writer stores it whole.
|
|
692
|
+
value = value.first if attr.tolerates_singular_overflow?(value)
|
|
693
|
+
|
|
690
694
|
if attr.collection? || !instance.is_a?(Lutaml::Model::Serialize)
|
|
691
695
|
attr.valid_collection!(value, context)
|
|
692
696
|
end
|
|
@@ -1031,6 +1031,16 @@ child_mappings, options)
|
|
|
1031
1031
|
rule.attribute_type < Lutaml::Model::Serialize
|
|
1032
1032
|
end
|
|
1033
1033
|
|
|
1034
|
+
if is_nested_model && !value.is_a?(Lutaml::Model::Serialize)
|
|
1035
|
+
# The KV mirror of the XML lane's #971 collapse: a tolerated
|
|
1036
|
+
# singular attribute holding an over-assigned collection
|
|
1037
|
+
# serializes its leading value instead of raising.
|
|
1038
|
+
attr = if model_class.respond_to?(:attributes)
|
|
1039
|
+
model_class.attributes[rule.attribute_name.to_sym]
|
|
1040
|
+
end
|
|
1041
|
+
value = value.first if attr&.tolerates_singular_overflow?(value)
|
|
1042
|
+
end
|
|
1043
|
+
|
|
1034
1044
|
if is_nested_model
|
|
1035
1045
|
# Validate that value matches the expected type
|
|
1036
1046
|
# There are three valid cases:
|
data/lib/lutaml/model/version.rb
CHANGED
data/lutaml-model.gemspec
CHANGED
|
@@ -41,7 +41,7 @@ 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
|
-
spec.add_dependency "moxml", "~> 0.5.
|
|
44
|
+
spec.add_dependency "moxml", "~> 0.5.139"
|
|
45
45
|
spec.add_dependency "ostruct"
|
|
46
46
|
spec.add_dependency "rubyzip", "~> 3.7"
|
|
47
47
|
spec.add_dependency "thor", "~> 1.4"
|
|
@@ -91,4 +91,69 @@ RSpec.describe "singular_tolerance attribute option" do
|
|
|
91
91
|
expect(reduced).to eq(value.first)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
|
+
|
|
95
|
+
describe "on the KeyValue lane" do
|
|
96
|
+
let(:marked_class) do
|
|
97
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
98
|
+
attribute :content, :string
|
|
99
|
+
|
|
100
|
+
key_value do
|
|
101
|
+
map "content", to: :content
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
let(:relation_class) do
|
|
107
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
108
|
+
attribute :rel_type, :string
|
|
109
|
+
attribute :description, "ToleranceMarked", singular_tolerance: :first
|
|
110
|
+
|
|
111
|
+
key_value do
|
|
112
|
+
map "type", to: :rel_type
|
|
113
|
+
map "description", to: :description
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
before do
|
|
119
|
+
stub_const("ToleranceMarked", marked_class)
|
|
120
|
+
stub_const("ToleranceRelation", relation_class)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "keeps the leading value on ingest instead of the whole array" do
|
|
124
|
+
model = ToleranceRelation.from_yaml(
|
|
125
|
+
"---\ntype: cites\ndescription:\n - content: First\n - content: Second\n",
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
expect(model.description).to be_a(ToleranceMarked)
|
|
129
|
+
expect(model.description.content).to eq("First")
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "round-trips the collapsed singular through to_yaml" do
|
|
133
|
+
model = ToleranceRelation.from_yaml(
|
|
134
|
+
"---\ntype: cites\ndescription:\n - content: First\n - content: Second\n",
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
yaml = model.to_yaml
|
|
138
|
+
expect(yaml).to include("First")
|
|
139
|
+
expect(yaml).not_to include("Second")
|
|
140
|
+
expect(ToleranceRelation.from_yaml(yaml).description.content).to eq("First")
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "collapses an over-assigned collection at serialization" do
|
|
144
|
+
model = ToleranceRelation.new(
|
|
145
|
+
rel_type: "cites",
|
|
146
|
+
description: [ToleranceMarked.new(content: "One"),
|
|
147
|
+
ToleranceMarked.new(content: "Two")],
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
yaml = model.to_yaml
|
|
151
|
+
expect(yaml).to include("One")
|
|
152
|
+
expect(yaml).not_to include("Two")
|
|
153
|
+
end
|
|
154
|
+
end
|
|
94
155
|
end
|
|
156
|
+
|
|
157
|
+
# The KV mirror of the XML-lane cases: the YAML lane never consulted
|
|
158
|
+
# the tolerance — ingest stored the whole array and re-serialization
|
|
159
|
+
# raised the mapped-PORO type check.
|
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.114
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -92,14 +92,14 @@ dependencies:
|
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.5.
|
|
95
|
+
version: 0.5.139
|
|
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.
|
|
102
|
+
version: 0.5.139
|
|
103
103
|
- !ruby/object:Gem::Dependency
|
|
104
104
|
name: ostruct
|
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|