lutaml-model 0.8.0 → 0.8.1

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-repos.json +9 -0
  3. data/.github/workflows/downstream-performance.yml +0 -3
  4. data/.rubocop_todo.yml +21 -187
  5. data/README.adoc +212 -15
  6. data/bench/bench_xmi.rb +6 -6
  7. data/bench/gate_config.rb +2 -9
  8. data/docs/_pages/configuration.adoc +155 -41
  9. data/docs/_pages/serialization_adapters.adoc +65 -14
  10. data/docs/index.adoc +3 -1
  11. data/docs/yamls_sequence.adoc +335 -0
  12. data/lib/lutaml/hash_format.rb +4 -0
  13. data/lib/lutaml/json.rb +4 -0
  14. data/lib/lutaml/model/adapter_resolver.rb +410 -0
  15. data/lib/lutaml/model/adapter_scope.rb +64 -0
  16. data/lib/lutaml/model/config.rb +84 -21
  17. data/lib/lutaml/model/configuration.rb +17 -249
  18. data/lib/lutaml/model/format_registry.rb +44 -117
  19. data/lib/lutaml/model/serialize/format_conversion.rb +42 -3
  20. data/lib/lutaml/model/serialize.rb +4 -2
  21. data/lib/lutaml/model/version.rb +1 -1
  22. data/lib/lutaml/model.rb +2 -0
  23. data/lib/lutaml/toml.rb +10 -3
  24. data/lib/lutaml/xml/serialization/instance_methods.rb +6 -0
  25. data/lib/lutaml/xml.rb +3 -4
  26. data/lib/lutaml/yaml.rb +4 -0
  27. data/lib/lutaml/yamls/adapter/mapping.rb +7 -0
  28. data/lib/lutaml/yamls/adapter/standard_adapter.rb +23 -2
  29. data/lib/lutaml/yamls/adapter/transform.rb +105 -7
  30. data/lib/lutaml/yamls/adapter/yamls_sequence.rb +20 -0
  31. data/lib/lutaml/yamls/adapter/yamls_sequence_rule.rb +48 -0
  32. data/lib/lutaml/yamls/adapter.rb +2 -0
  33. data/spec/fixtures/geolexica_v2_concept.rb +136 -0
  34. data/spec/fixtures/geolexica_v2_sample.yaml +36 -0
  35. data/spec/fixtures/geolexica_v2_sample2.yaml +38 -0
  36. data/spec/fixtures/yamls_range_concept.rb +139 -0
  37. data/spec/lutaml/model/xml_decoupling_spec.rb +5 -4
  38. data/spec/lutaml/model/yamls_range_spec.rb +393 -0
  39. data/spec/lutaml/model/yamls_sequence_spec.rb +245 -0
  40. data/spec/spec_helper.rb +5 -0
  41. metadata +13 -3
  42. data/bench/bench_uniword.rb +0 -69
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c756e06ffeedb744a2c6dc3168e678770e105d856c0373340bfb91999a3e0d0d
4
- data.tar.gz: b73daf9b28bc1e6920975a51cb55cdd15255421249e2b130f648e4989d8c7f92
3
+ metadata.gz: 7e243cd9c18fd7a9e9d16c246265f18a5088096093527bb78c860198621040c1
4
+ data.tar.gz: 2eb85ccf7aac11cb6fe202291db84d43c5e32485f1cc32e28679f559e996943e
5
5
  SHA512:
6
- metadata.gz: 05d5cb08e286dac1099ff9c591e62358609059dc42e4f97b5b7b41f5e638fc1d27b81437729980d8477a946fa4eac43f895da316dfc3ae7916af12e3a70b9074
7
- data.tar.gz: 39d87718bc1687710b447618c547e567c6d324f05759000439343a450c3ce4cf7e327250654776066547dee768b9cf9dc0a7992a02969627930046f2bf95b815
6
+ metadata.gz: 541667a09503edffcc498190f7d845c362168e375928b4f0b9341568e057fd8eab4e00c33cb9d495ee6e853caa935d46e3fb0e9f4985758019bc4ab319350171
7
+ data.tar.gz: 342dc3142ac6e68c1bff66956ccdd5a23978253abcab734ffe503534b4205fb7a02f7b2e18603c53f1cc976eb4e907636326acde7653563ff3e000dbc12c40a0
@@ -4,22 +4,31 @@
4
4
  "glossarist/iev",
