lutaml-model 0.8.189 → 0.8.191
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: 8e7b10a03d458c7802e12b80ba1dd59ed0d4f4c75668a69c13d9add36f3722ba
|
|
4
|
+
data.tar.gz: 3a8bee4fcd326b8dd9d1ecded4c7e285f35792cd41d03cc01aa67b3fbc0970e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 353c5e1fbb2e53f1f4013f0d8e33b72aa345dfc29c98ce306060233f97a1403bf978bfeef4bf8d03fb0318758ac3a4e0d47fb1bc614662a2a6be4f65b687b50f
|
|
7
|
+
data.tar.gz: 57aca3cc29495f7418d9d8c31932c5655359448ae54c8480177c577f26bd9f971a19787b2deaab7929cb8411cf3f254cc85290d2db81b523bd0a56475c3b74b1
|
|
@@ -643,17 +643,12 @@ module Lutaml
|
|
|
643
643
|
return resolved_type.new(value)
|
|
644
644
|
end
|
|
645
645
|
|
|
646
|
-
# A plain scalar for a mapped complex attribute
|
|
647
|
-
#
|
|
648
|
-
#
|
|
649
|
-
#
|
|
650
|
-
#
|
|
651
|
-
#
|
|
652
|
-
if value.is_a?(::String) && !hash_type? &&
|
|
653
|
-
resolved_type.include?(Lutaml::Model::Serialize)
|
|
654
|
-
content_attr = scalar_content_attribute_for(resolved_type)
|
|
655
|
-
return resolved_type.new(content_attr => value) if content_attr
|
|
656
|
-
end
|
|
646
|
+
# A plain scalar for a mapped complex attribute does NOT coerce
|
|
647
|
+
# here: this method is shared with direct construction
|
|
648
|
+
# (Model.new), where an assigned String must keep verbatim
|
|
649
|
+
# (the 0.8.x contract — #1252). The scalar-coercion contract
|
|
650
|
+
# (#1228: `title: "Coll"` builds the localized title) lives
|
|
651
|
+
# solely at the format boundary — see cast_present.
|
|
657
652
|
|
|
658
653
|
# Special handling for Reference types - pass the metadata
|
|
659
654
|
# (the comparison is attribute-constant; memoize the verdict)
|
data/lib/lutaml/model/version.rb
CHANGED
data/lutaml-model.gemspec
CHANGED
|
@@ -50,7 +50,12 @@ Gem::Specification.new do |spec|
|
|
|
50
50
|
# workspace-local 0.5.x pin is retired with this floor — it cannot
|
|
51
51
|
# resolve against it — and the boot's lib/compat/opal append is
|
|
52
52
|
# directory-guarded in the Rakefile for both lines.
|
|
53
|
-
|
|
53
|
+
# 0.6.23: preprocess_entities stopped rewriting the declared
|
|
54
|
+
# encoding of text payloads beginning with an XML declaration
|
|
55
|
+
# (lutaml/moxml#604) — the text-emission verbatim contract
|
|
56
|
+
# (lutaml-model#1249, rfc8794's embedded-XML sourcecode). The floor
|
|
57
|
+
# is the fix version.
|
|
58
|
+
spec.add_dependency "moxml", "~> 0.6.23"
|
|
54
59
|
spec.add_dependency "ostruct"
|
|
55
60
|
# LML grammar machinery (subsumed language core)
|
|
56
61
|
spec.add_dependency "parsanol", "~> 1.5.0"
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# lutaml-model#1252: direct construction must keep an assigned String
|
|
6
|
+
# verbatim, even when the declared type is a Serializable whose
|
|
7
|
+
# (derived or explicit) mapping exposes a scalar `content` rule. The
|
|
8
|
+
# scalar-coercion contract (#1228, #978) belongs to the format
|
|
9
|
+
# boundary (from_json/from_yaml/from_hash) only.
|
|
10
|
+
RSpec.describe "direct construction keeps assigned scalars verbatim" do
|
|
11
|
+
let(:text_element_class) do
|
|
12
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
13
|
+
attribute :content, Lutaml::Model::Serializable, default: -> { "" },
|
|
14
|
+
polymorphic: [Lutaml::Model::Type::String, :array]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
let(:title_class) do
|
|
19
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
20
|
+
attribute :content, "VerbatimTextElement"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
before do
|
|
25
|
+
stub_const("VerbatimTextElement", text_element_class)
|
|
26
|
+
stub_const("VerbatimTitle", title_class)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# The ceradoc shape: derived mapping, polymorphic inner content.
|
|
30
|
+
it "keeps the String with a derived content mapping (#1252)" do
|
|
31
|
+
title = VerbatimTitle.new(content: "Test Document")
|
|
32
|
+
|
|
33
|
+
expect(title.content).to be_a(String)
|
|
34
|
+
expect(title.content).to eq("Test Document")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "keeps the String with an explicit keyed content mapping" do
|
|
38
|
+
element_class = Class.new(Lutaml::Model::Serializable) do
|
|
39
|
+
attribute :content, :string
|
|
40
|
+
|
|
41
|
+
key_value do
|
|
42
|
+
map "content", to: :content
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
stub_const("VerbatimMappedElement", element_class)
|
|
46
|
+
|
|
47
|
+
holder = Class.new(Lutaml::Model::Serializable) do
|
|
48
|
+
attribute :body, "VerbatimMappedElement"
|
|
49
|
+
end
|
|
50
|
+
stub_const("VerbatimMappedHolder", holder)
|
|
51
|
+
|
|
52
|
+
model = VerbatimMappedHolder.new(body: "plain text")
|
|
53
|
+
|
|
54
|
+
expect(model.body).to be_a(String)
|
|
55
|
+
expect(model.body).to eq("plain text")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "still coerces at the deserialization boundary (#1228 contract)" do
|
|
59
|
+
element_class = Class.new(Lutaml::Model::Serializable) do
|
|
60
|
+
attribute :content, :string
|
|
61
|
+
|
|
62
|
+
key_value do
|
|
63
|
+
map "content", to: :content
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
stub_const("BoundaryMappedElement", element_class)
|
|
67
|
+
|
|
68
|
+
holder = Class.new(Lutaml::Model::Serializable) do
|
|
69
|
+
attribute :body, "BoundaryMappedElement"
|
|
70
|
+
|
|
71
|
+
key_value do
|
|
72
|
+
map "body", to: :body
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
stub_const("BoundaryHolder", holder)
|
|
76
|
+
|
|
77
|
+
model = BoundaryHolder.from_json('{"body": "wire text"}')
|
|
78
|
+
|
|
79
|
+
expect(model.body).to be_a(BoundaryMappedElement)
|
|
80
|
+
expect(model.body.content).to eq("wire text")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
# lutaml-model#1249: text content emission must pass verbatim payloads
|
|
6
|
+
# through — a value that begins with an embedded XML declaration keeps
|
|
7
|
+
# its original declaration spelling (rfc8794's <sourcecode> carries an
|
|
8
|
+
# escaped XML example). moxml 0.6.23 fixed preprocess_entities to skip
|
|
9
|
+
# the declared-encoding rewrite outside document-parse entry
|
|
10
|
+
# (lutaml/moxml#604); the gemspec floors moxml at that version.
|
|
11
|
+
RSpec.describe "verbatim text content emission (#1249)" do
|
|
12
|
+
let(:embedded_declaration) do
|
|
13
|
+
%(<?xml version="1.0" encoding="utf-8"?>\n<EBMLSchema xmlns="urn:ietf:rfc:8794" version="1">\n</EBMLSchema>)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let(:model_class) do
|
|
17
|
+
Class.new(Lutaml::Model::Serializable) do
|
|
18
|
+
attribute :content, :string, collection: true
|
|
19
|
+
|
|
20
|
+
xml do
|
|
21
|
+
element "sourcecode"
|
|
22
|
+
mixed_content
|
|
23
|
+
map_content to: :content
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "keeps the declared encoding of an embedded declaration verbatim" do
|
|
29
|
+
instance = model_class.new(content: [embedded_declaration])
|
|
30
|
+
output = instance.to_xml
|
|
31
|
+
|
|
32
|
+
aggregate_failures do
|
|
33
|
+
expect(output).to include('encoding="utf-8"')
|
|
34
|
+
expect(output).not_to include('encoding="UTF-8"')
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "round-trips the payload through parse and serialize unchanged" do
|
|
39
|
+
source = <<~XML
|
|
40
|
+
<sourcecode>#{embedded_declaration.gsub('<', '<').gsub('>', '>')}</sourcecode>
|
|
41
|
+
XML
|
|
42
|
+
|
|
43
|
+
parsed = model_class.from_xml(source)
|
|
44
|
+
output = parsed.to_xml
|
|
45
|
+
|
|
46
|
+
aggregate_failures do
|
|
47
|
+
expect(parsed.content.first).to eq(embedded_declaration)
|
|
48
|
+
expect(output).to include('encoding="utf-8"')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
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.
|
|
4
|
+
version: 0.8.191
|
|
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
|
+
date: 2026-11-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -92,14 +92,14 @@ dependencies:
|
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.6.
|
|
95
|
+
version: 0.6.23
|
|
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.6.
|
|
102
|
+
version: 0.6.23
|
|
103
103
|
- !ruby/object:Gem::Dependency
|
|
104
104
|
name: ostruct
|
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -2087,6 +2087,7 @@ files:
|
|
|
2087
2087
|
- spec/lutaml/model/delegation_spec.rb
|
|
2088
2088
|
- spec/lutaml/model/derived_attribute_serialization_spec.rb
|
|
2089
2089
|
- spec/lutaml/model/desc_spec.rb
|
|
2090
|
+
- spec/lutaml/model/direct_construction_verbatim_spec.rb
|
|
2090
2091
|
- spec/lutaml/model/dynamic_attribute_spec.rb
|
|
2091
2092
|
- spec/lutaml/model/encoding_spec.rb
|
|
2092
2093
|
- spec/lutaml/model/enum_spec.rb
|
|
@@ -2423,6 +2424,7 @@ files:
|
|
|
2423
2424
|
- spec/lutaml/xml/schema_primer_spec.rb
|
|
2424
2425
|
- spec/lutaml/xml/serializable_namespace_spec.rb
|
|
2425
2426
|
- spec/lutaml/xml/shared_element_rules_spec.rb
|
|
2427
|
+
- spec/lutaml/xml/text_content_verbatim_spec.rb
|
|
2426
2428
|
- spec/lutaml/xml/transformation/custom_method_wrapper_spec.rb
|
|
2427
2429
|
- spec/lutaml/xml/transformation_spec.rb
|
|
2428
2430
|
- spec/lutaml/xml/type_namespace/collector_spec.rb
|