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.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +1 -0
  3. data/.github/workflows/release.yml +3 -0
  4. data/.gitignore +6 -1
  5. data/.irbrc +1 -0
  6. data/.pryrc +1 -0
  7. data/.rubocop_todo.yml +25 -52
  8. data/README.adoc +2177 -192
  9. data/docs/custom_registers.adoc +228 -0
  10. data/docs/schema_generation.adoc +898 -0
  11. data/docs/schema_import.adoc +364 -0
  12. data/flake.lock +114 -0
  13. data/flake.nix +103 -0
  14. data/lib/lutaml/model/attribute.rb +230 -94
  15. data/lib/lutaml/model/choice.rb +30 -0
  16. data/lib/lutaml/model/collection.rb +194 -0
  17. data/lib/lutaml/model/comparable_model.rb +3 -3
  18. data/lib/lutaml/model/config.rb +26 -3
  19. data/lib/lutaml/model/constants.rb +2 -0
  20. data/lib/lutaml/model/error/element_count_out_of_range_error.rb +29 -0
  21. data/lib/lutaml/model/error/invalid_attribute_name_error.rb +15 -0
  22. data/lib/lutaml/model/error/invalid_attribute_options_error.rb +16 -0
  23. data/lib/lutaml/model/error/invalid_choice_range_error.rb +3 -5
  24. data/lib/lutaml/model/error/register/not_registrable_class_error.rb +11 -0
  25. data/lib/lutaml/model/error/type/invalid_value_error.rb +5 -3
  26. data/lib/lutaml/model/error/type/max_bound_error.rb +20 -0
  27. data/lib/lutaml/model/error/type/max_length_error.rb +20 -0
  28. data/lib/lutaml/model/error/type/min_bound_error.rb +20 -0
  29. data/lib/lutaml/model/error/type/min_length_error.rb +20 -0
  30. data/lib/lutaml/model/error/type/pattern_not_matched_error.rb +18 -0
  31. data/lib/lutaml/model/error/validation_failed_error.rb +9 -0
  32. data/lib/lutaml/model/error.rb +10 -0
  33. data/lib/lutaml/model/errors.rb +36 -0
  34. data/lib/lutaml/model/format_registry.rb +5 -2
  35. data/lib/lutaml/model/global_register.rb +41 -0
  36. data/lib/lutaml/model/{hash.rb → hash_adapter.rb} +5 -5
  37. data/lib/lutaml/model/jsonl/document.rb +14 -0
  38. data/lib/lutaml/model/jsonl/mapping.rb +19 -0
  39. data/lib/lutaml/model/jsonl/mapping_rule.rb +9 -0
  40. data/lib/lutaml/model/jsonl/standard_adapter.rb +33 -0
  41. data/lib/lutaml/model/jsonl/transform.rb +19 -0
  42. data/lib/lutaml/model/jsonl.rb +21 -0
  43. data/lib/lutaml/model/key_value_document.rb +3 -2
  44. data/lib/lutaml/model/mapping/key_value_mapping.rb +64 -4
  45. data/lib/lutaml/model/mapping/key_value_mapping_rule.rb +4 -0
  46. data/lib/lutaml/model/mapping/mapping_rule.rb +8 -3
  47. data/lib/lutaml/model/register.rb +105 -0
  48. data/lib/lutaml/model/registrable.rb +6 -0
  49. data/lib/lutaml/model/schema/base_schema.rb +64 -0
  50. data/lib/lutaml/model/schema/decorators/attribute.rb +114 -0
  51. data/lib/lutaml/model/schema/decorators/choices.rb +31 -0
  52. data/lib/lutaml/model/schema/decorators/class_definition.rb +85 -0
  53. data/lib/lutaml/model/schema/decorators/definition_collection.rb +97 -0
  54. data/lib/lutaml/model/schema/generator/definition.rb +53 -0
  55. data/lib/lutaml/model/schema/generator/definitions_collection.rb +81 -0
  56. data/lib/lutaml/model/schema/generator/properties_collection.rb +63 -0
  57. data/lib/lutaml/model/schema/generator/property.rb +110 -0
  58. data/lib/lutaml/model/schema/generator/ref.rb +24 -0
  59. data/lib/lutaml/model/schema/helpers/template_helper.rb +49 -0
  60. data/lib/lutaml/model/schema/json_schema.rb +42 -49
  61. data/lib/lutaml/model/schema/relaxng_schema.rb +14 -10
  62. data/lib/lutaml/model/schema/renderer.rb +36 -0
  63. data/lib/lutaml/model/schema/shared_methods.rb +24 -0
  64. data/lib/lutaml/model/schema/templates/model.erb +9 -0
  65. data/lib/lutaml/model/schema/xml_compiler/attribute.rb +85 -0
  66. data/lib/lutaml/model/schema/xml_compiler/attribute_group.rb +45 -0
  67. data/lib/lutaml/model/schema/xml_compiler/choice.rb +65 -0
  68. data/lib/lutaml/model/schema/xml_compiler/complex_content.rb +27 -0
  69. data/lib/lutaml/model/schema/xml_compiler/complex_content_restriction.rb +34 -0
  70. data/lib/lutaml/model/schema/xml_compiler/complex_type.rb +136 -0
  71. data/lib/lutaml/model/schema/xml_compiler/element.rb +104 -0
  72. data/lib/lutaml/model/schema/xml_compiler/group.rb +97 -0
  73. data/lib/lutaml/model/schema/xml_compiler/restriction.rb +101 -0
  74. data/lib/lutaml/model/schema/xml_compiler/sequence.rb +50 -0
  75. data/lib/lutaml/model/schema/xml_compiler/simple_content.rb +36 -0
  76. data/lib/lutaml/model/schema/xml_compiler/simple_type.rb +189 -0
  77. data/lib/lutaml/model/schema/xml_compiler.rb +231 -587
  78. data/lib/lutaml/model/schema/xsd_schema.rb +12 -8
  79. data/lib/lutaml/model/schema/yaml_schema.rb +41 -35
  80. data/lib/lutaml/model/schema.rb +1 -0
  81. data/lib/lutaml/model/sequence.rb +60 -30
  82. data/lib/lutaml/model/serialize.rb +175 -53
  83. data/lib/lutaml/model/services/base.rb +11 -0
  84. data/lib/lutaml/model/services/logger.rb +2 -2
  85. data/lib/lutaml/model/services/rule_value_extractor.rb +92 -0
  86. data/lib/lutaml/model/services/type/validator/number.rb +25 -0
  87. data/lib/lutaml/model/services/type/validator/string.rb +52 -0
  88. data/lib/lutaml/model/services/type/validator.rb +43 -0
  89. data/lib/lutaml/model/services/validator.rb +145 -0
  90. data/lib/lutaml/model/services.rb +3 -0
  91. data/lib/lutaml/model/transform/key_value_transform.rb +60 -50
  92. data/lib/lutaml/model/transform/xml_transform.rb +46 -57
  93. data/lib/lutaml/model/transform.rb +22 -8
  94. data/lib/lutaml/model/type/boolean.rb +1 -1
  95. data/lib/lutaml/model/type/date.rb +1 -1
  96. data/lib/lutaml/model/type/date_time.rb +1 -1
  97. data/lib/lutaml/model/type/decimal.rb +11 -9
  98. data/lib/lutaml/model/type/float.rb +2 -1
  99. data/lib/lutaml/model/type/integer.rb +24 -21
  100. data/lib/lutaml/model/type/string.rb +4 -2
  101. data/lib/lutaml/model/type/time.rb +1 -1
  102. data/lib/lutaml/model/type/time_without_date.rb +1 -1
  103. data/lib/lutaml/model/type/value.rb +5 -1
  104. data/lib/lutaml/model/type.rb +5 -2
  105. data/lib/lutaml/model/utils.rb +30 -8
  106. data/lib/lutaml/model/validation.rb +6 -4
  107. data/lib/lutaml/model/version.rb +1 -1
  108. data/lib/lutaml/model/xml/document.rb +37 -19
  109. data/lib/lutaml/model/xml/mapping.rb +74 -13
  110. data/lib/lutaml/model/xml/mapping_rule.rb +10 -2
  111. data/lib/lutaml/model/xml/nokogiri_adapter.rb +5 -3
  112. data/lib/lutaml/model/xml/oga/element.rb +4 -1
  113. data/lib/lutaml/model/xml/oga_adapter.rb +4 -3
  114. data/lib/lutaml/model/xml/ox_adapter.rb +20 -6
  115. data/lib/lutaml/model/xml/xml_element.rb +3 -28
  116. data/lib/lutaml/model/xml_adapter/element.rb +1 -1
  117. data/lib/lutaml/model/xml_adapter/nokogiri_adapter.rb +1 -1
  118. data/lib/lutaml/model/xml_adapter/oga_adapter.rb +1 -1
  119. data/lib/lutaml/model/xml_adapter/ox_adapter.rb +1 -1
  120. data/lib/lutaml/model/yamls/document.rb +14 -0
  121. data/lib/lutaml/model/yamls/mapping.rb +19 -0
  122. data/lib/lutaml/model/yamls/mapping_rule.rb +9 -0
  123. data/lib/lutaml/model/yamls/standard_adapter.rb +34 -0
  124. data/lib/lutaml/model/yamls/transform.rb +19 -0
  125. data/lib/lutaml/model/yamls.rb +21 -0
  126. data/lib/lutaml/model.rb +7 -31
  127. data/spec/benchmarks/xml_parsing_benchmark_spec.rb +4 -5
  128. data/spec/fixtures/xml/advanced_test_schema.xsd +134 -0
  129. data/spec/fixtures/xml/examples/nested_categories.xml +55 -0
  130. data/spec/fixtures/xml/examples/valid_catalog.xml +43 -0
  131. data/spec/fixtures/xml/product_catalog.xsd +151 -0
  132. data/spec/fixtures/xml/specifications_schema.xsd +38 -0
  133. data/spec/lutaml/model/attribute_collection_spec.rb +101 -0
  134. data/spec/lutaml/model/attribute_spec.rb +41 -44
  135. data/spec/lutaml/model/choice_spec.rb +44 -0
  136. data/spec/lutaml/model/custom_collection_spec.rb +830 -0
  137. data/spec/lutaml/model/custom_model_spec.rb +15 -3
  138. data/spec/lutaml/model/defaults_spec.rb +5 -1
  139. data/spec/lutaml/model/global_register_spec.rb +108 -0
  140. data/spec/lutaml/model/group_spec.rb +9 -3
  141. data/spec/lutaml/model/jsonl/standard_adapter_spec.rb +91 -0
  142. data/spec/lutaml/model/jsonl_spec.rb +229 -0
  143. data/spec/lutaml/model/multiple_mapping_spec.rb +1 -1
  144. data/spec/lutaml/model/register/key_value_spec.rb +275 -0
  145. data/spec/lutaml/model/register/xml_spec.rb +187 -0
  146. data/spec/lutaml/model/register_spec.rb +147 -0
  147. data/spec/lutaml/model/rule_value_extractor_spec.rb +162 -0
  148. data/spec/lutaml/model/schema/generator/definitions_collection_spec.rb +120 -0
  149. data/spec/lutaml/model/schema/json_schema_spec.rb +412 -51
  150. data/spec/lutaml/model/schema/json_schema_to_models_spec.rb +383 -0
  151. data/spec/lutaml/model/schema/xml_compiler/attribute_group_spec.rb +65 -0
  152. data/spec/lutaml/model/schema/xml_compiler/attribute_spec.rb +63 -0
  153. data/spec/lutaml/model/schema/xml_compiler/choice_spec.rb +71 -0
  154. data/spec/lutaml/model/schema/xml_compiler/complex_content_restriction_spec.rb +55 -0
  155. data/spec/lutaml/model/schema/xml_compiler/complex_content_spec.rb +37 -0
  156. data/spec/lutaml/model/schema/xml_compiler/complex_type_spec.rb +173 -0
  157. data/spec/lutaml/model/schema/xml_compiler/element_spec.rb +63 -0
  158. data/spec/lutaml/model/schema/xml_compiler/group_spec.rb +86 -0
  159. data/spec/lutaml/model/schema/xml_compiler/restriction_spec.rb +76 -0
  160. data/spec/lutaml/model/schema/xml_compiler/sequence_spec.rb +59 -0
  161. data/spec/lutaml/model/schema/xml_compiler/simple_content_spec.rb +55 -0
  162. data/spec/lutaml/model/schema/xml_compiler/simple_type_spec.rb +181 -0
  163. data/spec/lutaml/model/schema/xml_compiler_spec.rb +503 -1804
  164. data/spec/lutaml/model/schema/yaml_schema_spec.rb +249 -26
  165. data/spec/lutaml/model/sequence_spec.rb +36 -0
  166. data/spec/lutaml/model/serializable_spec.rb +31 -0
  167. data/spec/lutaml/model/type_spec.rb +8 -4
  168. data/spec/lutaml/model/utils_spec.rb +3 -3
  169. data/spec/lutaml/model/xml/derived_attributes_spec.rb +1 -1
  170. data/spec/lutaml/model/xml/xml_element_spec.rb +7 -1
  171. data/spec/lutaml/model/xml_adapter/xml_namespace_spec.rb +6 -6
  172. data/spec/lutaml/model/xml_adapter_spec.rb +24 -0
  173. data/spec/lutaml/model/xml_mapping_rule_spec.rb +11 -4
  174. data/spec/lutaml/model/xml_mapping_spec.rb +1 -1
  175. data/spec/lutaml/model/yamls/standard_adapter_spec.rb +183 -0
  176. data/spec/lutaml/model/yamls_spec.rb +294 -0
  177. data/spec/spec_helper.rb +1 -0
  178. metadata +105 -9
  179. data/lib/lutaml/model/schema/templates/simple_type.rb +0 -247
  180. /data/lib/lutaml/model/{hash → hash_adapter}/document.rb +0 -0
  181. /data/lib/lutaml/model/{hash → hash_adapter}/mapping.rb +0 -0
  182. /data/lib/lutaml/model/{hash → hash_adapter}/mapping_rule.rb +0 -0
  183. /data/lib/lutaml/model/{hash → hash_adapter}/standard_adapter.rb +0 -0
  184. /data/lib/lutaml/model/{hash → hash_adapter}/transform.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f183fc2d573bc4334639c25ff07b4959279e2907a57e6267087673c15ab366b9