5
5
  "glossarist/termium",
6
6
  "lutaml/genericode",
7
+ "lutaml/hyperlang",
8
+ "lutaml/lutaml-hal",
7
9
  "lutaml/lutaml-xsd",
8
10
  "lutaml/metaschema",
9
11
  "lutaml/ogc-gml",
12
+ "lutaml/reqif",
13
+ "lutaml/rng",
14
+ "lutaml/unibuf",
10
15
  "lutaml/xmi",
11
16
  "metanorma/atmospheric",
17
+ "metanorma/docbook",
12
18
  "metanorma/metanorma-cli",
13
19
  "metanorma/modspec-ruby",
14
20
  "metanorma/niso-jats",
21
+ "metanorma/prosereflect",
15
22
  "metanorma/revix",
16
23
  "metanorma/rfcxml",
17
24
  "metanorma/sts-ruby",
25
+ "metanorma/uniword",
18
26
  "plurimath/mml",
19
27
  "plurimath/plurimath",
20
28
  "relaton/ieee-idams",
21
29
  "relaton/loc_mods",
22
30
  "relaton/w3c_api",
31
+ "ukiryu/ukiryu",
23
32
  "unitsml/unitsml-ruby"
24
33
  ]
25
34
  }
@@ -38,9 +38,6 @@ jobs:
38
38
  - downstream: unitsml
39
39
  repo: unitsml/unitsml-ruby
40
40
  env_key: UNITSML_DIR
41
- - downstream: uniword
42
- repo: lutaml/uniword
43
- env_key: UNIWORD_DIR
44
41
  steps:
45
42
  - uses: actions/checkout@v6
46
43
  with:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-05-01 09:59:35 UTC using RuboCop version 1.86.0.
3
+ # on 2026-05-03 14:18:01 UTC using RuboCop version 1.86.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -11,149 +11,13 @@ Gemspec/RequiredRubyVersion:
11
11
  Exclude:
12
12
  - 'lutaml-model.gemspec'
13
13
 
