lutaml-model 0.6.7 → 0.7.2
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/.github/workflows/dependent-repos-todo.json +7 -0
- data/.github/workflows/dependent-repos.json +17 -9
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +51 -65
- data/Gemfile +4 -1
- data/README.adoc +5083 -2612
- data/RELEASE_NOTES.adoc +346 -0
- data/docs/custom_adapters.adoc +144 -0
- data/lib/lutaml/model/attribute.rb +101 -16
- data/lib/lutaml/model/choice.rb +7 -0
- data/lib/lutaml/model/comparable_model.rb +48 -9
- data/lib/lutaml/model/config.rb +48 -42
- data/lib/lutaml/model/error/collection_count_out_of_range_error.rb +1 -1
- data/lib/lutaml/model/error/polymorphic_error.rb +14 -0
- data/lib/lutaml/model/error.rb +1 -0
- data/lib/lutaml/model/format_registry.rb +41 -0
- data/lib/lutaml/model/hash/document.rb +11 -0
- data/lib/lutaml/model/hash/mapping.rb +19 -0
- data/lib/lutaml/model/hash/mapping_rule.rb +9 -0
- data/lib/lutaml/model/hash/standard_adapter.rb +17 -0
- data/lib/lutaml/model/hash/transform.rb +8 -0
- data/lib/lutaml/model/hash.rb +21 -0
- data/lib/lutaml/model/json/document.rb +11 -0
- data/lib/lutaml/model/json/mapping.rb +19 -0
- data/lib/lutaml/model/json/mapping_rule.rb +9 -0
- data/lib/lutaml/model/{json_adapter → json}/multi_json_adapter.rb +4 -5
- data/lib/lutaml/model/{json_adapter/standard_json_adapter.rb → json/standard_adapter.rb} +5 -3
- data/lib/lutaml/model/json/transform.rb +8 -0
- data/lib/lutaml/model/json.rb +21 -0
- data/lib/lutaml/model/key_value_document.rb +27 -0
- data/lib/lutaml/model/{key_value_mapping.rb → mapping/key_value_mapping.rb} +64 -16
- data/lib/lutaml/model/{key_value_mapping_rule.rb → mapping/key_value_mapping_rule.rb} +18 -2
- data/lib/lutaml/model/mapping/mapping.rb +13 -0
- data/lib/lutaml/model/mapping/mapping_rule.rb +300 -0
- data/lib/lutaml/model/schema/xml_compiler.rb +15 -15
- data/lib/lutaml/model/sequence.rb +2 -2
- data/lib/lutaml/model/serialization_adapter.rb +22 -0
- data/lib/lutaml/model/serialize.rb +219 -444
- data/lib/lutaml/model/services/logger.rb +54 -0
- data/lib/lutaml/model/services/transformer.rb +48 -0
- data/lib/lutaml/model/services.rb +2 -0
- data/lib/lutaml/model/toml/document.rb +11 -0
- data/lib/lutaml/model/toml/mapping.rb +27 -0
- data/lib/lutaml/model/toml/mapping_rule.rb +9 -0
- data/lib/lutaml/model/{toml_adapter → toml}/toml_rb_adapter.rb +3 -3
- data/lib/lutaml/model/toml/tomlib_adapter.rb +19 -0
- data/lib/lutaml/model/toml/transform.rb +8 -0
- data/lib/lutaml/model/toml.rb +30 -0
- data/lib/lutaml/model/transform/key_value_transform.rb +291 -0
- data/lib/lutaml/model/transform/xml_transform.rb +239 -0
- data/lib/lutaml/model/transform.rb +78 -0
- data/lib/lutaml/model/type/date.rb +1 -1
- data/lib/lutaml/model/type/date_time.rb +2 -2
- data/lib/lutaml/model/type/hash.rb +1 -1
- data/lib/lutaml/model/type/time.rb +2 -2
- data/lib/lutaml/model/type/time_without_date.rb +2 -2
- data/lib/lutaml/model/type/value.rb +6 -9
- data/lib/lutaml/model/uninitialized_class.rb +64 -0
- data/lib/lutaml/model/utils.rb +44 -0
- data/lib/lutaml/model/validation.rb +1 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model/{xml_adapter → xml}/builder/nokogiri.rb +2 -2
- data/lib/lutaml/model/{xml_adapter → xml}/builder/oga.rb +10 -10
- data/lib/lutaml/model/{xml_adapter → xml}/builder/ox.rb +1 -1
- data/lib/lutaml/model/{xml_adapter/xml_document.rb → xml/document.rb} +41 -21
- data/lib/lutaml/model/xml/element.rb +32 -0
- data/lib/lutaml/model/xml/mapping.rb +410 -0
- data/lib/lutaml/model/xml/mapping_rule.rb +141 -0
- data/lib/lutaml/model/xml/nokogiri_adapter.rb +232 -0
- data/lib/lutaml/model/{xml_adapter → xml}/oga/document.rb +1 -1
- data/lib/lutaml/model/{xml_adapter → xml}/oga/element.rb +3 -1
- data/lib/lutaml/model/xml/oga_adapter.rb +171 -0
- data/lib/lutaml/model/xml/ox_adapter.rb +215 -0
- data/lib/lutaml/model/xml/transform.rb +8 -0
- data/lib/lutaml/model/{xml_adapter → xml}/xml_attribute.rb +1 -1
- data/lib/lutaml/model/{xml_adapter → xml}/xml_element.rb +23 -10
- data/lib/lutaml/model/{xml_adapter → xml}/xml_namespace.rb +1 -1
- data/lib/lutaml/model/xml.rb +31 -0
- data/lib/lutaml/model/xml_adapter/element.rb +11 -25
- data/lib/lutaml/model/xml_adapter/nokogiri_adapter.rb +6 -223
- data/lib/lutaml/model/xml_adapter/oga_adapter.rb +13 -163
- data/lib/lutaml/model/xml_adapter/ox_adapter.rb +10 -207
- data/lib/lutaml/model/yaml/document.rb +10 -0
- data/lib/lutaml/model/yaml/mapping.rb +19 -0
- data/lib/lutaml/model/yaml/mapping_rule.rb +9 -0
- data/lib/lutaml/model/{yaml_adapter/standard_yaml_adapter.rb → yaml/standard_adapter.rb} +4 -3
- data/lib/lutaml/model/yaml/transform.rb +8 -0
- data/lib/lutaml/model/yaml.rb +21 -0
- data/lib/lutaml/model.rb +40 -4
- data/lutaml-model.gemspec +0 -4
- data/spec/benchmarks/xml_parsing_benchmark_spec.rb +7 -7
- data/spec/fixtures/person.rb +5 -5
- data/spec/lutaml/model/attribute_spec.rb +37 -1
- data/spec/lutaml/model/cdata_spec.rb +9 -9
- data/spec/lutaml/model/collection_spec.rb +50 -2
- data/spec/lutaml/model/comparable_model_spec.rb +92 -27
- data/spec/lutaml/model/custom_bibtex_adapter_spec.rb +598 -0
- data/spec/lutaml/model/custom_vobject_adapter_spec.rb +1226 -0
- data/spec/lutaml/model/defaults_spec.rb +1 -1
- data/spec/lutaml/model/enum_spec.rb +1 -1
- data/spec/lutaml/model/group_spec.rb +333 -20
- data/spec/lutaml/model/hash/adapter_spec.rb +255 -0
- data/spec/lutaml/model/json_adapter_spec.rb +6 -6
- data/spec/lutaml/model/key_value_mapping_spec.rb +65 -3
- data/spec/lutaml/model/mixed_content_spec.rb +24 -24
- data/spec/lutaml/model/multiple_mapping_spec.rb +5 -5
- data/spec/lutaml/model/ordered_content_spec.rb +6 -6
- data/spec/lutaml/model/polymorphic_spec.rb +526 -0
- data/spec/lutaml/model/render_empty_spec.rb +194 -0
- data/spec/lutaml/model/render_nil_spec.rb +206 -22
- data/spec/lutaml/model/root_mappings_spec.rb +3 -3
- data/spec/lutaml/model/schema/xml_compiler_spec.rb +6 -6
- data/spec/lutaml/model/serializable_spec.rb +179 -103
- data/spec/lutaml/model/simple_model_spec.rb +9 -9
- data/spec/lutaml/model/toml_adapter_spec.rb +6 -6
- data/spec/lutaml/model/toml_spec.rb +51 -0
- data/spec/lutaml/model/transformation_spec.rb +72 -15
- data/spec/lutaml/model/uninitialized_class_spec.rb +96 -0
- data/spec/lutaml/model/value_map_spec.rb +240 -0
- data/spec/lutaml/model/xml/namespace/nested_with_explicit_namespace_spec.rb +85 -0
- data/spec/lutaml/model/xml/namespace_spec.rb +57 -0
- data/spec/lutaml/model/xml/xml_element_spec.rb +93 -0
- data/spec/lutaml/model/xml_adapter/nokogiri_adapter_spec.rb +2 -2
- data/spec/lutaml/model/xml_adapter/oga_adapter_spec.rb +2 -2
- data/spec/lutaml/model/xml_adapter/ox_adapter_spec.rb +2 -2
- data/spec/lutaml/model/xml_adapter/xml_namespace_spec.rb +6 -6
- data/spec/lutaml/model/xml_adapter_spec.rb +6 -6
- data/spec/lutaml/model/xml_mapping_rule_spec.rb +105 -5
- data/spec/lutaml/model/xml_mapping_spec.rb +70 -16
- data/spec/lutaml/model/xml_spec.rb +63 -0
- data/spec/lutaml/model/yaml_adapter_spec.rb +3 -5
- data/spec/sample_model_spec.rb +3 -3
- data/spec/spec_helper.rb +3 -3
- metadata +76 -59
- data/lib/lutaml/model/json_adapter/json_document.rb +0 -20
- data/lib/lutaml/model/json_adapter/json_object.rb +0 -28
- data/lib/lutaml/model/loggable.rb +0 -15
- data/lib/lutaml/model/mapping_rule.rb +0 -109
- data/lib/lutaml/model/toml_adapter/toml_document.rb +0 -20
- data/lib/lutaml/model/toml_adapter/toml_object.rb +0 -28
- data/lib/lutaml/model/toml_adapter/tomlib_adapter.rb +0 -20
- data/lib/lutaml/model/toml_adapter.rb +0 -6
- data/lib/lutaml/model/xml_mapping.rb +0 -307
- data/lib/lutaml/model/xml_mapping_rule.rb +0 -122
- data/lib/lutaml/model/yaml_adapter/yaml_document.rb +0 -20
- data/lib/lutaml/model/yaml_adapter/yaml_object.rb +0 -28
- data/lib/lutaml/model/yaml_adapter.rb +0 -8
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: base64
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: liquid
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '5'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '5'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: moxml
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +48,7 @@ executables:
|
|
76
48
|
extensions: []
|
77
49
|
extra_rdoc_files: []
|
78
50
|
files:
|
51
|
+
- ".github/workflows/dependent-repos-todo.json"
|
79
52
|
- ".github/workflows/dependent-repos.json"
|
80
53
|
- ".github/workflows/dependent-tests.yml"
|
81
54
|
- ".github/workflows/rake.yml"
|
@@ -88,9 +61,11 @@ files:
|
|
88
61
|
- Gemfile
|
89
62
|
- LICENSE.md
|
90
63
|
- README.adoc
|
64
|
+
- RELEASE_NOTES.adoc
|
91
65
|
- Rakefile
|
92
66
|
- bin/console
|
93
67
|
- bin/setup
|
68
|
+
- docs/custom_adapters.adoc
|
94
69
|
- exe/lutaml-model
|
95
70
|
- lib/lutaml/model.rb
|
96
71
|
- lib/lutaml/model/attribute.rb
|
@@ -116,6 +91,7 @@ files:
|
|
116
91
|
- lib/lutaml/model/error/no_root_mapping_error.rb
|
117
92
|
- lib/lutaml/model/error/no_root_namespace_error.rb
|
118
93
|
- lib/lutaml/model/error/pattern_not_matched_error.rb
|
94
|
+
- lib/lutaml/model/error/polymorphic_error.rb
|
119
95
|
- lib/lutaml/model/error/type/invalid_value_error.rb
|
120
96
|
- lib/lutaml/model/error/type_error.rb
|
121
97
|
- lib/lutaml/model/error/type_not_enabled_error.rb
|
@@ -123,17 +99,28 @@ files:
|
|
123
99
|
- lib/lutaml/model/error/unknown_sequence_mapping_error.rb
|
124
100
|
- lib/lutaml/model/error/unknown_type_error.rb
|
125
101
|
- lib/lutaml/model/error/validation_error.rb
|
102
|
+
- lib/lutaml/model/format_registry.rb
|
103
|
+
- lib/lutaml/model/hash.rb
|
104
|
+
- lib/lutaml/model/hash/document.rb
|
105
|
+
- lib/lutaml/model/hash/mapping.rb
|
106
|
+
- lib/lutaml/model/hash/mapping_rule.rb
|
107
|
+
- lib/lutaml/model/hash/standard_adapter.rb
|
108
|
+
- lib/lutaml/model/hash/transform.rb
|
109
|
+
- lib/lutaml/model/json.rb
|
110
|
+
- lib/lutaml/model/json/document.rb
|
111
|
+
- lib/lutaml/model/json/mapping.rb
|
112
|
+
- lib/lutaml/model/json/mapping_rule.rb
|
113
|
+
- lib/lutaml/model/json/multi_json_adapter.rb
|
114
|
+
- lib/lutaml/model/json/standard_adapter.rb
|
115
|
+
- lib/lutaml/model/json/transform.rb
|
126
116
|
- lib/lutaml/model/json_adapter.rb
|
127
|
-
- lib/lutaml/model/
|
128
|
-
- lib/lutaml/model/json_adapter/json_object.rb
|
129
|
-
- lib/lutaml/model/json_adapter/multi_json_adapter.rb
|
130
|
-
- lib/lutaml/model/json_adapter/standard_json_adapter.rb
|
131
|
-
- lib/lutaml/model/key_value_mapping.rb
|
132
|
-
- lib/lutaml/model/key_value_mapping_rule.rb
|
117
|
+
- lib/lutaml/model/key_value_document.rb
|
133
118
|
- lib/lutaml/model/liquefiable.rb
|
134
|
-
- lib/lutaml/model/
|
119
|
+
- lib/lutaml/model/mapping/key_value_mapping.rb
|
120
|
+
- lib/lutaml/model/mapping/key_value_mapping_rule.rb
|
121
|
+
- lib/lutaml/model/mapping/mapping.rb
|
122
|
+
- lib/lutaml/model/mapping/mapping_rule.rb
|
135
123
|
- lib/lutaml/model/mapping_hash.rb
|
136
|
-
- lib/lutaml/model/mapping_rule.rb
|
137
124
|
- lib/lutaml/model/schema.rb
|
138
125
|
- lib/lutaml/model/schema/json_schema.rb
|
139
126
|
- lib/lutaml/model/schema/json_schema_parser.rb
|
@@ -145,12 +132,21 @@ files:
|
|
145
132
|
- lib/lutaml/model/schema_location.rb
|
146
133
|
- lib/lutaml/model/sequence.rb
|
147
134
|
- lib/lutaml/model/serializable.rb
|
135
|
+
- lib/lutaml/model/serialization_adapter.rb
|
148
136
|
- lib/lutaml/model/serialize.rb
|
149
|
-
- lib/lutaml/model/
|
150
|
-
- lib/lutaml/model/
|
151
|
-
- lib/lutaml/model/
|
152
|
-
- lib/lutaml/model/
|
153
|
-
- lib/lutaml/model/
|
137
|
+
- lib/lutaml/model/services.rb
|
138
|
+
- lib/lutaml/model/services/logger.rb
|
139
|
+
- lib/lutaml/model/services/transformer.rb
|
140
|
+
- lib/lutaml/model/toml.rb
|
141
|
+
- lib/lutaml/model/toml/document.rb
|
142
|
+
- lib/lutaml/model/toml/mapping.rb
|
143
|
+
- lib/lutaml/model/toml/mapping_rule.rb
|
144
|
+
- lib/lutaml/model/toml/toml_rb_adapter.rb
|
145
|
+
- lib/lutaml/model/toml/tomlib_adapter.rb
|
146
|
+
- lib/lutaml/model/toml/transform.rb
|
147
|
+
- lib/lutaml/model/transform.rb
|
148
|
+
- lib/lutaml/model/transform/key_value_transform.rb
|
149
|
+
- lib/lutaml/model/transform/xml_transform.rb
|
154
150
|
- lib/lutaml/model/type.rb
|
155
151
|
- lib/lutaml/model/type/boolean.rb
|
156
152
|
- lib/lutaml/model/type/date.rb
|
@@ -163,29 +159,38 @@ files:
|
|
163
159
|
- lib/lutaml/model/type/time.rb
|
164
160
|
- lib/lutaml/model/type/time_without_date.rb
|
165
161
|
- lib/lutaml/model/type/value.rb
|
162
|
+
- lib/lutaml/model/uninitialized_class.rb
|
166
163
|
- lib/lutaml/model/utils.rb
|
167
164
|
- lib/lutaml/model/validation.rb
|
168
165
|
- lib/lutaml/model/version.rb
|
166
|
+
- lib/lutaml/model/xml.rb
|
167
|
+
- lib/lutaml/model/xml/builder/nokogiri.rb
|
168
|
+
- lib/lutaml/model/xml/builder/oga.rb
|
169
|
+
- lib/lutaml/model/xml/builder/ox.rb
|
170
|
+
- lib/lutaml/model/xml/document.rb
|
171
|
+
- lib/lutaml/model/xml/element.rb
|
172
|
+
- lib/lutaml/model/xml/mapping.rb
|
173
|
+
- lib/lutaml/model/xml/mapping_rule.rb
|
174
|
+
- lib/lutaml/model/xml/nokogiri_adapter.rb
|
175
|
+
- lib/lutaml/model/xml/oga/document.rb
|
176
|
+
- lib/lutaml/model/xml/oga/element.rb
|
177
|
+
- lib/lutaml/model/xml/oga_adapter.rb
|
178
|
+
- lib/lutaml/model/xml/ox_adapter.rb
|
179
|
+
- lib/lutaml/model/xml/transform.rb
|
180
|
+
- lib/lutaml/model/xml/xml_attribute.rb
|
181
|
+
- lib/lutaml/model/xml/xml_element.rb
|
182
|
+
- lib/lutaml/model/xml/xml_namespace.rb
|
169
183
|
- lib/lutaml/model/xml_adapter.rb
|
170
|
-
- lib/lutaml/model/xml_adapter/builder/nokogiri.rb
|
171
|
-
- lib/lutaml/model/xml_adapter/builder/oga.rb
|
172
|
-
- lib/lutaml/model/xml_adapter/builder/ox.rb
|
173
184
|
- lib/lutaml/model/xml_adapter/element.rb
|
174
185
|
- lib/lutaml/model/xml_adapter/nokogiri_adapter.rb
|
175
|
-
- lib/lutaml/model/xml_adapter/oga/document.rb
|
176
|
-
- lib/lutaml/model/xml_adapter/oga/element.rb
|
177
186
|
- lib/lutaml/model/xml_adapter/oga_adapter.rb
|
178
187
|
- lib/lutaml/model/xml_adapter/ox_adapter.rb
|
179
|
-
- lib/lutaml/model/
|
180
|
-
- lib/lutaml/model/
|
181
|
-
- lib/lutaml/model/
|
182
|
-
- lib/lutaml/model/
|
183
|
-
- lib/lutaml/model/
|
184
|
-
- lib/lutaml/model/
|
185
|
-
- lib/lutaml/model/yaml_adapter.rb
|
186
|
-
- lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb
|
187
|
-
- lib/lutaml/model/yaml_adapter/yaml_document.rb
|
188
|
-
- lib/lutaml/model/yaml_adapter/yaml_object.rb
|
188
|
+
- lib/lutaml/model/yaml.rb
|
189
|
+
- lib/lutaml/model/yaml/document.rb
|
190
|
+
- lib/lutaml/model/yaml/mapping.rb
|
191
|
+
- lib/lutaml/model/yaml/mapping_rule.rb
|
192
|
+
- lib/lutaml/model/yaml/standard_adapter.rb
|
193
|
+
- lib/lutaml/model/yaml/transform.rb
|
189
194
|
- lutaml-model.gemspec
|
190
195
|
- sig/lutaml/model.rbs
|
191
196
|
- spec/address_spec.rb
|
@@ -213,12 +218,15 @@ files:
|
|
213
218
|
- spec/lutaml/model/choice_spec.rb
|
214
219
|
- spec/lutaml/model/collection_spec.rb
|
215
220
|
- spec/lutaml/model/comparable_model_spec.rb
|
221
|
+
- spec/lutaml/model/custom_bibtex_adapter_spec.rb
|
216
222
|
- spec/lutaml/model/custom_model_spec.rb
|
217
223
|
- spec/lutaml/model/custom_serialization_spec.rb
|
224
|
+
- spec/lutaml/model/custom_vobject_adapter_spec.rb
|
218
225
|
- spec/lutaml/model/defaults_spec.rb
|
219
226
|
- spec/lutaml/model/delegation_spec.rb
|
220
227
|
- spec/lutaml/model/enum_spec.rb
|
221
228
|
- spec/lutaml/model/group_spec.rb
|
229
|
+
- spec/lutaml/model/hash/adapter_spec.rb
|
222
230
|
- spec/lutaml/model/included_spec.rb
|
223
231
|
- spec/lutaml/model/inheritance_spec.rb
|
224
232
|
- spec/lutaml/model/json_adapter_spec.rb
|
@@ -230,6 +238,8 @@ files:
|
|
230
238
|
- spec/lutaml/model/multiple_mapping_spec.rb
|
231
239
|
- spec/lutaml/model/namespace_spec.rb
|
232
240
|
- spec/lutaml/model/ordered_content_spec.rb
|
241
|
+
- spec/lutaml/model/polymorphic_spec.rb
|
242
|
+
- spec/lutaml/model/render_empty_spec.rb
|
233
243
|
- spec/lutaml/model/render_nil_spec.rb
|
234
244
|
- spec/lutaml/model/root_mappings_spec.rb
|
235
245
|
- spec/lutaml/model/schema/json_schema_spec.rb
|
@@ -242,6 +252,7 @@ files:
|
|
242
252
|
- spec/lutaml/model/serializable_validation_spec.rb
|
243
253
|
- spec/lutaml/model/simple_model_spec.rb
|
244
254
|
- spec/lutaml/model/toml_adapter_spec.rb
|
255
|
+
- spec/lutaml/model/toml_spec.rb
|
245
256
|
- spec/lutaml/model/transformation_spec.rb
|
246
257
|
- spec/lutaml/model/type/boolean_spec.rb
|
247
258
|
- spec/lutaml/model/type/date_spec.rb
|
@@ -254,10 +265,15 @@ files:
|
|
254
265
|
- spec/lutaml/model/type/time_spec.rb
|
255
266
|
- spec/lutaml/model/type/time_without_date_spec.rb
|
256
267
|
- spec/lutaml/model/type_spec.rb
|
268
|
+
- spec/lutaml/model/uninitialized_class_spec.rb
|
257
269
|
- spec/lutaml/model/utils_spec.rb
|
258
270
|
- spec/lutaml/model/validation_spec.rb
|
271
|
+
- spec/lutaml/model/value_map_spec.rb
|
259
272
|
- spec/lutaml/model/with_child_mapping_spec.rb
|
260
273
|
- spec/lutaml/model/xml/derived_attributes_spec.rb
|
274
|
+
- spec/lutaml/model/xml/namespace/nested_with_explicit_namespace_spec.rb
|
275
|
+
- spec/lutaml/model/xml/namespace_spec.rb
|
276
|
+
- spec/lutaml/model/xml/xml_element_spec.rb
|
261
277
|
- spec/lutaml/model/xml_adapter/nokogiri_adapter_spec.rb
|
262
278
|
- spec/lutaml/model/xml_adapter/oga_adapter_spec.rb
|
263
279
|
- spec/lutaml/model/xml_adapter/ox_adapter_spec.rb
|
@@ -265,6 +281,7 @@ files:
|
|
265
281
|
- spec/lutaml/model/xml_adapter_spec.rb
|
266
282
|
- spec/lutaml/model/xml_mapping_rule_spec.rb
|
267
283
|
- spec/lutaml/model/xml_mapping_spec.rb
|
284
|
+
- spec/lutaml/model/xml_spec.rb
|
268
285
|
- spec/lutaml/model/yaml_adapter_spec.rb
|
269
286
|
- spec/lutaml/model_spec.rb
|
270
287
|
- spec/person_spec.rb
|
@@ -290,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
307
|
- !ruby/object:Gem::Version
|
291
308
|
version: '0'
|
292
309
|
requirements: []
|
293
|
-
rubygems_version: 3.
|
310
|
+
rubygems_version: 3.5.22
|
294
311
|
signing_key:
|
295
312
|
specification_version: 4
|
296
313
|
summary: LutaML creating data models in Ruby
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "json_object"
|
4
|
-
|
5
|
-
module Lutaml
|
6
|
-
module Model
|
7
|
-
module JsonAdapter
|
8
|
-
# Base class for JSON documents
|
9
|
-
class JsonDocument < JsonObject
|
10
|
-
def self.parse(json, _options = {})
|
11
|
-
raise NotImplementedError, "Subclasses must implement `parse`."
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_json(*args)
|
15
|
-
raise NotImplementedError, "Subclasses must implement `to_json`."
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Lutaml
|
4
|
-
module Model
|
5
|
-
module JsonAdapter
|
6
|
-
# Base class for JSON objects
|
7
|
-
class JsonObject
|
8
|
-
attr_reader :attributes
|
9
|
-
|
10
|
-
def initialize(attributes = {})
|
11
|
-
@attributes = attributes
|
12
|
-
end
|
13
|
-
|
14
|
-
def [](key)
|
15
|
-
@attributes[key]
|
16
|
-
end
|
17
|
-
|
18
|
-
def []=(key, value)
|
19
|
-
@attributes[key] = value
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_h
|
23
|
-
@attributes
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Lutaml
|
2
|
-
module Model
|
3
|
-
module Loggable
|
4
|
-
def self.included(base)
|
5
|
-
base.define_method :warn_auto_handling do |name|
|
6
|
-
caller_file = File.basename(caller_locations(2, 1)[0].path)
|
7
|
-
caller_line = caller_locations(2, 1)[0].lineno
|
8
|
-
|
9
|
-
str = "[Lutaml::Model] WARN: `#{name}` is handled by default. No need to explecitly define at `#{caller_file}:#{caller_line}`"
|
10
|
-
warn(str)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
module Lutaml
|
2
|
-
module Model
|
3
|
-
class MappingRule
|
4
|
-
attr_reader :name,
|
5
|
-
:to,
|
6
|
-
:render_nil,
|
7
|
-
:render_default,
|
8
|
-
:attribute,
|
9
|
-
:custom_methods,
|
10
|
-
:delegate,
|
11
|
-
:transform
|
12
|
-
|
13
|
-
def initialize(
|
14
|
-
name,
|
15
|
-
to:,
|
16
|
-
render_nil: false,
|
17
|
-
render_default: false,
|
18
|
-
with: {},
|
19
|
-
attribute: false,
|
20
|
-
delegate: nil,
|
21
|
-
root_mappings: nil,
|
22
|
-
transform: {}
|
23
|
-
)
|
24
|
-
@name = name
|
25
|
-
@to = to
|
26
|
-
@render_nil = render_nil
|
27
|
-
@render_default = render_default
|
28
|
-
@custom_methods = with
|
29
|
-
@attribute = attribute
|
30
|
-
@delegate = delegate
|
31
|
-
@root_mappings = root_mappings
|
32
|
-
@transform = transform
|
33
|
-
end
|
34
|
-
|
35
|
-
alias from name
|
36
|
-
alias render_nil? render_nil
|
37
|
-
alias render_default? render_default
|
38
|
-
alias attribute? attribute
|
39
|
-
|
40
|
-
def render?(value)
|
41
|
-
render_nil? || (!value.nil? && !Utils.empty_collection?(value))
|
42
|
-
end
|
43
|
-
|
44
|
-
def serialize_attribute(model, element, doc)
|
45
|
-
if custom_methods[:to]
|
46
|
-
model.send(custom_methods[:to], model, element, doc)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def to_value_for(model)
|
51
|
-
if delegate
|
52
|
-
model.public_send(delegate).public_send(to)
|
53
|
-
else
|
54
|
-
return if to.nil?
|
55
|
-
|
56
|
-
model.public_send(to)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def serialize(model, parent = nil, doc = nil)
|
61
|
-
if custom_methods[:to]
|
62
|
-
model.send(custom_methods[:to], model, parent, doc)
|
63
|
-
else
|
64
|
-
to_value_for(model)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def deserialize(model, value, attributes, mapper_class = nil)
|
69
|
-
if custom_methods[:from]
|
70
|
-
mapper_class.new.send(custom_methods[:from], model, value) unless value.nil?
|
71
|
-
elsif delegate
|
72
|
-
if model.public_send(delegate).nil?
|
73
|
-
model.public_send(:"#{delegate}=", attributes[delegate].type.new)
|
74
|
-
end
|
75
|
-
|
76
|
-
model.public_send(delegate).public_send(:"#{to}=", value)
|
77
|
-
elsif transform_method = transform[:import] || attributes[to].transform_import_method
|
78
|
-
model.public_send(:"#{to}=", transform_method.call(value))
|
79
|
-
else
|
80
|
-
model.public_send(:"#{to}=", value)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def using_custom_methods?
|
85
|
-
!custom_methods.empty?
|
86
|
-
end
|
87
|
-
|
88
|
-
def multiple_mappings?
|
89
|
-
name.is_a?(Array)
|
90
|
-
end
|
91
|
-
|
92
|
-
def raw_mapping?
|
93
|
-
name == Constants::RAW_MAPPING_KEY
|
94
|
-
end
|
95
|
-
|
96
|
-
def eql?(other)
|
97
|
-
other.class == self.class &&
|
98
|
-
instance_variables.all? do |var|
|
99
|
-
instance_variable_get(var) == other.instance_variable_get(var)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
alias == eql?
|
103
|
-
|
104
|
-
def deep_dup
|
105
|
-
raise NotImplementedError, "Subclasses must implement `deep_dup`."
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "toml_object"
|
4
|
-
|
5
|
-
module Lutaml
|
6
|
-
module Model
|
7
|
-
module TomlAdapter
|
8
|
-
# Base class for TOML documents
|
9
|
-
class TomlDocument < TomlObject
|
10
|
-
def self.parse(toml, _options = {})
|
11
|
-
raise NotImplementedError, "Subclasses must implement `parse`."
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_toml(*args)
|
15
|
-
raise NotImplementedError, "Subclasses must implement `to_toml`."
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Lutaml
|
4
|
-
module Model
|
5
|
-
module TomlAdapter
|
6
|
-
# Base class for TOML objects
|
7
|
-
class TomlObject
|
8
|
-
attr_reader :attributes
|
9
|
-
|
10
|
-
def initialize(attributes = {})
|
11
|
-
@attributes = attributes
|
12
|
-
end
|
13
|
-
|
14
|
-
def [](key)
|
15
|
-
@attributes[key]
|
16
|
-
end
|
17
|
-
|
18
|
-
def []=(key, value)
|
19
|
-
@attributes[key] = value
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_h
|
23
|
-
@attributes
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require "tomlib"
|
2
|
-
require_relative "toml_document"
|
3
|
-
|
4
|
-
module Lutaml
|
5
|
-
module Model
|
6
|
-
module TomlAdapter
|
7
|
-
class TomlibAdapter < TomlDocument
|
8
|
-
def self.parse(toml, _options = {})
|
9
|
-
data = Tomlib.load(toml)
|
10
|
-
new(data)
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_toml(*args)
|
14
|
-
Tomlib.dump(to_h, *args)
|
15
|
-
# Tomlib::Generator.new(to_h).toml_str
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|