4
- data.tar.gz: ee03da94f667dd5b00651686f8ac580df98e99729d3a59f5e990e80335d15200
3
+ metadata.gz: 99264c5157019d0cddfc59098e9603152db0a2d84caa8c9710a9c6a165f39cc4
4
+ data.tar.gz: 34886a6307aa6b6bb2211925477272c7a1412b67c7ef6695ea495a211bc0e540
5
5
  SHA512:
6
- metadata.gz: cab7034d72088f139ff4893e5fd6dd3331dee0823bac4db5f69efd0dd56ca3169beb63694b704f2edb5caadf4d8f2e0388d05c9785bc54248390549d49fecb18
7
- data.tar.gz: 11e5728cdd5dc561dcf084047aaea8f748143aefeaa69802feed4f4b8dabeb30b2a47e7fdb055eba70e376cd4a587cbcd991a21d25b7045a8a4b548bc7f11667
6
+ metadata.gz: f1f358820c85b0626fade2aaac1ff1c3a408c0e267e22b25165d133b92adccbf31c2ca969099dbd441c1fbfc8d9833e5b1ff43fcdf079f6523e769f28bef91c5
7
+ data.tar.gz: c2799042e4d91fedd894c7f86c34f79ecc93509e4422b5f204aef1f5eb5150133e120fa442477c39185c210fe65c6fcb844bb6764e3833a6828235a4e9551054
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ use flake
@@ -18,6 +18,9 @@ jobs:
18
18
  uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