14
- # Offense count: 15
15
- # This cop supports safe autocorrection (--autocorrect).
16
- # Configuration parameters: EnforcedStyle, IndentationWidth.
17
- # SupportedStyles: with_first_argument, with_fixed_indentation
18
- Layout/ArgumentAlignment:
19
- Exclude:
20
- - 'lib/lutaml/model/configuration.rb'
21
- - 'lib/lutaml/model/instrumentation.rb'
22
- - 'lib/lutaml/xml/schema/xsd/schema.rb'
23
- - 'lib/lutaml/xml/schema/xsd/schema_path.rb'
24
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/complex_type_spec.rb'
25
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/containers_spec.rb'
26
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/element_spec.rb'
27
-
28
- # Offense count: 1
29
- # This cop supports safe autocorrection (--autocorrect).
30
- # Configuration parameters: EnforcedStyle, IndentationWidth.
31
- # SupportedStyles: with_first_element, with_fixed_indentation
32
- Layout/ArrayAlignment:
33
- Exclude:
34
- - 'lib/lutaml/xml/schema/xsd/base.rb'
35
-
36
- # Offense count: 40
37
- # This cop supports safe autocorrection (--autocorrect).
38
- # Configuration parameters: EnforcedStyleAlignWith.
39
- # SupportedStylesAlignWith: either, start_of_block, start_of_line
40
- Layout/BlockAlignment:
41
- Exclude:
42
- - 'lib/lutaml/xml/schema/xsd/complex_type.rb'
43
- - 'lib/lutaml/xml/schema/xsd/element.rb'
44
- - 'lib/lutaml/xml/schema/xsd/schema.rb'
45
- - 'spec/lutaml/key_value/transformation_spec.rb'
46
- - 'spec/lutaml/model/cached_type_resolver_spec.rb'
47
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/attribute_and_group_spec.rb'
48
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/complex_type_spec.rb'
49
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/containers_spec.rb'
50
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/element_spec.rb'
51
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb'
52
-
53
- # Offense count: 32
54
- # This cop supports safe autocorrection (--autocorrect).
55
- Layout/BlockEndNewline:
56
- Exclude:
57
- - 'lib/lutaml/xml/schema/xsd/complex_type.rb'
58
- - 'lib/lutaml/xml/schema/xsd/element.rb'
59
- - 'lib/lutaml/xml/schema/xsd/schema.rb'
60
- - 'spec/lutaml/key_value/transformation_spec.rb'
61
- - 'spec/lutaml/model/cached_type_resolver_spec.rb'
62
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/attribute_and_group_spec.rb'
63
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/complex_type_spec.rb'
64
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/containers_spec.rb'
65
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/element_spec.rb'
66
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb'
67
-
68
- # Offense count: 3
69
- # This cop supports safe autocorrection (--autocorrect).
70
- Layout/ClosingParenthesisIndentation:
71
- Exclude:
72
- - 'spec/lutaml/model/cached_type_resolver_spec.rb'
73
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb'
74
-
75
- # Offense count: 1
76
- # This cop supports safe autocorrection (--autocorrect).
77
- Layout/ElseAlignment:
78
- Exclude:
79
- - 'lib/lutaml/xml/schema/xsd/schema_path.rb'
80
-
81
- # Offense count: 1
82
- # This cop supports safe autocorrection (--autocorrect).
83
- # Configuration parameters: EnforcedStyleAlignWith.
84
- # SupportedStylesAlignWith: keyword, variable, start_of_line
85
- Layout/EndAlignment:
86
- Exclude:
87
- - 'lib/lutaml/xml/schema/xsd/schema_path.rb'
88
-
89
- # Offense count: 3
90
- # This cop supports safe autocorrection (--autocorrect).
91
- # Configuration parameters: EnforcedStyle, IndentationWidth.
92
- # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
93
- Layout/FirstArgumentIndentation:
94
- Exclude:
95
- - 'spec/lutaml/model/cached_type_resolver_spec.rb'
96
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb'
97
-
98
- # Offense count: 58
99
- # This cop supports safe autocorrection (--autocorrect).
100
- # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
101
- # SupportedStylesAlignWith: start_of_line, relative_to_receiver
102
- Layout/IndentationWidth:
103
- Exclude:
104
- - 'lib/lutaml/xml/schema/xsd/complex_type.rb'
105
- - 'lib/lutaml/xml/schema/xsd/element.rb'
106
- - 'lib/lutaml/xml/schema/xsd/schema.rb'
107
- - 'lib/lutaml/xml/schema/xsd/schema_path.rb'
108
- - 'spec/lutaml/key_value/transformation_spec.rb'
109
- - 'spec/lutaml/model/cached_type_resolver_spec.rb'
110
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/attribute_and_group_spec.rb'
111
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/complex_type_spec.rb'
112
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/containers_spec.rb'
113
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/element_spec.rb'
114
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb'
115
-
116
- # Offense count: 3236
14
+ # Offense count: 3210
117
15
  # This cop supports safe autocorrection (--autocorrect).
118
16
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
119
17
  # URISchemes: http, https
120
18
  Layout/LineLength:
121
19
  Enabled: false
122
20
 
