lutaml-model 0.3.28 → 0.3.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +14 -15
- data/README.adoc +1 -2
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model/xml_mapping.rb +19 -11
- data/spec/lutaml/model/xml_mapping_spec.rb +14 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fba70c8a3fca206b3109603109812019773027580c47b2e3615d873df6e0ce2d
|
4
|
+
data.tar.gz: 21313fbfb52c29c620eb1020672d337689eed963c25fe56c20baeef139e569b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 274739542b8473ae58b4fc6b78e1152aaef604a55f3c9db0ec5678743573d683b4afdd2429d97d6a24c03fdb2c14a72904bf4e057f480e6bafc635a21fde085a
|
7
|
+
data.tar.gz: b1a7ad49313463676b3afe8732f94ed8ab37f79935f33449c70011bd8a8449934425aa27b9dd25d2a7e25a064afa1e665bf95f8b2eac4ec7cd63be4bcfdb7b8d
|
data/.rubocop_todo.yml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2024-11-
|
3
|
+
# on 2024-11-25 13:01:09 UTC using RuboCop version 1.66.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 185
|
10
10
|
# This cop supports safe autocorrection (--autocorrect).
|
11
11
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
12
12
|
# URISchemes: http, https
|
@@ -26,13 +26,12 @@ Lint/ConstantDefinitionInBlock:
|
|
26
26
|
- 'spec/lutaml/model/validation_spec.rb'
|
27
27
|
- 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
|
28
28
|
|
29
|
-
# Offense count:
|
29
|
+
# Offense count: 1
|
30
30
|
Lint/DuplicateMethods:
|
31
31
|
Exclude:
|
32
|
-
- 'lib/lutaml/model/attribute.rb'
|
33
32
|
- 'lib/lutaml/model/type/float.rb'
|
34
33
|
|
35
|
-
# Offense count:
|
34
|
+
# Offense count: 37
|
36
35
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
37
36
|
Metrics/AbcSize:
|
38
37
|
Exclude:
|
@@ -45,6 +44,7 @@ Metrics/AbcSize:
|
|
45
44
|
- 'lib/lutaml/model/xml_adapter/nokogiri_adapter.rb'
|
46
45
|
- 'lib/lutaml/model/xml_adapter/ox_adapter.rb'
|
47
46
|
- 'lib/lutaml/model/xml_adapter/xml_document.rb'
|
47
|
+
- 'lib/lutaml/model/xml_mapping.rb'
|
48
48
|
- 'lib/lutaml/model/xml_mapping_rule.rb'
|
49
49
|
|
50
50
|
# Offense count: 6
|
@@ -53,7 +53,7 @@ Metrics/AbcSize:
|
|
53
53
|
Metrics/BlockLength:
|
54
54
|
Max: 47
|
55
55
|
|
56
|
-
# Offense count:
|
56
|
+
# Offense count: 28
|
57
57
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
58
58
|
Metrics/CyclomaticComplexity:
|
59
59
|
Exclude:
|
@@ -65,7 +65,7 @@ Metrics/CyclomaticComplexity:
|
|
65
65
|
- 'lib/lutaml/model/xml_adapter/ox_adapter.rb'
|
66
66
|
- 'lib/lutaml/model/xml_adapter/xml_document.rb'
|
67
67
|
|
68
|
-
# Offense count:
|
68
|
+
# Offense count: 55
|
69
69
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
70
70
|
Metrics/MethodLength:
|
71
71
|
Max: 46
|
@@ -75,7 +75,7 @@ Metrics/MethodLength:
|
|
75
75
|
Metrics/ParameterLists:
|
76
76
|
Max: 14
|
77
77
|
|
78
|
-
# Offense count:
|
78
|
+
# Offense count: 25
|
79
79
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
80
80
|
Metrics/PerceivedComplexity:
|
81
81
|
Exclude:
|
@@ -87,7 +87,7 @@ Metrics/PerceivedComplexity:
|
|
87
87
|
- 'lib/lutaml/model/xml_adapter/ox_adapter.rb'
|
88
88
|
- 'lib/lutaml/model/xml_adapter/xml_document.rb'
|
89
89
|
|
90
|
-
# Offense count:
|
90
|
+
# Offense count: 8
|
91
91
|
# Configuration parameters: Prefixes, AllowedPatterns.
|
92
92
|
# Prefixes: when, with, without
|
93
93
|
RSpec/ContextWording:
|
@@ -97,7 +97,7 @@ RSpec/ContextWording:
|
|
97
97
|
- 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
|
98
98
|
- 'spec/lutaml/model/xml_mapping_spec.rb'
|
99
99
|
|
100
|
-
# Offense count:
|
100
|
+
# Offense count: 127
|
101
101
|
# Configuration parameters: CountAsOne.
|
102
102
|
RSpec/ExampleLength:
|
103
103
|
Max: 54
|
@@ -127,16 +127,16 @@ RSpec/MultipleDescribes:
|
|
127
127
|
- 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
|
128
128
|
- 'spec/lutaml/model/xml_adapter_spec.rb'
|
129
129
|
|
130
|
-
# Offense count:
|
130
|
+
# Offense count: 153
|
131
131
|
RSpec/MultipleExpectations:
|
132
132
|
Max: 14
|
133
133
|
|
134
|
-
# Offense count:
|
134
|
+
# Offense count: 24
|
135
135
|
# Configuration parameters: AllowSubject.
|
136
136
|
RSpec/MultipleMemoizedHelpers:
|
137
137
|
Max: 9
|
138
138
|
|
139
|
-
# Offense count:
|
139
|
+
# Offense count: 11
|
140
140
|
# Configuration parameters: AllowedGroups.
|
141
141
|
RSpec/NestedGroups:
|
142
142
|
Max: 4
|
@@ -154,10 +154,9 @@ RSpec/PendingWithoutReason:
|
|
154
154
|
- 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
|
155
155
|
- 'spec/lutaml/model/xml_adapter_spec.rb'
|
156
156
|
|
157
|
-
# Offense count:
|
157
|
+
# Offense count: 1
|
158
158
|
RSpec/RemoveConst:
|
159
159
|
Exclude:
|
160
|
-
- 'spec/lutaml/model/type/decimal_spec.rb'
|
161
160
|
- 'spec/lutaml/model/type_spec.rb'
|
162
161
|
|
163
162
|
# Offense count: 2
|
data/README.adoc
CHANGED
@@ -938,8 +938,7 @@ This includes:
|
|
938
938
|
* attributes
|
939
939
|
* text nodes
|
940
940
|
|
941
|
-
The `map_all` tag is **exclusive** and cannot be combined with other mappings
|
942
|
-
(`map_element`, `map_attribute`, `map_content`) for the same element, ensuring
|
941
|
+
The `map_all` tag is **exclusive** and cannot be combined with other mappings (`map_element`, `map_content`) except for `map_attribute` for the same element, ensuring
|
943
942
|
it captures the entire inner XML content.
|
944
943
|
|
945
944
|
NOTE: An error is raised if `map_all` is defined alongside any other mapping in
|
data/lib/lutaml/model/version.rb
CHANGED
@@ -3,6 +3,13 @@ require_relative "xml_mapping_rule"
|
|
3
3
|
module Lutaml
|
4
4
|
module Model
|
5
5
|
class XmlMapping
|
6
|
+
TYPES = {
|
7
|
+
attribute: :map_attribute,
|
8
|
+
element: :map_element,
|
9
|
+
content: :map_content,
|
10
|
+
all_content: :map_all,
|
11
|
+
}.freeze
|
12
|
+
|
6
13
|
attr_reader :root_element,
|
7
14
|
:namespace_uri,
|
8
15
|
:namespace_prefix,
|
@@ -53,7 +60,7 @@ module Lutaml
|
|
53
60
|
prefix: (prefix_set = false
|
54
61
|
nil)
|
55
62
|
)
|
56
|
-
validate!(name, to, with)
|
63
|
+
validate!(name, to, with, type: TYPES[:element])
|
57
64
|
|
58
65
|
rule = XmlMappingRule.new(
|
59
66
|
name,
|
@@ -84,7 +91,7 @@ module Lutaml
|
|
84
91
|
prefix: (prefix_set = false
|
85
92
|
nil)
|
86
93
|
)
|
87
|
-
validate!(name, to, with)
|
94
|
+
validate!(name, to, with, type: TYPES[:attribute])
|
88
95
|
|
89
96
|
rule = XmlMappingRule.new(
|
90
97
|
name,
|
@@ -114,7 +121,7 @@ module Lutaml
|
|
114
121
|
mixed: false,
|
115
122
|
cdata: false
|
116
123
|
)
|
117
|
-
validate!("content", to, with)
|
124
|
+
validate!("content", to, with, type: TYPES[:content])
|
118
125
|
|
119
126
|
@content_mapping = XmlMappingRule.new(
|
120
127
|
nil,
|
@@ -139,7 +146,7 @@ module Lutaml
|
|
139
146
|
prefix: (prefix_set = false
|
140
147
|
nil)
|
141
148
|
)
|
142
|
-
validate!("__raw_mapping", to, with)
|
149
|
+
validate!("__raw_mapping", to, with, type: TYPES[:all_content])
|
143
150
|
|
144
151
|
rule = XmlMappingRule.new(
|
145
152
|
"__raw_mapping",
|
@@ -158,8 +165,8 @@ module Lutaml
|
|
158
165
|
@raw_mapping = rule
|
159
166
|
end
|
160
167
|
|
161
|
-
def validate!(key, to, with)
|
162
|
-
validate_mappings!(
|
168
|
+
def validate!(key, to, with, type: nil)
|
169
|
+
validate_mappings!(type)
|
163
170
|
|
164
171
|
if to.nil? && with.empty?
|
165
172
|
msg = ":to or :with argument is required for mapping '#{key}'"
|
@@ -172,13 +179,14 @@ module Lutaml
|
|
172
179
|
end
|
173
180
|
end
|
174
181
|
|
175
|
-
def validate_mappings!(
|
176
|
-
|
177
|
-
raise StandardError, "
|
182
|
+
def validate_mappings!(type)
|
183
|
+
if !@raw_mapping.nil? && type != TYPES[:attribute]
|
184
|
+
raise StandardError, "#{type} is not allowed, only #{TYPES[:attribute]} " \
|
185
|
+
"is allowed with #{TYPES[:all_content]}"
|
178
186
|
end
|
179
187
|
|
180
|
-
if !
|
181
|
-
raise StandardError, "
|
188
|
+
if !(elements.empty? && content_mapping.nil?) && type == TYPES[:all_content]
|
189
|
+
raise StandardError, "#{TYPES[:all_content]} is not allowed with other mappings"
|
182
190
|
end
|
183
191
|
end
|
184
192
|
|
@@ -179,6 +179,7 @@ module XmlMapping
|
|
179
179
|
|
180
180
|
class WithMapAll < Lutaml::Model::Serializable
|
181
181
|
attribute :all_content, :string
|
182
|
+
attribute :attr, :string
|
182
183
|
|
183
184
|
xml do
|
184
185
|
root "WithMapAll"
|
@@ -777,30 +778,34 @@ RSpec.describe Lutaml::Model::XmlMapping do
|
|
777
778
|
|
778
779
|
describe "#map_all" do
|
779
780
|
context "when map_all is defined before any other mapping" do
|
780
|
-
let(:error_message) { "no other mappings are allowed with map_all" }
|
781
|
-
|
782
781
|
it "raise error when for map_element with map_all" do
|
783
782
|
expect do
|
784
783
|
XmlMapping::WithMapAll.xml do
|
785
784
|
map_element "ele", to: :ele
|
786
785
|
end
|
787
|
-
end.to raise_error(
|
786
|
+
end.to raise_error(
|
787
|
+
StandardError,
|
788
|
+
"map_element is not allowed, only map_attribute is allowed with map_all",
|
789
|
+
)
|
788
790
|
end
|
789
791
|
|
790
|
-
it "raise error when for
|
792
|
+
it "raise error when for map_content with map_all" do
|
791
793
|
expect do
|
792
794
|
XmlMapping::WithMapAll.xml do
|
793
|
-
|
795
|
+
map_content to: :text
|
794
796
|
end
|
795
|
-
end.to raise_error(
|
797
|
+
end.to raise_error(
|
798
|
+
StandardError,
|
799
|
+
"map_content is not allowed, only map_attribute is allowed with map_all",
|
800
|
+
)
|
796
801
|
end
|
797
802
|
|
798
|
-
it "raise error
|
803
|
+
it "does not raise error for map_attribute with map_all" do
|
799
804
|
expect do
|
800
805
|
XmlMapping::WithMapAll.xml do
|
801
|
-
|
806
|
+
map_attribute "attr", to: :attr
|
802
807
|
end
|
803
|
-
end.
|
808
|
+
end.not_to raise_error
|
804
809
|
end
|
805
810
|
end
|
806
811
|
|
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.3.
|
4
|
+
version: 0.3.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|