19
19
  with:
20
20
  next_version: ${{ github.event.inputs.next_version }}
21
+ post_install: |
22
+ git status
23
+ cat .bundle/config
21
24
  secrets:
22
25
  rubygems-api-key: ${{ secrets.LUTAML_CI_RUBYGEMS_API_KEY }}
23
26
  pat_token: ${{ secrets.LUTAML_CI_PAT_TOKEN }}
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  .rubocop-https---*
2
2
 
3
- /.bundle/
4
3
  /.yardoc
5
4
  /_yardoc/
6
5
  /coverage/
@@ -11,3 +10,9 @@
11
10
 
12
11
  # rspec failure tracking
13
12
  .rspec_status
13
+
14
+ # Direnv
15
+ .direnv/
16
+
17
+ # Bundler
18
+ .bundle/
data/.irbrc ADDED
@@ -0,0 +1 @@
1
+ require "lutaml/model"
data/.pryrc ADDED
@@ -0,0 +1 @@
1
+ require "lutaml/model"
data/.rubocop_todo.yml CHANGED
@@ -1,35 +1,14 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-04-08 13:11:39 UTC using RuboCop version 1.75.2.
3
+ # on 2025-07-07 12:34:09 UTC using RuboCop version 1.77.0.
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: 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: 525
9
+ # Offense count: 627
31
10
  # This cop supports safe autocorrection (--autocorrect).
