lutaml-model 0.7.3 → 0.7.5
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/.envrc +1 -0
- data/.github/workflows/release.yml +3 -0
- data/.gitignore +6 -1
- data/.irbrc +1 -0
- data/.pryrc +1 -0
- data/.rubocop_todo.yml +25 -52
- data/README.adoc +2177 -192
- data/docs/custom_registers.adoc +228 -0
- data/docs/schema_generation.adoc +898 -0
- data/docs/schema_import.adoc +364 -0
- data/flake.lock +114 -0
- data/flake.nix +103 -0
- data/lib/lutaml/model/attribute.rb +230 -94
- data/lib/lutaml/model/choice.rb +30 -0
- data/lib/lutaml/model/collection.rb +194 -0
- data/lib/lutaml/model/comparable_model.rb +3 -3
- data/lib/lutaml/model/config.rb +26 -3
- data/lib/lutaml/model/constants.rb +2 -0
- data/lib/lutaml/model/error/element_count_out_of_range_error.rb +29 -0
- data/lib/lutaml/model/error/invalid_attribute_name_error.rb +15 -0
- data/lib/lutaml/model/error/invalid_attribute_options_error.rb +16 -0
- data/lib/lutaml/model/error/invalid_choice_range_error.rb +3 -5
- data/lib/lutaml/model/error/register/not_registrable_class_error.rb +11 -0
- data/lib/lutaml/model/error/type/invalid_value_error.rb +5 -3
- data/lib/lutaml/model/error/type/max_bound_error.rb +20 -0
- data/lib/lutaml/model/error/type/max_length_error.rb +20 -0
- data/lib/lutaml/model/error/type/min_bound_error.rb +20 -0
- data/lib/lutaml/model/error/type/min_length_error.rb +20 -0
- data/lib/lutaml/model/error/type/pattern_not_matched_error.rb +18 -0
- data/lib/lutaml/model/error/validation_failed_error.rb +9 -0
- data/lib/lutaml/model/error.rb +10 -0
- data/lib/lutaml/model/errors.rb +36 -0
- data/lib/lutaml/model/format_registry.rb +5 -2
- data/lib/lutaml/model/global_register.rb +41 -0
- data/lib/lutaml/model/{hash.rb → hash_adapter.rb} +5 -5
- data/lib/lutaml/model/jsonl/document.rb +14 -0
- data/lib/lutaml/model/jsonl/mapping.rb +19 -0
- data/lib/lutaml/model/jsonl/mapping_rule.rb +9 -0
- data/lib/lutaml/model/jsonl/standard_adapter.rb +33 -0
- data/lib/lutaml/model/jsonl/transform.rb +19 -0
- data/lib/lutaml/model/jsonl.rb +21 -0
- data/lib/lutaml/model/key_value_document.rb +3 -2
- data/lib/lutaml/model/mapping/key_value_mapping.rb +64 -4
- data/lib/lutaml/model/mapping/key_value_mapping_rule.rb +4 -0
- data/lib/lutaml/model/mapping/mapping_rule.rb +8 -3
- data/lib/lutaml/model/register.rb +105 -0
- data/lib/lutaml/model/registrable.rb +6 -0
- data/lib/lutaml/model/schema/base_schema.rb +64 -0
- data/lib/lutaml/model/schema/decorators/attribute.rb +114 -0
- data/lib/lutaml/model/schema/decorators/choices.rb +31 -0
- data/lib/lutaml/model/schema/decorators/class_definition.rb +85 -0
- data/lib/lutaml/model/schema/decorators/definition_collection.rb +97 -0
- data/lib/lutaml/model/schema/generator/definition.rb +53 -0
- data/lib/lutaml/model/schema/generator/definitions_collection.rb +81 -0
- data/lib/lutaml/model/schema/generator/properties_collection.rb +63 -0
- data/lib/lutaml/model/schema/generator/property.rb +110 -0
- data/lib/lutaml/model/schema/generator/ref.rb +24 -0
- data/lib/lutaml/model/schema/helpers/template_helper.rb +49 -0
- data/lib/lutaml/model/schema/json_schema.rb +42 -49
- data/lib/lutaml/model/schema/relaxng_schema.rb +14 -10
- data/lib/lutaml/model/schema/renderer.rb +36 -0
- data/lib/lutaml/model/schema/shared_methods.rb +24 -0
- data/lib/lutaml/model/schema/templates/model.erb +9 -0
- data/lib/lutaml/model/schema/xml_compiler/attribute.rb +85 -0
- data/lib/lutaml/model/schema/xml_compiler/attribute_group.rb +45 -0
- data/lib/lutaml/model/schema/xml_compiler/choice.rb +65 -0
- data/lib/lutaml/model/schema/xml_compiler/complex_content.rb +27 -0
- data/lib/lutaml/model/schema/xml_compiler/complex_content_restriction.rb +34 -0
- data/lib/lutaml/model/schema/xml_compiler/complex_type.rb +136 -0
- data/lib/lutaml/model/schema/xml_compiler/element.rb +104 -0
- data/lib/lutaml/model/schema/xml_compiler/group.rb +97 -0
- data/lib/lutaml/model/schema/xml_compiler/restriction.rb +101 -0
- data/lib/lutaml/model/schema/xml_compiler/sequence.rb +50 -0
- data/lib/lutaml/model/schema/xml_compiler/simple_content.rb +36 -0
- data/lib/lutaml/model/schema/xml_compiler/simple_type.rb +189 -0
- data/lib/lutaml/model/schema/xml_compiler.rb +231 -587
- data/lib/lutaml/model/schema/xsd_schema.rb +12 -8
- data/lib/lutaml/model/schema/yaml_schema.rb +41 -35
- data/lib/lutaml/model/schema.rb +1 -0
- data/lib/lutaml/model/sequence.rb +60 -30
- data/lib/lutaml/model/serialize.rb +175 -53
- data/lib/lutaml/model/services/base.rb +11 -0
- data/lib/lutaml/model/services/logger.rb +2 -2
- data/lib/lutaml/model/services/rule_value_extractor.rb +92 -0
- data/lib/lutaml/model/services/type/validator/number.rb +25 -0
- data/lib/lutaml/model/services/type/validator/string.rb +52 -0
- data/lib/lutaml/model/services/type/validator.rb +43 -0
- data/lib/lutaml/model/services/validator.rb +145 -0
- data/lib/lutaml/model/services.rb +3 -0
- data/lib/lutaml/model/transform/key_value_transform.rb +60 -50
- data/lib/lutaml/model/transform/xml_transform.rb +46 -57
- data/lib/lutaml/model/transform.rb +22 -8
- data/lib/lutaml/model/type/boolean.rb +1 -1
- data/lib/lutaml/model/type/date.rb +1 -1
- data/lib/lutaml/model/type/date_time.rb +1 -1
- data/lib/lutaml/model/type/decimal.rb +11 -9
- data/lib/lutaml/model/type/float.rb +2 -1
- data/lib/lutaml/model/type/integer.rb +24 -21
- data/lib/lutaml/model/type/string.rb +4 -2
- data/lib/lutaml/model/type/time.rb +1 -1
- data/lib/lutaml/model/type/time_without_date.rb +1 -1
- data/lib/lutaml/model/type/value.rb +5 -1
- data/lib/lutaml/model/type.rb +5 -2
- data/lib/lutaml/model/utils.rb +30 -8
- data/lib/lutaml/model/validation.rb +6 -4
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model/xml/document.rb +37 -19
- data/lib/lutaml/model/xml/mapping.rb +74 -13
- data/lib/lutaml/model/xml/mapping_rule.rb +10 -2
- data/lib/lutaml/model/xml/nokogiri_adapter.rb +5 -3
- data/lib/lutaml/model/xml/oga/element.rb +4 -1
- data/lib/lutaml/model/xml/oga_adapter.rb +4 -3
- data/lib/lutaml/model/xml/ox_adapter.rb +20 -6
- data/lib/lutaml/model/xml/xml_element.rb +3 -28
- data/lib/lutaml/model/xml_adapter/element.rb +1 -1
- data/lib/lutaml/model/xml_adapter/nokogiri_adapter.rb +1 -1
- data/lib/lutaml/model/xml_adapter/oga_adapter.rb +1 -1
- data/lib/lutaml/model/xml_adapter/ox_adapter.rb +1 -1
- data/lib/lutaml/model/yamls/document.rb +14 -0
- data/lib/lutaml/model/yamls/mapping.rb +19 -0
- data/lib/lutaml/model/yamls/mapping_rule.rb +9 -0
- data/lib/lutaml/model/yamls/standard_adapter.rb +34 -0
- data/lib/lutaml/model/yamls/transform.rb +19 -0
- data/lib/lutaml/model/yamls.rb +21 -0
- data/lib/lutaml/model.rb +7 -31
- data/spec/benchmarks/xml_parsing_benchmark_spec.rb +4 -5
- data/spec/fixtures/xml/advanced_test_schema.xsd +134 -0
- data/spec/fixtures/xml/examples/nested_categories.xml +55 -0
- data/spec/fixtures/xml/examples/valid_catalog.xml +43 -0
- data/spec/fixtures/xml/product_catalog.xsd +151 -0
- data/spec/fixtures/xml/specifications_schema.xsd +38 -0
- data/spec/lutaml/model/attribute_collection_spec.rb +101 -0
- data/spec/lutaml/model/attribute_spec.rb +41 -44
- data/spec/lutaml/model/choice_spec.rb +44 -0
- data/spec/lutaml/model/custom_collection_spec.rb +830 -0
- data/spec/lutaml/model/custom_model_spec.rb +15 -3
- data/spec/lutaml/model/defaults_spec.rb +5 -1
- data/spec/lutaml/model/global_register_spec.rb +108 -0
- data/spec/lutaml/model/group_spec.rb +9 -3
- data/spec/lutaml/model/jsonl/standard_adapter_spec.rb +91 -0
- data/spec/lutaml/model/jsonl_spec.rb +229 -0
- data/spec/lutaml/model/multiple_mapping_spec.rb +1 -1
- data/spec/lutaml/model/register/key_value_spec.rb +275 -0
- data/spec/lutaml/model/register/xml_spec.rb +187 -0
- data/spec/lutaml/model/register_spec.rb +147 -0
- data/spec/lutaml/model/rule_value_extractor_spec.rb +162 -0
- data/spec/lutaml/model/schema/generator/definitions_collection_spec.rb +120 -0
- data/spec/lutaml/model/schema/json_schema_spec.rb +412 -51
- data/spec/lutaml/model/schema/json_schema_to_models_spec.rb +383 -0
- data/spec/lutaml/model/schema/xml_compiler/attribute_group_spec.rb +65 -0
- data/spec/lutaml/model/schema/xml_compiler/attribute_spec.rb +63 -0
- data/spec/lutaml/model/schema/xml_compiler/choice_spec.rb +71 -0
- data/spec/lutaml/model/schema/xml_compiler/complex_content_restriction_spec.rb +55 -0
- data/spec/lutaml/model/schema/xml_compiler/complex_content_spec.rb +37 -0
- data/spec/lutaml/model/schema/xml_compiler/complex_type_spec.rb +173 -0
- data/spec/lutaml/model/schema/xml_compiler/element_spec.rb +63 -0
- data/spec/lutaml/model/schema/xml_compiler/group_spec.rb +86 -0
- data/spec/lutaml/model/schema/xml_compiler/restriction_spec.rb +76 -0
- data/spec/lutaml/model/schema/xml_compiler/sequence_spec.rb +59 -0
- data/spec/lutaml/model/schema/xml_compiler/simple_content_spec.rb +55 -0
- data/spec/lutaml/model/schema/xml_compiler/simple_type_spec.rb +181 -0
- data/spec/lutaml/model/schema/xml_compiler_spec.rb +503 -1804
- data/spec/lutaml/model/schema/yaml_schema_spec.rb +249 -26
- data/spec/lutaml/model/sequence_spec.rb +36 -0
- data/spec/lutaml/model/serializable_spec.rb +31 -0
- data/spec/lutaml/model/type_spec.rb +8 -4
- data/spec/lutaml/model/utils_spec.rb +3 -3
- data/spec/lutaml/model/xml/derived_attributes_spec.rb +1 -1
- data/spec/lutaml/model/xml/xml_element_spec.rb +7 -1
- data/spec/lutaml/model/xml_adapter/xml_namespace_spec.rb +6 -6
- data/spec/lutaml/model/xml_adapter_spec.rb +24 -0
- data/spec/lutaml/model/xml_mapping_rule_spec.rb +11 -4
- data/spec/lutaml/model/xml_mapping_spec.rb +1 -1
- data/spec/lutaml/model/yamls/standard_adapter_spec.rb +183 -0
- data/spec/lutaml/model/yamls_spec.rb +294 -0
- data/spec/spec_helper.rb +1 -0
- metadata +105 -9
- data/lib/lutaml/model/schema/templates/simple_type.rb +0 -247
- /data/lib/lutaml/model/{hash → hash_adapter}/document.rb +0 -0
- /data/lib/lutaml/model/{hash → hash_adapter}/mapping.rb +0 -0
- /data/lib/lutaml/model/{hash → hash_adapter}/mapping_rule.rb +0 -0
- /data/lib/lutaml/model/{hash → hash_adapter}/standard_adapter.rb +0 -0
- /data/lib/lutaml/model/{hash → hash_adapter}/transform.rb +0 -0
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.7.
|
4
|
+
version: 0.7.5
|
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-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: moxml
|
@@ -48,12 +48,15 @@ executables:
|
|
48
48
|
extensions: []
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
|
+
- ".envrc"
|
51
52
|
- ".github/workflows/dependent-repos-todo.json"
|
52
53
|
- ".github/workflows/dependent-repos.json"
|
53
54
|
- ".github/workflows/dependent-tests.yml"
|
54
55
|
- ".github/workflows/rake.yml"
|
55
56
|
- ".github/workflows/release.yml"
|
56
57
|
- ".gitignore"
|
58
|
+
- ".irbrc"
|
59
|
+
- ".pryrc"
|
57
60
|
- ".rspec"
|
58
61
|
- ".rubocop.yml"
|
59
62
|
- ".rubocop_todo.yml"
|
@@ -66,11 +69,17 @@ files:
|
|
66
69
|
- bin/console
|
67
70
|
- bin/setup
|
68
71
|
- docs/custom_adapters.adoc
|
72
|
+
- docs/custom_registers.adoc
|
73
|
+
- docs/schema_generation.adoc
|
74
|
+
- docs/schema_import.adoc
|
69
75
|
- exe/lutaml-model
|
76
|
+
- flake.lock
|
77
|
+
- flake.nix
|
70
78
|
- lib/lutaml/model.rb
|
71
79
|
- lib/lutaml/model/attribute.rb
|
72
80
|
- lib/lutaml/model/choice.rb
|
73
81
|
- lib/lutaml/model/cli.rb
|
82
|
+
- lib/lutaml/model/collection.rb
|
74
83
|
- lib/lutaml/model/comparable_model.rb
|
75
84
|
- lib/lutaml/model/comparable_nil.rb
|
76
85
|
- lib/lutaml/model/comparison.rb
|
@@ -81,9 +90,12 @@ files:
|
|
81
90
|
- lib/lutaml/model/error/choice_upper_bound_error.rb
|
82
91
|
- lib/lutaml/model/error/collection_count_out_of_range_error.rb
|
83
92
|
- lib/lutaml/model/error/collection_true_missing_error.rb
|
93
|
+
- lib/lutaml/model/error/element_count_out_of_range_error.rb
|
84
94
|
- lib/lutaml/model/error/import_model_with_root_error.rb
|
85
95
|
- lib/lutaml/model/error/incorrect_mapping_argument_error.rb
|
86
96
|
- lib/lutaml/model/error/incorrect_sequence_error.rb
|
97
|
+
- lib/lutaml/model/error/invalid_attribute_name_error.rb
|
98
|
+
- lib/lutaml/model/error/invalid_attribute_options_error.rb
|
87
99
|
- lib/lutaml/model/error/invalid_choice_range_error.rb
|
88
100
|
- lib/lutaml/model/error/invalid_value_error.rb
|
89
101
|
- lib/lutaml/model/error/liquid_not_enabled_error.rb
|
@@ -92,20 +104,29 @@ files:
|
|
92
104
|
- lib/lutaml/model/error/no_root_namespace_error.rb
|
93
105
|
- lib/lutaml/model/error/pattern_not_matched_error.rb
|
94
106
|
- lib/lutaml/model/error/polymorphic_error.rb
|
107
|
+
- lib/lutaml/model/error/register/not_registrable_class_error.rb
|
95
108
|
- lib/lutaml/model/error/type/invalid_value_error.rb
|
109
|
+
- lib/lutaml/model/error/type/max_bound_error.rb
|
110
|
+
- lib/lutaml/model/error/type/max_length_error.rb
|
111
|
+
- lib/lutaml/model/error/type/min_bound_error.rb
|
112
|
+
- lib/lutaml/model/error/type/min_length_error.rb
|
113
|
+
- lib/lutaml/model/error/type/pattern_not_matched_error.rb
|
96
114
|
- lib/lutaml/model/error/type_error.rb
|
97
115
|
- lib/lutaml/model/error/type_not_enabled_error.rb
|
98
116
|
- lib/lutaml/model/error/unknown_adapter_type_error.rb
|
99
117
|
- lib/lutaml/model/error/unknown_sequence_mapping_error.rb
|
100
118
|
- lib/lutaml/model/error/unknown_type_error.rb
|
101
119
|
- lib/lutaml/model/error/validation_error.rb
|
120
|
+
- lib/lutaml/model/error/validation_failed_error.rb
|
121
|
+
- lib/lutaml/model/errors.rb
|
102
122
|
- lib/lutaml/model/format_registry.rb
|
103
|
-
- lib/lutaml/model/
|
104
|
-
- lib/lutaml/model/
|
105
|
-
- lib/lutaml/model/
|
106
|
-
- lib/lutaml/model/
|
107
|
-
- lib/lutaml/model/
|
108
|
-
- lib/lutaml/model/
|
123
|
+
- lib/lutaml/model/global_register.rb
|
124
|
+
- lib/lutaml/model/hash_adapter.rb
|
125
|
+
- lib/lutaml/model/hash_adapter/document.rb
|
126
|
+
- lib/lutaml/model/hash_adapter/mapping.rb
|
127
|
+
- lib/lutaml/model/hash_adapter/mapping_rule.rb
|
128
|
+
- lib/lutaml/model/hash_adapter/standard_adapter.rb
|
129
|
+
- lib/lutaml/model/hash_adapter/transform.rb
|
109
130
|
- lib/lutaml/model/json.rb
|
110
131
|
- lib/lutaml/model/json/document.rb
|
111
132
|
- lib/lutaml/model/json/mapping.rb
|
@@ -114,6 +135,12 @@ files:
|
|
114
135
|
- lib/lutaml/model/json/standard_adapter.rb
|
115
136
|
- lib/lutaml/model/json/transform.rb
|
116
137
|
- lib/lutaml/model/json_adapter.rb
|
138
|
+
- lib/lutaml/model/jsonl.rb
|
139
|
+
- lib/lutaml/model/jsonl/document.rb
|
140
|
+
- lib/lutaml/model/jsonl/mapping.rb
|
141
|
+
- lib/lutaml/model/jsonl/mapping_rule.rb
|
142
|
+
- lib/lutaml/model/jsonl/standard_adapter.rb
|
143
|
+
- lib/lutaml/model/jsonl/transform.rb
|
117
144
|
- lib/lutaml/model/key_value_document.rb
|
118
145
|
- lib/lutaml/model/liquefiable.rb
|
119
146
|
- lib/lutaml/model/mapping/key_value_mapping.rb
|
@@ -121,12 +148,39 @@ files:
|
|
121
148
|
- lib/lutaml/model/mapping/mapping.rb
|
122
149
|
- lib/lutaml/model/mapping/mapping_rule.rb
|
123
150
|
- lib/lutaml/model/mapping_hash.rb
|
151
|
+
- lib/lutaml/model/register.rb
|
152
|
+
- lib/lutaml/model/registrable.rb
|
124
153
|
- lib/lutaml/model/schema.rb
|
154
|
+
- lib/lutaml/model/schema/base_schema.rb
|
155
|
+
- lib/lutaml/model/schema/decorators/attribute.rb
|
156
|
+
- lib/lutaml/model/schema/decorators/choices.rb
|
157
|
+
- lib/lutaml/model/schema/decorators/class_definition.rb
|
158
|
+
- lib/lutaml/model/schema/decorators/definition_collection.rb
|
159
|
+
- lib/lutaml/model/schema/generator/definition.rb
|
160
|
+
- lib/lutaml/model/schema/generator/definitions_collection.rb
|
161
|
+
- lib/lutaml/model/schema/generator/properties_collection.rb
|
162
|
+
- lib/lutaml/model/schema/generator/property.rb
|
163
|
+
- lib/lutaml/model/schema/generator/ref.rb
|
164
|
+
- lib/lutaml/model/schema/helpers/template_helper.rb
|
125
165
|
- lib/lutaml/model/schema/json_schema.rb
|
126
166
|
- lib/lutaml/model/schema/json_schema_parser.rb
|
127
167
|
- lib/lutaml/model/schema/relaxng_schema.rb
|
128
|
-
- lib/lutaml/model/schema/
|
168
|
+
- lib/lutaml/model/schema/renderer.rb
|
169
|
+
- lib/lutaml/model/schema/shared_methods.rb
|
170
|
+
- lib/lutaml/model/schema/templates/model.erb
|
129
171
|
- lib/lutaml/model/schema/xml_compiler.rb
|
172
|
+
- lib/lutaml/model/schema/xml_compiler/attribute.rb
|
173
|
+
- lib/lutaml/model/schema/xml_compiler/attribute_group.rb
|
174
|
+
- lib/lutaml/model/schema/xml_compiler/choice.rb
|
175
|
+
- lib/lutaml/model/schema/xml_compiler/complex_content.rb
|
176
|
+
- lib/lutaml/model/schema/xml_compiler/complex_content_restriction.rb
|
177
|
+
- lib/lutaml/model/schema/xml_compiler/complex_type.rb
|
178
|
+
- lib/lutaml/model/schema/xml_compiler/element.rb
|
179
|
+
- lib/lutaml/model/schema/xml_compiler/group.rb
|
180
|
+
- lib/lutaml/model/schema/xml_compiler/restriction.rb
|
181
|
+
- lib/lutaml/model/schema/xml_compiler/sequence.rb
|
182
|
+
- lib/lutaml/model/schema/xml_compiler/simple_content.rb
|
183
|
+
- lib/lutaml/model/schema/xml_compiler/simple_type.rb
|
130
184
|
- lib/lutaml/model/schema/xsd_schema.rb
|
131
185
|
- lib/lutaml/model/schema/yaml_schema.rb
|
132
186
|
- lib/lutaml/model/schema_location.rb
|
@@ -135,8 +189,14 @@ files:
|
|
135
189
|
- lib/lutaml/model/serialization_adapter.rb
|
136
190
|
- lib/lutaml/model/serialize.rb
|
137
191
|
- lib/lutaml/model/services.rb
|
192
|
+
- lib/lutaml/model/services/base.rb
|
138
193
|
- lib/lutaml/model/services/logger.rb
|
194
|
+
- lib/lutaml/model/services/rule_value_extractor.rb
|
139
195
|
- lib/lutaml/model/services/transformer.rb
|
196
|
+
- lib/lutaml/model/services/type/validator.rb
|
197
|
+
- lib/lutaml/model/services/type/validator/number.rb
|
198
|
+
- lib/lutaml/model/services/type/validator/string.rb
|
199
|
+
- lib/lutaml/model/services/validator.rb
|
140
200
|
- lib/lutaml/model/toml.rb
|
141
201
|
- lib/lutaml/model/toml/document.rb
|
142
202
|
- lib/lutaml/model/toml/mapping.rb
|
@@ -191,6 +251,12 @@ files:
|
|
191
251
|
- lib/lutaml/model/yaml/mapping_rule.rb
|
192
252
|
- lib/lutaml/model/yaml/standard_adapter.rb
|
193
253
|
- lib/lutaml/model/yaml/transform.rb
|
254
|
+
- lib/lutaml/model/yamls.rb
|
255
|
+
- lib/lutaml/model/yamls/document.rb
|
256
|
+
- lib/lutaml/model/yamls/mapping.rb
|
257
|
+
- lib/lutaml/model/yamls/mapping_rule.rb
|
258
|
+
- lib/lutaml/model/yamls/standard_adapter.rb
|
259
|
+
- lib/lutaml/model/yamls/transform.rb
|
194
260
|
- lutaml-model.gemspec
|
195
261
|
- sig/lutaml/model.rbs
|
196
262
|
- spec/address_spec.rb
|
@@ -205,31 +271,41 @@ files:
|
|
205
271
|
- spec/fixtures/sample_model.rb
|
206
272
|
- spec/fixtures/vase.rb
|
207
273
|
- spec/fixtures/xml/address_example_260.xsd
|
274
|
+
- spec/fixtures/xml/advanced_test_schema.xsd
|
275
|
+
- spec/fixtures/xml/examples/nested_categories.xml
|
276
|
+
- spec/fixtures/xml/examples/valid_catalog.xml
|
208
277
|
- spec/fixtures/xml/invalid_math_document.xml
|
209
278
|
- spec/fixtures/xml/latin_encoding.xml
|
210
279
|
- spec/fixtures/xml/math_document_schema.xsd
|
280
|
+
- spec/fixtures/xml/product_catalog.xsd
|
211
281
|
- spec/fixtures/xml/shift_jis.xml
|
212
282
|
- spec/fixtures/xml/special_char.xml
|
283
|
+
- spec/fixtures/xml/specifications_schema.xsd
|
213
284
|
- spec/fixtures/xml/test_schema.xsd
|
214
285
|
- spec/fixtures/xml/user.xsd
|
215
286
|
- spec/fixtures/xml/valid_math_document.xml
|
287
|
+
- spec/lutaml/model/attribute_collection_spec.rb
|
216
288
|
- spec/lutaml/model/attribute_spec.rb
|
217
289
|
- spec/lutaml/model/cdata_spec.rb
|
218
290
|
- spec/lutaml/model/choice_spec.rb
|
219
291
|
- spec/lutaml/model/collection_spec.rb
|
220
292
|
- spec/lutaml/model/comparable_model_spec.rb
|
221
293
|
- spec/lutaml/model/custom_bibtex_adapter_spec.rb
|
294
|
+
- spec/lutaml/model/custom_collection_spec.rb
|
222
295
|
- spec/lutaml/model/custom_model_spec.rb
|
223
296
|
- spec/lutaml/model/custom_serialization_spec.rb
|
224
297
|
- spec/lutaml/model/custom_vobject_adapter_spec.rb
|
225
298
|
- spec/lutaml/model/defaults_spec.rb
|
226
299
|
- spec/lutaml/model/delegation_spec.rb
|
227
300
|
- spec/lutaml/model/enum_spec.rb
|
301
|
+
- spec/lutaml/model/global_register_spec.rb
|
228
302
|
- spec/lutaml/model/group_spec.rb
|
229
303
|
- spec/lutaml/model/hash/adapter_spec.rb
|
230
304
|
- spec/lutaml/model/included_spec.rb
|
231
305
|
- spec/lutaml/model/inheritance_spec.rb
|
232
306
|
- spec/lutaml/model/json_adapter_spec.rb
|
307
|
+
- spec/lutaml/model/jsonl/standard_adapter_spec.rb
|
308
|
+
- spec/lutaml/model/jsonl_spec.rb
|
233
309
|
- spec/lutaml/model/key_value_mapping_spec.rb
|
234
310
|
- spec/lutaml/model/liquefiable_spec.rb
|
235
311
|
- spec/lutaml/model/map_all_spec.rb
|
@@ -239,11 +315,29 @@ files:
|
|
239
315
|
- spec/lutaml/model/namespace_spec.rb
|
240
316
|
- spec/lutaml/model/ordered_content_spec.rb
|
241
317
|
- spec/lutaml/model/polymorphic_spec.rb
|
318
|
+
- spec/lutaml/model/register/key_value_spec.rb
|
319
|
+
- spec/lutaml/model/register/xml_spec.rb
|
320
|
+
- spec/lutaml/model/register_spec.rb
|
242
321
|
- spec/lutaml/model/render_empty_spec.rb
|
243
322
|
- spec/lutaml/model/render_nil_spec.rb
|
244
323
|
- spec/lutaml/model/root_mappings_spec.rb
|
324
|
+
- spec/lutaml/model/rule_value_extractor_spec.rb
|
325
|
+
- spec/lutaml/model/schema/generator/definitions_collection_spec.rb
|
245
326
|
- spec/lutaml/model/schema/json_schema_spec.rb
|
327
|
+
- spec/lutaml/model/schema/json_schema_to_models_spec.rb
|
246
328
|
- spec/lutaml/model/schema/relaxng_schema_spec.rb
|
329
|
+
- spec/lutaml/model/schema/xml_compiler/attribute_group_spec.rb
|
330
|
+
- spec/lutaml/model/schema/xml_compiler/attribute_spec.rb
|
331
|
+
- spec/lutaml/model/schema/xml_compiler/choice_spec.rb
|
332
|
+
- spec/lutaml/model/schema/xml_compiler/complex_content_restriction_spec.rb
|
333
|
+
- spec/lutaml/model/schema/xml_compiler/complex_content_spec.rb
|
334
|
+
- spec/lutaml/model/schema/xml_compiler/complex_type_spec.rb
|
335
|
+
- spec/lutaml/model/schema/xml_compiler/element_spec.rb
|
336
|
+
- spec/lutaml/model/schema/xml_compiler/group_spec.rb
|
337
|
+
- spec/lutaml/model/schema/xml_compiler/restriction_spec.rb
|
338
|
+
- spec/lutaml/model/schema/xml_compiler/sequence_spec.rb
|
339
|
+
- spec/lutaml/model/schema/xml_compiler/simple_content_spec.rb
|
340
|
+
- spec/lutaml/model/schema/xml_compiler/simple_type_spec.rb
|
247
341
|
- spec/lutaml/model/schema/xml_compiler_spec.rb
|
248
342
|
- spec/lutaml/model/schema/xsd_schema_spec.rb
|
249
343
|
- spec/lutaml/model/schema/yaml_schema_spec.rb
|
@@ -283,6 +377,8 @@ files:
|
|
283
377
|
- spec/lutaml/model/xml_mapping_spec.rb
|
284
378
|
- spec/lutaml/model/xml_spec.rb
|
285
379
|
- spec/lutaml/model/yaml_adapter_spec.rb
|
380
|
+
- spec/lutaml/model/yamls/standard_adapter_spec.rb
|
381
|
+
- spec/lutaml/model/yamls_spec.rb
|
286
382
|
- spec/lutaml/model_spec.rb
|
287
383
|
- spec/person_spec.rb
|
288
384
|
- spec/sample_model_spec.rb
|
@@ -1,247 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Lutaml
|
4
|
-
module Model
|
5
|
-
module Schema
|
6
|
-
module Templates
|
7
|
-
module SimpleType
|
8
|
-
extend self
|
9
|
-
attr_accessor :simple_types
|
10
|
-
|
11
|
-
DEFAULT_CLASSES = %w[int integer string boolean].freeze
|
12
|
-
|
13
|
-
SUPPORTED_DATA_TYPES = {
|
14
|
-
nonNegativeInteger: { class_name: "Lutaml::Model::Type::String", validations: { pattern: /\+?[0-9]+/ } },
|
15
|
-
positiveInteger: { class_name: "Lutaml::Model::Type::Integer", validations: { min: 0 } },
|
16
|
-
base64Binary: { class_name: "Lutaml::Model::Type::String", validations: { pattern: /\A([A-Za-z0-9+\/]+={0,2}|\s)*\z/ } },
|
17
|
-
unsignedLong: { class_name: "Lutaml::Model::Type::Integer", validations: { min: 0, max: 18446744073709551615 } },
|
18
|
-
unsignedInt: { class_name: "Lutaml::Model::Type::Integer", validations: { min: 0, max: 4294967295 } },
|
19
|
-
hexBinary: { class_name: "Lutaml::Model::Type::String", validations: { pattern: /([0-9a-fA-F]{2})*/ } },
|
20
|
-
dateTime: { skippable: true, class_name: "Lutaml::Model::Type::DateTime" },
|
21
|
-
boolean: { skippable: true, class_name: "Lutaml::Model::Type::Boolean" },
|
22
|
-
integer: { skippable: true, class_name: "Lutaml::Model::Type::Integer" },
|
23
|
-
string: { skippable: true, class_name: "Lutaml::Model::Type::String" },
|
24
|
-
token: { class_name: "Lutaml::Model::Type::String", validations: { pattern: /\A[^\t\n\f\r ]+(?: [^\t\n\f\r ]+)*\z/ } },
|
25
|
-
long: { class_name: "Lutaml::Model::Type::Decimal" },
|
26
|
-
int: { skippable: true, class_name: "Lutaml::Model::Type::Integer" },
|
27
|
-
}.freeze
|
28
|
-
|
29
|
-
REF_TEMPLATE = ERB.new(<<~TEMPLATE, trim_mode: "-")
|
30
|
-
# frozen_string_literal: true
|
31
|
-
|
32
|
-
require "lutaml/model"
|
33
|
-
<%= "require_relative \#{Utils.snake_case(parent_class).inspect}\n" if require_parent -%>
|
34
|
-
|
35
|
-
class <%= klass_name %> < <%= parent_class %>; end
|
36
|
-
TEMPLATE
|
37
|
-
|
38
|
-
SUPPORTED_TYPES_TEMPLATE = ERB.new(<<~TEMPLATE, trim_mode: "-")
|
39
|
-
# frozen_string_literal: true
|
40
|
-
|
41
|
-
require "lutaml/model"
|
42
|
-
|
43
|
-
class <%= Utils.camel_case(klass_name.to_s) %> < <%= properties[:class_name].to_s %>
|
44
|
-
def self.cast(value)
|
45
|
-
return nil if value.nil?
|
46
|
-
|
47
|
-
value = super(value)
|
48
|
-
<%=
|
49
|
-
if pattern_exist = validations.key?(:pattern)
|
50
|
-
" pattern = %r{\#{validations[:pattern]}}\n\#{indent}raise Lutaml::Model::Type::InvalidValueError, \\"The value \\\#{value} does not match the required pattern: \\\#{pattern}\\" unless value.match?(pattern)\n"
|
51
|
-
end
|
52
|
-
-%>
|
53
|
-
<%=
|
54
|
-
if min_exist = validations.key?(:min)
|
55
|
-
" min = \#{validations[:min]}\n\#{indent}raise Lutaml::Model::Type::InvalidValueError, \\"The value \\\#{value} is less than the set limit: \\\#{min}\\" if value < min\n"
|
56
|
-
end
|
57
|
-
-%>
|
58
|
-
<%=
|
59
|
-
if max_exist = validations.key?(:max)
|
60
|
-
" max = \#{validations[:max]}\n\#{indent}raise Lutaml::Model::Type::InvalidValueError, \\"The value \\\#{value} is greater than the set limit: \\\#{max}\\" if value > max\n"
|
61
|
-
end
|
62
|
-
-%>
|
63
|
-
value
|
64
|
-
end
|
65
|
-
end
|
66
|
-
TEMPLATE
|
67
|
-
|
68
|
-
UNION_TEMPLATE = ERB.new(<<~TEMPLATE, trim_mode: "-")
|
69
|
-
# frozen_string_literal: true
|
70
|
-
|
71
|
-
require "lutaml/model"
|
72
|
-
<%=
|
73
|
-
resolve_required_files(unions)&.map do |file|
|
74
|
-
next if file.nil? || file.empty?
|
75
|
-
|
76
|
-
"require_relative \\\"\#{file}\\\""
|
77
|
-
end.compact.join("\n") + "\n"
|
78
|
-
-%>
|
79
|
-
|
80
|
-
class <%= klass_name %> < Lutaml::Model::Type::Value
|
81
|
-
def self.cast(value)
|
82
|
-
return nil if value.nil?
|
83
|
-
|
84
|
-
<%= unions.map do |union|
|
85
|
-
base_class = union.base_class.split(':').last
|
86
|
-
if DEFAULT_CLASSES.include?(base_class)
|
87
|
-
"\#{SUPPORTED_DATA_TYPES.dig(base_class.to_sym, :class_name)}.cast(value)"
|
88
|
-
else
|
89
|
-
"\#{Utils.camel_case(base_class)}.cast(value)"
|
90
|
-
end
|
91
|
-
end.join(" || ") %>
|
92
|
-
end
|
93
|
-
end
|
94
|
-
TEMPLATE
|
95
|
-
|
96
|
-
MODEL_TEMPLATE = ERB.new(<<~TEMPLATE, trim_mode: "-")
|
97
|
-
# frozen_string_literal: true
|
98
|
-
require "lutaml/model"
|
99
|
-
<%= "require_relative '\#{Utils.snake_case(parent_class)}'\n" if require_parent -%>
|
100
|
-
|
101
|
-
class <%= klass_name %> < <%= parent_class %>
|
102
|
-
<%= " VALUES = \#{values}.freeze\n\n" if values_exist = values&.any? -%>
|
103
|
-
<%= " LENGTHS = \#{properties[:length]&.map(&:value)}\n\n" if length_exist = properties&.key?(:length) -%>
|
104
|
-
def self.cast(value)
|
105
|
-
return nil if value.nil?
|
106
|
-
|
107
|
-
value = super(value)
|
108
|
-
<%= " raise_values_error(value) unless VALUES.include?(value)\n" if values_exist -%>
|
109
|
-
<%= " raise_length_error(value) unless LENGTHS.all?(value.length)\n" if length_exist -%>
|
110
|
-
<%=
|
111
|
-
if pattern_exist = properties.key?(:pattern)
|
112
|
-
" pattern = %r{\#{properties[:pattern]}}\n raise_pattern_error(value, pattern) unless value.match?(pattern)\n"
|
113
|
-
end
|
114
|
-
-%>
|
115
|
-
<%=
|
116
|
-
if min_length_exist = properties&.key_exist?(:min_length)
|
117
|
-
" min_length = \#{properties.min_length}\n raise_min_length_error(value, min_length) unless value.length >= min_length\n"
|
118
|
-
end
|
119
|
-
-%>
|
120
|
-
<%=
|
121
|
-
if max_length_exist = properties&.key_exist?(:max_length)
|
122
|
-
" max_length = \#{properties.max_length}\n raise_max_length_error(value, max_length) unless value.length <= max_length\n"
|
123
|
-
end
|
124
|
-
-%>
|
125
|
-
<%=
|
126
|
-
if min_bound_exist = (properties&.key_exist?(:min_inclusive) || properties&.key_exist?(:min_exclusive))
|
127
|
-
" min_bound = \#{properties[:min_inclusive] || properties[:min_exclusive]}\n raise_min_bound_error(value, min_bound) unless value >\#{'=' if properties.key?(:min_inclusive)} min_bound \n"
|
128
|
-
end
|
129
|
-
-%>
|
130
|
-
<%=
|
131
|
-
if max_bound_exist = (properties&.key_exist?(:max_inclusive) || properties&.key_exist?(:max_exclusive))
|
132
|
-
" max_bound = \#{properties[:max_inclusive] || properties[:max_exclusive]}\n raise_max_bound_error(value, max_bound) unless value <\#{'=' if properties.key?(:max_inclusive)} max_bound \n"
|
133
|
-
end
|
134
|
-
-%>
|
135
|
-
<%= "value" %>
|
136
|
-
end
|
137
|
-
<%= "\n private\n" if pattern_exist || values_exist || length_exist || min_length_exist || max_length_exist || min_bound_exist || max_bound_exist -%>
|
138
|
-
<%=
|
139
|
-
if pattern_exist
|
140
|
-
"\n def self.raise_pattern_error(value, pattern)\n raise Lutaml::Model::Type::InvalidValueError, \\"The value \\\#{value} does not match the required pattern: \\\#{pattern}\\"\n end\n"
|
141
|
-
end
|
142
|
-
-%>
|
143
|
-
<%=
|
144
|
-
if values_exist
|
145
|
-
"\n def self.raise_values_error(input_value)\n raise Lutaml::Model::InvalidValueError.new(self, input_value, VALUES)\n end\n"
|
146
|
-
end
|
147
|
-
-%>
|
148
|
-
<%=
|
149
|
-
if length_exist
|
150
|
-
"\n def self.raise_length_error(input_value)\n raise Lutaml::Model::Type::InvalidValueError, \\"The provided value \\\\\\"\\\#{input_value}\\\\\\" should match the specified lengths: \\\#{LENGTHS.join(',')}\\"\n end\n"
|
151
|
-
end
|
152
|
-
-%>
|
153
|
-
<%=
|
154
|
-
if min_length_exist
|
155
|
-
"\n def self.raise_min_length_error(input_value, min_length)\n raise Lutaml::Model::Type::InvalidValueError, \\"The provided value \\\\\\"\\\#{input_value}\\\\\\" has fewer characters than the minimum allowed \\\#{min_length}\\"\n end\n"
|
156
|
-
end
|
157
|
-
-%>
|
158
|
-
<%=
|
159
|
-
if max_length_exist
|
160
|
-
"\n def self.raise_max_length_error(input_value, max_length)\n raise Lutaml::Model::Type::InvalidValueError, \\"The provided value \\\\\\"\\\#{input_value}\\\\\\" exceeds the maximum allowed length of \\\#{max_length}\\"\n end\n"
|
161
|
-
end
|
162
|
-
-%>
|
163
|
-
<%=
|
164
|
-
if min_bound_exist
|
165
|
-
"\n def self.raise_min_bound_error(input_value, min_bound)\n raise Lutaml::Model::Type::InvalidValueError, \\"The provided value \\\\\\"\\\#{input_value}\\\\\\" is less than the minimum allowed value of \\\#{min_bound}\\"\n end\n"
|
166
|
-
end
|
167
|
-
-%>
|
168
|
-
<%=
|
169
|
-
if max_bound_exist
|
170
|
-
"\n def self.raise_max_bound_error(input_value, max_bound)\n raise Lutaml::Model::Type::InvalidValueError, \\"The provided value \\\\\\"\\\#{input_value}\\\\\\" exceeds the maximum allowed value of \\\#{max_bound}\\"\n end\n"
|
171
|
-
end
|
172
|
-
-%>
|
173
|
-
end
|
174
|
-
TEMPLATE
|
175
|
-
|
176
|
-
def create_simple_types(simple_types)
|
177
|
-
setup_supported_types
|
178
|
-
simple_types.each do |name, properties|
|
179
|
-
klass_name = Utils.camel_case(name)
|
180
|
-
@simple_types[name] = if @simple_types.key?(properties[:base_class]) && properties.one?
|
181
|
-
ref_template(properties, klass_name)
|
182
|
-
elsif properties&.key_exist?(:union)
|
183
|
-
union_template(properties, klass_name)
|
184
|
-
else
|
185
|
-
model_template(properties, klass_name)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
@simple_types
|
189
|
-
end
|
190
|
-
|
191
|
-
private
|
192
|
-
|
193
|
-
# klass_name is used in template using `binding`
|
194
|
-
def model_template(properties, klass_name)
|
195
|
-
base_class = properties.base_class.split(":")&.last
|
196
|
-
parent_class, require_parent = extract_parent_class(base_class)
|
197
|
-
values = properties[:values] if properties.key_exist?(:values)
|
198
|
-
MODEL_TEMPLATE.result(binding)
|
199
|
-
end
|
200
|
-
|
201
|
-
def extract_parent_class(base_class)
|
202
|
-
klass = if SUPPORTED_DATA_TYPES[base_class.to_sym]&.key?(:class_name)
|
203
|
-
parent = false
|
204
|
-
SUPPORTED_DATA_TYPES.dig(base_class.to_sym, :class_name)
|
205
|
-
else
|
206
|
-
parent = true
|
207
|
-
Utils.camel_case(base_class.to_s)
|
208
|
-
end
|
209
|
-
[klass, parent]
|
210
|
-
end
|
211
|
-
|
212
|
-
# klass_name is used in template using `binding`
|
213
|
-
def union_template(properties, klass_name)
|
214
|
-
unions = properties.union
|
215
|
-
UNION_TEMPLATE.result(binding)
|
216
|
-
end
|
217
|
-
|
218
|
-
# klass_name is used in template using `binding`
|
219
|
-
def ref_template(properties, klass_name)
|
220
|
-
parent_class = properties.base_class
|
221
|
-
require_parent = true unless properties[:base_class].include?("Lutaml::Model::")
|
222
|
-
REF_TEMPLATE.result(binding)
|
223
|
-
end
|
224
|
-
|
225
|
-
def setup_supported_types
|
226
|
-
@simple_types = MappingHash.new
|
227
|
-
indent = " "
|
228
|
-
SUPPORTED_DATA_TYPES.each do |klass_name, properties|
|
229
|
-
validations = properties[:validations] || {}
|
230
|
-
next if properties[:skippable]
|
231
|
-
|
232
|
-
@simple_types[klass_name] = SUPPORTED_TYPES_TEMPLATE.result(binding)
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
def resolve_required_files(unions)
|
237
|
-
unions.map do |union|
|
238
|
-
next if DEFAULT_CLASSES.include?(union.base_class.split(":").last)
|
239
|
-
|
240
|
-
Utils.snake_case(union.base_class.split(":").last)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|