123
- # Offense count: 8
124
- # This cop supports safe autocorrection (--autocorrect).
125
- Layout/MultilineBlockLayout:
126
- Exclude:
127
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/attribute_and_group_spec.rb'
128
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/complex_type_spec.rb'
129
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/containers_spec.rb'
130
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/element_spec.rb'
131
-
132
- # Offense count: 3
133
- # This cop supports safe autocorrection (--autocorrect).
134
- # Configuration parameters: EnforcedStyle.
135
- # SupportedStyles: symmetrical, new_line, same_line
136
- Layout/MultilineMethodCallBraceLayout:
137
- Exclude:
138
- - 'spec/lutaml/model/cached_type_resolver_spec.rb'
139
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb'
140
-
141
- # Offense count: 24
142
- # This cop supports safe autocorrection (--autocorrect).
143
- # Configuration parameters: AllowInHeredoc.
144
- Layout/TrailingWhitespace:
145
- Exclude:
146
- - 'lib/lutaml/model/configuration.rb'
147
- - 'lib/lutaml/model/instrumentation.rb'
148
- - 'lib/lutaml/xml/schema/xsd/base.rb'
149
- - 'lib/lutaml/xml/schema/xsd/complex_type.rb'
150
- - 'lib/lutaml/xml/schema/xsd/schema.rb'
151
- - 'lib/lutaml/xml/schema/xsd/schema_path.rb'
152
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/attribute_and_group_spec.rb'
153
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/complex_type_spec.rb'
154
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/containers_spec.rb'
155
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/element_spec.rb'
156
-
157
21
  # Offense count: 21
158
22
  # Configuration parameters: AllowedMethods.
159
23
  # AllowedMethods: enums
@@ -170,15 +34,10 @@ Lint/ConstantDefinitionInBlock:
170
34
  Lint/DuplicateBranch:
171
35
  Enabled: false
172
36
 
173
- # Offense count: 21
37
+ # Offense count: 3
174
38
  Lint/DuplicateMethods:
175
39
  Exclude:
176
40
  - 'lib/lutaml/xml/mapping.rb'
177
- - 'spec/lutaml/xml/namespace_no_hoisting_spec.rb'
178
- - 'spec/lutaml/xml/namespace_scope_declare_spec.rb'
179
- - 'spec/lutaml/xml/namespace_scope_vcard_spec.rb'
180
- - 'spec/lutaml/xml/prefix_control_spec.rb'
181
- - 'spec/lutaml/xml/type_namespace_examples_spec.rb'
182
41
 
183
42
  # Offense count: 1
184
43
  # This cop supports safe autocorrection (--autocorrect).
@@ -251,7 +110,7 @@ Lint/UselessConstantScoping:
251
110
  - 'lib/lutaml/xml/adapter/nokogiri_adapter.rb'
252
111
  - 'lib/lutaml/xml/mapping_rule.rb'
253
112
 
254
- # Offense count: 336
113
+ # Offense count: 340
255
114
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
256
115
  Metrics/AbcSize:
257
116
  Enabled: false
@@ -267,12 +126,12 @@ Metrics/BlockLength:
267
126
  Metrics/BlockNesting:
268
127
  Max: 6
269
128
 
270
- # Offense count: 297
129
+ # Offense count: 301
271
130
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
272
131
  Metrics/CyclomaticComplexity:
273
132
  Enabled: false
274
133
 
275
- # Offense count: 543
134
+ # Offense count: 551
276
135
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
277
136
  Metrics/MethodLength:
278
137
  Max: 514
@@ -283,7 +142,7 @@ Metrics/ParameterLists:
283
142
  Max: 24
284
143
  MaxOptionalParameters: 5
285
144
 
286
- # Offense count: 251
145
+ # Offense count: 255
287
146
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
288
147
  Metrics/PerceivedComplexity:
289
148
  Enabled: false
@@ -295,12 +154,11 @@ Naming/ClassAndModuleCamelCase:
295
154
  Exclude:
296
155
  - 'spec/support/xml_mapping_namespaces.rb'
297
156
 
298
- # Offense count: 8
157
+ # Offense count: 6
299
158
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
300
159
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
301
160
  Naming/MethodParameterName:
302
161
  Exclude:
303
- - 'lib/lutaml/model/configuration.rb'
304
162
  - 'lib/lutaml/model/error/invalid_attribute_type_error.rb'
305
163
  - 'lib/lutaml/model/error/unknown_adapter_type_error.rb'
306
164
  - 'lib/lutaml/model/type_context.rb'
@@ -376,7 +234,7 @@ RSpec/BeforeAfterAll:
376
234
  RSpec/ContextWording:
377
235
  Enabled: false
378
236
 
379
- # Offense count: 79
237
+ # Offense count: 81
380
238
  # Configuration parameters: IgnoredMetadata.