32
- # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
11
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
33
12
  # URISchemes: http, https
34
13
  Layout/LineLength:
35
14
  Enabled: false
@@ -42,18 +21,18 @@ Lint/ConstantDefinitionInBlock:
42
21
  - 'spec/benchmarks/xml_parsing_benchmark_spec.rb'
43
22
  - 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
44
23
 
45
- # Offense count: 60
24
+ # Offense count: 65
46
25
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
47
26
  Metrics/AbcSize:
48
27
  Enabled: false
49
28
 
50
- # Offense count: 9
29
+ # Offense count: 8
51
30
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
52
31
  # AllowedMethods: refine
53
32
  Metrics/BlockLength:
54
- Max: 35
33
+ Max: 36
55
34
 
56
- # Offense count: 43
35
+ # Offense count: 36
57
36
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
58
37
  Metrics/CyclomaticComplexity:
59
38
  Exclude:
@@ -69,17 +48,17 @@ Metrics/CyclomaticComplexity:
69
48
  - 'lib/lutaml/model/xml/oga_adapter.rb'
70
49
  - 'lib/lutaml/model/xml/ox_adapter.rb'
71
50
 
72
- # Offense count: 93
51
+ # Offense count: 95
73
52
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
74
53
  Metrics/MethodLength:
75
- Max: 44
54
+ Max: 45
76
55
 
