lutaml-model 0.5.3 → 0.6.0

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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-tests.yml +2 -0
  3. data/.rubocop_todo.yml +86 -23
  4. data/Gemfile +2 -0
  5. data/README.adoc +1441 -220
  6. data/lib/lutaml/model/attribute.rb +33 -10
  7. data/lib/lutaml/model/choice.rb +56 -0
  8. data/lib/lutaml/model/config.rb +1 -0
  9. data/lib/lutaml/model/constants.rb +7 -0
  10. data/lib/lutaml/model/error/choice_lower_bound_error.rb +9 -0
  11. data/lib/lutaml/model/error/choice_upper_bound_error.rb +9 -0
  12. data/lib/lutaml/model/error/import_model_with_root_error.rb +9 -0
  13. data/lib/lutaml/model/error/incorrect_sequence_error.rb +9 -0
  14. data/lib/lutaml/model/error/invalid_choice_range_error.rb +20 -0
  15. data/lib/lutaml/model/error/no_root_mapping_error.rb +9 -0
  16. data/lib/lutaml/model/error/no_root_namespace_error.rb +9 -0
  17. data/lib/lutaml/model/error/type/invalid_value_error.rb +19 -0
  18. data/lib/lutaml/model/error/unknown_sequence_mapping_error.rb +9 -0
  19. data/lib/lutaml/model/error.rb +9 -0
  20. data/lib/lutaml/model/json_adapter/standard_json_adapter.rb +6 -1
  21. data/lib/lutaml/model/key_value_mapping.rb +34 -3
  22. data/lib/lutaml/model/key_value_mapping_rule.rb +4 -2
  23. data/lib/lutaml/model/liquefiable.rb +59 -0
  24. data/lib/lutaml/model/mapping_hash.rb +9 -1
  25. data/lib/lutaml/model/mapping_rule.rb +19 -2
  26. data/lib/lutaml/model/schema/templates/simple_type.rb +247 -0
  27. data/lib/lutaml/model/schema/xml_compiler.rb +762 -0
  28. data/lib/lutaml/model/schema.rb +5 -0
  29. data/lib/lutaml/model/schema_location.rb +7 -0
  30. data/lib/lutaml/model/sequence.rb +71 -0
  31. data/lib/lutaml/model/serialize.rb +139 -33
  32. data/lib/lutaml/model/toml_adapter/toml_rb_adapter.rb +1 -2
  33. data/lib/lutaml/model/type/decimal.rb +0 -4
  34. data/lib/lutaml/model/type/hash.rb +11 -11
  35. data/lib/lutaml/model/type/time.rb +3 -3
  36. data/lib/lutaml/model/utils.rb +19 -15
  37. data/lib/lutaml/model/validation.rb +12 -1
  38. data/lib/lutaml/model/version.rb +1 -1
  39. data/lib/lutaml/model/xml_adapter/builder/oga.rb +10 -7
  40. data/lib/lutaml/model/xml_adapter/builder/ox.rb +20 -13
  41. data/lib/lutaml/model/xml_adapter/element.rb +32 -0
  42. data/lib/lutaml/model/xml_adapter/nokogiri_adapter.rb +13 -9
  43. data/lib/lutaml/model/xml_adapter/oga/element.rb +14 -13
  44. data/lib/lutaml/model/xml_adapter/oga_adapter.rb +86 -19
  45. data/lib/lutaml/model/xml_adapter/ox_adapter.rb +19 -15
  46. data/lib/lutaml/model/xml_adapter/xml_document.rb +82 -25
  47. data/lib/lutaml/model/xml_adapter/xml_element.rb +57 -3
  48. data/lib/lutaml/model/xml_mapping.rb +53 -9
  49. data/lib/lutaml/model/xml_mapping_rule.rb +8 -6
  50. data/lib/lutaml/model.rb +2 -0
  51. data/lutaml-model.gemspec +5 -0
  52. data/spec/benchmarks/xml_parsing_benchmark_spec.rb +75 -0
  53. data/spec/ceramic_spec.rb +39 -0
  54. data/spec/fixtures/ceramic.rb +23 -0
  55. data/spec/fixtures/xml/address_example_260.xsd +9 -0
  56. data/spec/fixtures/xml/invalid_math_document.xml +4 -0
  57. data/spec/fixtures/xml/math_document_schema.xsd +56 -0
  58. data/spec/fixtures/xml/test_schema.xsd +53 -0
  59. data/spec/fixtures/xml/user.xsd +10 -0
  60. data/spec/fixtures/xml/valid_math_document.xml +4 -0
  61. data/spec/lutaml/model/cdata_spec.rb +4 -5
  62. data/spec/lutaml/model/choice_spec.rb +168 -0
  63. data/spec/lutaml/model/collection_spec.rb +1 -1
  64. data/spec/lutaml/model/custom_model_spec.rb +7 -21
  65. data/spec/lutaml/model/custom_serialization_spec.rb +74 -2
  66. data/spec/lutaml/model/defaults_spec.rb +3 -1
  67. data/spec/lutaml/model/delegation_spec.rb +7 -5
  68. data/spec/lutaml/model/enum_spec.rb +35 -0
  69. data/spec/lutaml/model/group_spec.rb +160 -0
  70. data/spec/lutaml/model/inheritance_spec.rb +25 -0
  71. data/spec/lutaml/model/key_value_mapping_spec.rb +27 -0
  72. data/spec/lutaml/model/liquefiable_spec.rb +121 -0
  73. data/spec/lutaml/model/map_all_spec.rb +188 -0
  74. data/spec/lutaml/model/mixed_content_spec.rb +95 -56
  75. data/spec/lutaml/model/multiple_mapping_spec.rb +22 -10
  76. data/spec/lutaml/model/schema/xml_compiler_spec.rb +1624 -0
  77. data/spec/lutaml/model/sequence_spec.rb +216 -0
  78. data/spec/lutaml/model/transformation_spec.rb +230 -0
  79. data/spec/lutaml/model/type_spec.rb +138 -31
  80. data/spec/lutaml/model/utils_spec.rb +32 -0
  81. data/spec/lutaml/model/with_child_mapping_spec.rb +2 -2
  82. data/spec/lutaml/model/xml_adapter/oga_adapter_spec.rb +11 -7
  83. data/spec/lutaml/model/xml_adapter/xml_namespace_spec.rb +52 -0
  84. data/spec/lutaml/model/xml_mapping_rule_spec.rb +51 -0
  85. data/spec/lutaml/model/xml_mapping_spec.rb +250 -112
  86. metadata +77 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75da66a7985ef5c93b6c5f93a660046026a158b85a422cf924ce7a641f57d488