381
239
  RSpec/DescribeClass:
382
240
  Enabled: false
@@ -387,7 +245,7 @@ RSpec/DescribeMethod:
387
245
  - 'spec/lutaml/xml/schema/xsd/schema_helper_methods_spec.rb'
388
246
  - 'spec/lutaml/xml/serializable_namespace_spec.rb'
389
247
 
390
- # Offense count: 1155
248
+ # Offense count: 1164
391
249
  # Configuration parameters: CountAsOne.
392
250
  RSpec/ExampleLength:
393
251
  Max: 68
@@ -462,7 +320,7 @@ RSpec/MultipleDescribes:
462
320
  - 'spec/lutaml/xml/namespace_resolution_strategy_spec.rb'
463
321
  - 'spec/lutaml/xml/xml_space_type_spec.rb'
464
322
 
465
- # Offense count: 1300
323
+ # Offense count: 1336
466
324
  RSpec/MultipleExpectations:
467
325
  Max: 21
468
326
 
@@ -534,25 +392,15 @@ Security/MarshalLoad:
534
392
  Exclude:
535
393
  - 'scripts-xmi-profile/profile_xmi.rb'
536
394
 
537
- # Offense count: 46
395
+ # Offense count: 2
538
396
  # This cop supports safe autocorrection (--autocorrect).
539
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
540
- # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
541
- # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
542
- # FunctionalMethods: let, let!, subject, watch
543
- # AllowedMethods: lambda, proc, it
544
- Style/BlockDelimiters:
545
- Exclude:
546
- - 'lib/lutaml/xml/schema/xsd/complex_type.rb'
547
- - 'lib/lutaml/xml/schema/xsd/element.rb'
548
- - 'lib/lutaml/xml/schema/xsd/schema.rb'
549
- - 'spec/lutaml/key_value/transformation_spec.rb'
550
- - 'spec/lutaml/model/cached_type_resolver_spec.rb'
551
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/attribute_and_group_spec.rb'
552
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/complex_type_spec.rb'
553
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/containers_spec.rb'
554
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/element_spec.rb'
555
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb'
397
+ # Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames.
398
+ # RedundantRestArgumentNames: args, arguments
399
+ # RedundantKeywordRestArgumentNames: kwargs, options, opts
400
+ # RedundantBlockArgumentNames: blk, block, proc
401
+ Style/ArgumentsForwarding:
402
+ Exclude:
403
+ - 'lib/lutaml/model/serialize.rb'
556
404
 
557
405
  # Offense count: 1
558
406
  # This cop supports unsafe autocorrection (--autocorrect-all).
@@ -577,7 +425,7 @@ Style/EmptyElse:
577
425
  - 'lib/lutaml/xml/declaration_planner.rb'
578
426
  - 'lib/lutaml/xml/model_transform.rb'
579
427
 
580
- # Offense count: 48
428
+ # Offense count: 46
581
429
  # This cop supports safe autocorrection (--autocorrect).
582
430
  # Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
583
431
  # SupportedStyles: annotated, template, unannotated
@@ -588,33 +436,19 @@ Style/FormatStringToken:
588
436
  - 'bench/bench_mml.rb'
589
437
  - 'bench/bench_niso.rb'
590
438
  - 'bench/bench_sts.rb'
591
- - 'bench/bench_uniword.rb'
592
439
  - 'bench/bench_xmi.rb'
593
440
  - 'benchmark/quick_benchmark.rb'
594
441
  - 'benchmark/serialization_benchmark.rb'
595
442
 
596
- # Offense count: 6
443
+ # Offense count: 5
597
444
  Style/MixinUsage:
598
445
  Exclude:
599
446
  - 'bench/bench_mml.rb'
600
447
  - 'bench/bench_niso.rb'
601
448
  - 'bench/bench_sts.rb'
602
449
  - 'bench/bench_unitsml.rb'
603
- - 'bench/bench_uniword.rb'
604
450
  - 'bench/bench_xmi.rb'
605
451
 