77
- # Offense count: 11
56
+ # Offense count: 13
78
57
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
79
58
  Metrics/ParameterLists:
80
59
  Max: 22
81
60
 
82
- # Offense count: 33
61
+ # Offense count: 26
83
62
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
84
63
  Metrics/PerceivedComplexity:
85
64
  Exclude:
@@ -95,6 +74,15 @@ Metrics/PerceivedComplexity:
95
74
  - 'lib/lutaml/model/xml/oga_adapter.rb'
96
75
  - 'lib/lutaml/model/xml/ox_adapter.rb'
97
76
 
77
+ # Offense count: 5
78
+ # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods.
79
+ # AllowedMethods: call
80
+ Naming/PredicateMethod:
81
+ Exclude:
82
+ - 'lib/lutaml/model/attribute.rb'
83
+ - 'lib/lutaml/model/mapping/mapping_rule.rb'
84
+ - 'spec/lutaml/model/custom_vobject_adapter_spec.rb'
85
+
98
86
  # Offense count: 1
99
87
  # Configuration parameters: MinSize.
100
88
  Performance/CollectionLiteralInLoop:
@@ -129,10 +117,10 @@ RSpec/DescribedClass:
129
117
  Exclude:
130
118
  - 'spec/lutaml/model/xml_mapping_spec.rb'
131
119
 
132
- # Offense count: 174
120
+ # Offense count: 211
133
121
  # Configuration parameters: CountAsOne.
134
122
  RSpec/ExampleLength:
135
- Max: 54
123
+ Max: 36
136
124
 
137
125
  # Offense count: 13
138
126
  RSpec/LeakyConstantDeclaration:
@@ -140,16 +128,16 @@ RSpec/LeakyConstantDeclaration:
140
128
  - 'spec/benchmarks/xml_parsing_benchmark_spec.rb'
141
129
  - 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
142
130
 
143
- # Offense count: 251
131
+ # Offense count: 329
144
132
  RSpec/MultipleExpectations:
145
133
  Max: 21
146
134
 
147
- # Offense count: 30
135
+ # Offense count: 49
148
136
  # Configuration parameters: AllowSubject.
149
137
  RSpec/MultipleMemoizedHelpers:
150
138
  Max: 9
151
139
 
152
- # Offense count: 121
140
+ # Offense count: 47
153
141
  # Configuration parameters: AllowedGroups.
154
142
  RSpec/NestedGroups:
155
143
  Max: 4
@@ -182,24 +170,9 @@ Style/CommentedKeyword:
182
170
  Exclude:
183
171
  - 'spec/lutaml/model/custom_bibtex_adapter_spec.rb'
184
172
 
185
- # Offense count: 1
186
- # This cop supports unsafe autocorrection (--autocorrect-all).
187
- # Configuration parameters: AllowedReceivers.
188
- # AllowedReceivers: Thread.current
189
- Style/HashEachMethods:
190
- Exclude:
191
- - 'lib/lutaml/model/schema/xml_compiler.rb'
192
-
193
173
  # Offense count: 1
194
174
  # Configuration parameters: AllowedMethods.
195
175
  # AllowedMethods: respond_to_missing?
196
176
  Style/OptionalBooleanParameter:
197
177
  Exclude:
198
178
  - 'lib/lutaml/model/comparable_model.rb'
199
-
200
- # Offense count: 4
201
- # This cop supports safe autocorrection (--autocorrect).
202
- Style/RedundantStringEscape:
203
- Exclude:
204
- - 'lib/lutaml/model/schema/templates/simple_type.rb'
205
- - 'lib/lutaml/model/schema/xml_compiler.rb'