4
- data.tar.gz: 5b3cbb99bd8c4398dec561c3885c2d996dd0491a0ba44d074549cc09c55cb59b
3
+ metadata.gz: 9883cb9431e9cd0c40c6e30891e1fb84861f1b9e9e7eb31a1cb5c6ec0d6121dc
4
+ data.tar.gz: 2d00bb121ca7486d151f4daaacb86f98824ef5950460dc4caecffe4280c93607
5
5
  SHA512:
6
- metadata.gz: '04728da10c80f08e47645646f4f06bbc796b074f8f1941594574f1d69fee96c32882b3db69d02b2f7878822b84423a46c81bb8a5ebb118d5b9c97533c0553e46'
7
- data.tar.gz: 06cc0fcbb12ea5fc260eb25b3ecf3c5fc204738df760c5e33468b285007a4c0f0bd955e00ce1c128267c11f97d943f9a1f24b55c3a799ff3d730d0453c602bd8
6
+ metadata.gz: df269be2c13bb4586e13d99dc79b47dbe1b445d49b8f23adf9c7ef502dae58deb77dd714431d29991c56e9aa9ac422a03910648e6f9a81414c7f375541fa6bf4
7
+ data.tar.gz: ed384722ad8f1fdb81671c8318ae0190c7372780a910ffece79e50658103344bd9f293afce048afa728cc91e47d952f6812bdbf2bce7a18d652d6704f9ef69cd
@@ -12,3 +12,5 @@ on:
12
12
  jobs:
13
13
  rake:
14
14
  uses: metanorma/ci/.github/workflows/dependent-rake.yml@main
15
+ with:
16
+ command: bundle exec rspec
data/.rubocop_todo.yml CHANGED
@@ -1,44 +1,70 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-01-07 10:19:56 UTC using RuboCop version 1.69.2.
3
+ # on 2025-02-08 01:06:17 UTC using RuboCop version 1.71.2.
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: 292
9
+ # Offense count: 2
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ Layout/ElseAlignment:
12
+ Exclude:
13
+ - 'lib/lutaml/model/schema/xml_compiler.rb'
14
+
15
+ # Offense count: 2
16
+ # This cop supports safe autocorrection (--autocorrect).
17
+ # Configuration parameters: EnforcedStyleAlignWith, Severity.
18
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
19
+ Layout/EndAlignment:
20
+ Exclude:
21
+ - 'lib/lutaml/model/schema/xml_compiler.rb'
22
+
23
+ # Offense count: 2
24
+ # This cop supports safe autocorrection (--autocorrect).
25
+ # Configuration parameters: Width, AllowedPatterns.
26
+ Layout/IndentationWidth:
27
+ Exclude:
28
+ - 'lib/lutaml/model/schema/xml_compiler.rb'
29
+
30
+ # Offense count: 596
10
31
  # This cop supports safe autocorrection (--autocorrect).
11
32
  # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
12
33
  # URISchemes: http, https
13
34
  Layout/LineLength:
14
35
  Enabled: false
15
36
 
16
- # Offense count: 16
37
+ # Offense count: 19
17
38
  # Configuration parameters: AllowedMethods.
18
39
  # AllowedMethods: enums
19
40
  Lint/ConstantDefinitionInBlock:
20
41
  Exclude:
42
+ - 'spec/benchmarks/xml_parsing_benchmark_spec.rb'
21
43
  - 'spec/lutaml/model/schema/json_schema_spec.rb'
22
44
  - 'spec/lutaml/model/schema/relaxng_schema_spec.rb'
23
45
  - 'spec/lutaml/model/schema/xsd_schema_spec.rb'
24
46
  - 'spec/lutaml/model/schema/yaml_schema_spec.rb'
25
- - 'spec/lutaml/model/type_spec.rb'
47
+ - 'spec/lutaml/model/transformation_spec.rb'
26
48
  - 'spec/lutaml/model/validation_spec.rb'
27
49
  - 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
28
50
 
29
- # Offense count: 1
51
+ # Offense count: 4
30
52
  Lint/DuplicateMethods:
31
53
  Exclude:
32
54
  - 'lib/lutaml/model/type/float.rb'
55
+ - 'lib/lutaml/model/xml_adapter/xml_document.rb'
56
+ - 'lib/lutaml/model/xml_adapter/xml_element.rb'
33
57
 
34
- # Offense count: 40
58
+ # Offense count: 56
35
59
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
36
60
  Metrics/AbcSize:
37
61
  Exclude:
38
62
  - 'lib/lutaml/model/attribute.rb'
39
63
  - 'lib/lutaml/model/comparable_model.rb'
64
+ - 'lib/lutaml/model/key_value_mapping.rb'
40
65
  - 'lib/lutaml/model/mapping_rule.rb'
41
66
  - 'lib/lutaml/model/schema/relaxng_schema.rb'
67
+ - 'lib/lutaml/model/schema/xml_compiler.rb'
42
68
  - 'lib/lutaml/model/schema/xsd_schema.rb'
43
69
  - 'lib/lutaml/model/serialize.rb'
44
70
  - 'lib/lutaml/model/xml_adapter/nokogiri_adapter.rb'
@@ -49,18 +75,21 @@ Metrics/AbcSize:
49
75
  - 'lib/lutaml/model/xml_mapping.rb'
50
76
  - 'lib/lutaml/model/xml_mapping_rule.rb'
51
77
 
52
- # Offense count: 9
78
+ # Offense count: 12
53
79
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
54
80
  # AllowedMethods: refine