606
- # Offense count: 1
607
- # This cop supports safe autocorrection (--autocorrect).
608
- Style/MultilineIfModifier:
609
- Exclude:
610
- - 'lib/lutaml/xml/schema/xsd/schema_path.rb'
611
-
612
- # Offense count: 1
613
- # This cop supports safe autocorrection (--autocorrect).
614
- Style/MultilineTernaryOperator:
615
- Exclude:
616
- - 'lib/lutaml/xml/schema/xsd/schema_path.rb'
617
-
618
452
  # Offense count: 12
619
453
  # Configuration parameters: AllowedClasses.
620
454
  Style/OneClassPerFile:
data/README.adoc CHANGED
@@ -11523,6 +11523,147 @@ yamls = Directory.from_yamls(yamls)
11523
11523
  ====
11524
11524
 
11525
11525
 
11526
+ ==== Heterogeneous YAML Stream (YAMLS Sequence)
11527
+
11528
+ In many real-world datasets, a YAML Stream contains documents of *different*
11529
+ types at specific positions. For example, Geolexica glossary files use
11530
+ document 0 as a concept index and documents 1+ as localized concept entries.
11531
+
11532
+ This is analogous to XML Schema's `<sequence>` element, where child elements
11533
+ appear in a fixed order and each position maps to a different type.
11534
+
11535
+ Lutaml::Model supports this pattern through the `sequence` block inside the
11536
+ `yamls` mapping DSL.
11537
+
11538
+ ===== Usage
11539
+
11540
+ The `sequence` block contains `map_document` calls that bind a document
11541
+ position to a model attribute:
11542
+
11543
+ * `position` — an `Integer` (exact document index) or a `Range` (e.g. `1..`
11544
+ meaning "from document 1 onwards").
11545
+ * `to` — the attribute name on the parent model.
11546
+ * `type` — the model class for deserialization.
11547
+ * `collection` — set to `true` if multiple documents map to this attribute.
11548
+
11549
+ [source,ruby]
11550
+ ----
11551
+ class ConceptIndex < Lutaml::Model::Serializable
11552
+ attribute :data, ConceptIndexData
11553
+ attribute :id, :string
11554
+
11555
+ yaml do
11556
+ map "data", to: :data
11557
+ map "id", to: :id
11558
+ end
11559
+ end
11560
+
11561
+ class LocalizedConcept < Lutaml::Model::Serializable
11562
+ attribute :data, LocalizedConceptData
11563
+ attribute :id, :string
11564
+
11565
+ yaml do
11566
+ map "data", to: :data
11567
+ map "id", to: :id
11568
+ end
11569
+ end
11570
+
11571
+ class ManagedConcept < Lutaml::Model::Serializable
11572
+ attribute :index, ConceptIndex
11573
+ attribute :localized, LocalizedConcept, collection: true
11574
+
11575
+ yamls do
11576
+ sequence do
11577
+ map_document 0, to: :index, type: ConceptIndex
11578
+ map_document 1.., to: :localized, type: LocalizedConcept, collection: true
11579
+ end
11580
+ end
11581
+ end
11582
+ ----
11583
+
11584
+ Given a YAML stream with two documents:
11585
+
11586
+ [source,yaml]
11587
+ ----
11588
+ ---
11589
+ data:
11590
+ identifier: 3.5.8.8
11591
+ localized_concepts:
11592
+ eng: fbe1444a-7c11-555e-bb1b-680a4e6f2502
11593
+ id: 0171b198-d068-53d9-8741-fb87e6755d62
11594
+
11595
+ ---
11596
+ data:
11597
+ definition:
11598
+ - content: characteristic of a financial model
11599
+ terms:
11600
+ - type: expression
11601
+ normative_status: preferred
11602
+ designation: membership-based
11603
+ language_code: eng
11604
+ id: fbe1444a-7c11-555e-bb1b-680a4e6f2502
11605
+ ----
11606
+
11607
+ [source,ruby]
11608
+ ----
11609
+ managed = ManagedConcept.from_yamls(yamls)
11610
+
11611
+ managed.index.data.identifier #=> "3.5.8.8"
11612
+ managed.localized.first.data.language_code #=> "eng"
11613
+ managed.localized.first.data.terms.first.designation #=> "membership-based"
11614
+
11615
+ # Round-trip back to a YAML stream
11616
+ managed.to_yamls #=> "---\ndata:\n identifier: 3.5.8.8\n..."
11617
+ ----
11618
+
11619
+ ===== Position semantics
11620
+
11621
+ [cols="1,4"]
11622
+ |===
11623
+ | Position | Meaning
11624
+
11625
+ | `0` (Integer)
11626
+ | Document at index 0 only. Used with `collection: false` (default).
11627
+
11628
+ | `-1` (negative Integer)
11629
+ | Last document in the stream.
11630
+
11631
+ | `-2` (negative Integer)
11632
+ | Second-to-last document.
11633
+
11634
+ | `1..` (open Range)
11635
+ | All documents from index 1 onwards. Used with `collection: true`.
11636
+
11637
+ | `0..1` (bounded Range)
11638
+ | Documents at indices 0 and 1.
11639
+
11640
+ | `2..4` (bounded Range)
11641
+ | Documents at indices 2, 3, 4.
11642
+
11643
+ | `-2..-1` (negative Range)
11644
+ | Last 2 documents in the stream.
11645
+
11646
+ | `1..-1` (mixed Range)
11647
+ | Documents from index 1 to the end.
11648
+
11649
+ | `2..-1` (mixed Range)
11650
+ | Documents from index 2 to the end.
11651
+ |===
11652
+
11653
+ ===== Loading a directory of sequence-based files
11654
+
11655
+ Each file is a complete YAML stream (one `ManagedConcept`). Load them
11656
+ individually and assemble into a collection:
11657
+
11658
+ [source,ruby]
11659
+ ----
11660
+ concepts = Dir["glossary/*.yaml"].map do |f|
11661
+ ManagedConcept.from_yamls(File.read(f))
11662
+ end
11663
+ collection = ManagedConceptCollection.new(concepts)
11664
+ ----
11665
+
11666
+
11526
11667
  == Serialization: Instance serialization (`to_{format}`)