55
81
  Metrics/BlockLength:
56
82
  Max: 46
57
83
 
58
- # Offense count: 32
84
+ # Offense count: 48
59
85
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
60
86
  Metrics/CyclomaticComplexity:
61
87
  Exclude:
62
88
  - 'lib/lutaml/model/attribute.rb'
63
89
  - 'lib/lutaml/model/comparable_model.rb'
90
+ - 'lib/lutaml/model/key_value_mapping.rb'
91
+ - 'lib/lutaml/model/mapping_rule.rb'
92
+ - 'lib/lutaml/model/schema/xml_compiler.rb'
64
93
  - 'lib/lutaml/model/serialize.rb'
65
94
  - 'lib/lutaml/model/type/integer.rb'
66
95
  - 'lib/lutaml/model/xml_adapter/builder/oga.rb'
@@ -69,26 +98,28 @@ Metrics/CyclomaticComplexity:
69
98
  - 'lib/lutaml/model/xml_adapter/ox_adapter.rb'
70
99
  - 'lib/lutaml/model/xml_adapter/xml_document.rb'
71
100
 
72
- # Offense count: 63
101
+ # Offense count: 87
73
102
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
74
103
  Metrics/MethodLength:
75
- Max: 45
104
+ Max: 46
76
105
 
77
- # Offense count: 7
106
+ # Offense count: 8
78
107
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
79
108
  Metrics/ParameterLists:
80
109
  Max: 15
81
110
 
82
- # Offense count: 30
111
+ # Offense count: 37
83
112
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
84
113
  Metrics/PerceivedComplexity:
85
114
  Exclude:
86
115
  - 'lib/lutaml/model/attribute.rb'
87
116
  - 'lib/lutaml/model/comparable_model.rb'
117
+ - 'lib/lutaml/model/key_value_mapping.rb'
118
+ - 'lib/lutaml/model/mapping_rule.rb'
119
+ - 'lib/lutaml/model/schema/xml_compiler.rb'
88
120
  - 'lib/lutaml/model/serialize.rb'
89
121
  - 'lib/lutaml/model/type/integer.rb'
90
122
  - 'lib/lutaml/model/xml_adapter/builder/oga.rb'
91
- - 'lib/lutaml/model/xml_adapter/builder/ox.rb'
92
123
  - 'lib/lutaml/model/xml_adapter/nokogiri_adapter.rb'
93
124
  - 'lib/lutaml/model/xml_adapter/oga_adapter.rb'
94
125
  - 'lib/lutaml/model/xml_adapter/ox_adapter.rb'
@@ -110,6 +141,18 @@ RSpec/ContextWording:
110
141
  - 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
111
142
  - 'spec/lutaml/model/xml_mapping_spec.rb'
112
143
 
144
+ # Offense count: 2
145
+ # Configuration parameters: IgnoredMetadata.
146
+ RSpec/DescribeClass:
147
+ Exclude:
148
+ - '**/spec/features/**/*'
149
+ - '**/spec/requests/**/*'
150
+ - '**/spec/routing/**/*'
151
+ - '**/spec/system/**/*'
152
+ - '**/spec/views/**/*'
153
+ - 'spec/benchmarks/xml_parsing_benchmark_spec.rb'
154
+ - 'spec/lutaml/model/transformation_spec.rb'
155
+
113
156
  # Offense count: 1
114
157
  # This cop supports unsafe autocorrection (--autocorrect-all).
115
158
  # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
@@ -118,7 +161,7 @@ RSpec/DescribedClass:
118
161
  Exclude:
119
162
  - 'spec/lutaml/model/xml_mapping_spec.rb'
120
163
 
121
- # Offense count: 139
164
+ # Offense count: 169
122
165
  # Configuration parameters: CountAsOne.
123
166
  RSpec/ExampleLength:
124
167
  Max: 54
@@ -129,14 +172,15 @@ RSpec/IndexedLet:
129
172
  Exclude:
130
173
  - 'spec/address_spec.rb'
131
174
 
132
- # Offense count: 24
175
+ # Offense count: 30
133
176
  RSpec/LeakyConstantDeclaration:
134
177
  Exclude:
178
+ - 'spec/benchmarks/xml_parsing_benchmark_spec.rb'
135
179
  - 'spec/lutaml/model/schema/json_schema_spec.rb'
136
180
  - 'spec/lutaml/model/schema/relaxng_schema_spec.rb'
137
181
  - 'spec/lutaml/model/schema/xsd_schema_spec.rb'
138
182
  - 'spec/lutaml/model/schema/yaml_schema_spec.rb'
139
- - 'spec/lutaml/model/type_spec.rb'
183
+ - 'spec/lutaml/model/transformation_spec.rb'
140
184
  - 'spec/lutaml/model/validation_spec.rb'
141
185
  - 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
142
186
 
@@ -148,16 +192,16 @@ RSpec/MultipleDescribes:
148
192
  - 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
149
193
  - 'spec/lutaml/model/xml_adapter_spec.rb'
150
194
 
151
- # Offense count: 172
195
+ # Offense count: 213
152
196
  RSpec/MultipleExpectations:
153
197
  Max: 14
154
198
 
155
- # Offense count: 24
199
+ # Offense count: 30
156
200
  # Configuration parameters: AllowSubject.
157
201
  RSpec/MultipleMemoizedHelpers:
158
202
  Max: 9
159
203
 
160
- # Offense count: 24
204
+ # Offense count: 108
161
205
  # Configuration parameters: AllowedGroups.
162
206
  RSpec/NestedGroups:
163
207
  Max: 4
@@ -176,6 +220,11 @@ RSpec/RemoveConst:
176
220
  Exclude:
177
221
  - 'spec/lutaml/model/type_spec.rb'
178
222
 
223
+ # Offense count: 3
224
+ RSpec/RepeatedExample:
225
+ Exclude:
226
+ - 'spec/lutaml/model/key_value_mapping_spec.rb'
227
+
179
228
  # Offense count: 2
180
229
  RSpec/RepeatedExampleGroupBody:
181
230
  Exclude:
@@ -207,6 +256,14 @@ Security/CompoundHash:
207
256
  Exclude:
208
257
  - 'lib/lutaml/model/comparable_model.rb'
209
258
 
259
+ # Offense count: 1
260
+ # This cop supports unsafe autocorrection (--autocorrect-all).
261
+ # Configuration parameters: AllowedReceivers.
262
+ # AllowedReceivers: Thread.current
263
+ Style/HashEachMethods:
264
+ Exclude:
265
+ - 'lib/lutaml/model/schema/xml_compiler.rb'
266
+
210
267
  # Offense count: 1
211
268
  Style/MissingRespondToMissing:
212
269
  Exclude:
@@ -219,9 +276,15 @@ Style/OptionalBooleanParameter:
219
276
  Exclude:
220
277
  - 'lib/lutaml/model/comparable_model.rb'
221
278
 
279
+ # Offense count: 4
280
+ # This cop supports safe autocorrection (--autocorrect).
281
+ Style/RedundantStringEscape:
282
+ Exclude:
283
+ - 'lib/lutaml/model/schema/templates/simple_type.rb'
284
+ - 'lib/lutaml/model/schema/xml_compiler.rb'
285
+
222
286
  # Offense count: 1
223
- # This cop supports unsafe autocorrection (--autocorrect-all).
224
- # Configuration parameters: Mode.
225
- Style/StringConcatenation:
287
+ # Configuration parameters: Max.
288
+ Style/SafeNavigationChainLength:
226
289
  Exclude:
227
- - 'spec/lutaml/model/xml_mapping_spec.rb'
290
+ - 'lib/lutaml/model/serialize.rb'
data/Gemfile CHANGED
@@ -5,8 +5,10 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in lutaml-model.gemspec
6
6
  gemspec
7
7
 
8
+ gem "benchmark-ips"
8
9
  gem "bigdecimal"
9
10
  gem "equivalent-xml"
11
+ gem "lutaml-xsd"
10
12
  gem "multi_json"
11
13
  gem "nokogiri"
12
14
  gem "oga"