11527
11668
 
11528
11669
  === General
@@ -15580,13 +15721,13 @@ There are two ways to specify a configuration:
15580
15721
  * by providing a predefined symbol (preferred)
15581
15722
  * by providing the actual adapter classes
15582
15723
 
15583
- There is a default configuration for adapters for commonly used formats:
15724
+ Adapters are auto-detected on first use. The defaults when gems are available:
15584
15725
 
15585
- * YAML: `yaml_adapter_type` is set to `:standard_yaml`
15586
- * JSON: `json_adapter_type` is set to `:standard_json`
15587
- * Hash: `hash_adapter_type` is set to `:standard_hash`
15588
- * XML: not defined
15589
- * TOML: not defined
15726
+ * XML: `:nokogiri` (auto-detected: `:nokogiri` `:ox` `:oga` → `:rexml`)
15727
+ * YAML: `:standard` (alias: `:standard_yaml`)
15728
+ * JSON: `:standard` (alias: `:standard_json`)
15729
+ * Hash: `:standard` (alias: `:standard_hash`)
15730
+ * TOML: `:tomlib` on non-Windows, `:toml_rb` on Windows
15590
15731
 
15591
15732
 
15592
15733
  ==== Configure adapters through symbol choices
@@ -15606,10 +15747,10 @@ require 'lutaml/model'
15606
15747
 
15607
15748
  Lutaml::Model::Config.configure do |config|
15608
15749
  config.xml_adapter_type = :nokogiri # can be one of [:nokogiri, :ox, :oga, :rexml]
15609
- config.hash_adapter_type = :standard_hash
15610
- config.yaml_adapter_type = :standard_yaml
15611
- config.json_adapter_type = :standard_json # can be one of [:standard_json, :multi_json, :oj]
15612
- config.toml_adapter_type = :toml_rb # can be one of [:toml_rb, :tomlib]
15750
+ config.hash_adapter = :standard
15751
+ config.yaml_adapter = :standard
15752
+ config.json_adapter = :standard # can be one of [:standard, :multi_json, :oj]
15753
+ config.toml_adapter = :toml_rb # can be one of [:toml_rb, :tomlib]
15613
15754
  end
15614
15755
  ----
15615
15756
 
@@ -15708,7 +15849,7 @@ Included in the Ruby standard library.
15708
15849
  require 'lutaml/model'
15709
15850
 
15710
15851
  Lutaml::Model::Config.configure do |config|
15711
- config.yaml_adapter = :standard_yaml
15852
+ config.yaml_adapter = :standard
15712
15853
  end
15713
15854
  ----
15714
15855
 
@@ -15738,11 +15879,11 @@ Requires the `oj` gem.
15738
15879
  require 'lutaml/model'
15739
15880
 
15740
15881
  Lutaml::Model::Config.configure do |config|
15741
- config.json_adapter = :standard_json
15882
+ config.json_adapter = :standard
15742
15883
  # or
15743
- config.json_adapter = :multi_json
15884
+ config.json_adapter_type = :multi_json
15744
15885
  # or
15745
- config.json_adapter = :oj
15886
+ config.json_adapter_type = :oj
15746
15887
  end
15747
15888
  ----
15748
15889
 
@@ -15782,6 +15923,62 @@ end
15782
15923
  ----
15783
15924
 
15784
15925
 
15926
+ === Per-operation adapter override
15927
+
15928
+ Override the adapter for a single serialization/deserialization call using the `adapter:` option:
15929
+
15930
+ [source,ruby]
15931
+ ----
15932
+ # Parse with Ox for this call only
15933
+ model = MyClass.from_xml(xml_string, adapter: :ox)
15934
+
15935
+ # Serialize with REXML for this call only
15936
+ output = model.to_xml(adapter: :rexml)
15937
+ ----
15938
+
15939
+ This is useful for testing with a specific adapter without changing global configuration,
15940
+ or for cross-adapter workflows.
15941
+
15942
+ === Scoped adapter context
15943
+
15944
+ Use `Config.with_adapter` for thread-safe, block-scoped adapter overrides:
15945
+
15946
+ [source,ruby]
15947
+ ----
15948
+ # All XML operations in this block use Ox
15949
+ Lutaml::Model::Config.with_adapter(xml: :ox) do
15950
+ model = MyClass.from_xml(data)
15951
+ model.to_xml # also uses Ox
15952
+ end
15953
+ # Outside the block, reverts to the configured default
15954
+ ----
15955
+
15956
+ TIP: `with_adapter` is thread-safe and nestable. Use it in tests instead of
15957
+ manual save/restore patterns.
15958
+
15959
+ === Library stacking
15960
+
15961
+ When multiple libraries depend on lutaml-model, each can set its preferred adapter
15962
+ within a scoped context without affecting the end-user's configuration:
15963
+
15964
+ [source,ruby]
15965
+ ----
15966
+ # In gem "my_xml_library"
15967
+ module MyXmlLibrary
15968
+ def self.parse(data)
15969
+ Config.with_adapter(xml: :nokogiri) do
15970
+ MyModel.from_xml(data)
15971
+ end
15972
+ end
15973
+ end
15974
+
15975
+ # End-user's choice is not affected
15976
+ Config.xml_adapter_type = :ox
15977
+ result = MyXmlLibrary.parse(data) # uses Nokogiri inside
15978
+ my_model.to_xml # uses Ox (user's choice)
15979
+ ----
15980
+
15981
+
15785
15982
  [[opal-compatibility]]
15786
15983
  === Opal compatibility
15787
15984
 
@@ -15790,7 +15987,7 @@ JavaScript). The runtime is detected automatically and adapter selection is
15790
15987
  adjusted accordingly.
15791
15988
 
15792
15989
  * *XML*: Only the `:oga` adapter is available (auto-selected).
15793
- * *JSON*: Only the `:standard_json` adapter is available.
15990
+ * *JSON*: Only the `:standard` adapter is available.
15794
15991
  * *TOML*: Not available on Opal.
15795
15992
  * *Schema generation*: `to_xsd`, `to_relaxng`, and `from_xml` (XML schema
15796
15993
  compilation) raise `NotImplementedError` on Opal.