lutaml-model 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) 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 +18 -186
  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/adapter/multi_json_adapter.rb +4 -2
  14. data/lib/lutaml/json/adapter/oj_adapter.rb +4 -2
  15. data/lib/lutaml/json.rb +4 -0
  16. data/lib/lutaml/key_value/adapter/json/multi_json_adapter.rb +4 -2
  17. data/lib/lutaml/key_value/adapter/json/oj_adapter.rb +4 -2
  18. data/lib/lutaml/model/adapter_resolver.rb +410 -0
  19. data/lib/lutaml/model/adapter_scope.rb +64 -0
  20. data/lib/lutaml/model/config.rb +84 -21
  21. data/lib/lutaml/model/configuration.rb +17 -249
  22. data/lib/lutaml/model/format_registry.rb +44 -117
  23. data/lib/lutaml/model/mapping/listener.rb +4 -2
  24. data/lib/lutaml/model/serialize/format_conversion.rb +42 -3
  25. data/lib/lutaml/model/serialize.rb +4 -2
  26. data/lib/lutaml/model/services/base.rb +4 -2
  27. data/lib/lutaml/model/version.rb +1 -1
  28. data/lib/lutaml/model.rb +2 -0
  29. data/lib/lutaml/toml.rb +10 -3
  30. data/lib/lutaml/xml/serialization/instance_methods.rb +6 -0
  31. data/lib/lutaml/xml.rb +3 -4
  32. data/lib/lutaml/yaml.rb +4 -0
  33. data/lib/lutaml/yamls/adapter/mapping.rb +7 -0
  34. data/lib/lutaml/yamls/adapter/standard_adapter.rb +23 -2
  35. data/lib/lutaml/yamls/adapter/transform.rb +105 -7
  36. data/lib/lutaml/yamls/adapter/yamls_sequence.rb +20 -0
  37. data/lib/lutaml/yamls/adapter/yamls_sequence_rule.rb +48 -0
  38. data/lib/lutaml/yamls/adapter.rb +2 -0
  39. data/spec/fixtures/geolexica_v2_concept.rb +136 -0
  40. data/spec/fixtures/geolexica_v2_sample.yaml +36 -0
  41. data/spec/fixtures/geolexica_v2_sample2.yaml +38 -0
  42. data/spec/fixtures/yamls_range_concept.rb +139 -0
  43. data/spec/lutaml/model/xml_decoupling_spec.rb +5 -4
  44. data/spec/lutaml/model/yamls_range_spec.rb +393 -0
  45. data/spec/lutaml/model/yamls_sequence_spec.rb +245 -0
  46. data/spec/spec_helper.rb +5 -0
  47. metadata +13 -3
  48. 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: d6eb717e543e98728e8819eef97823780156ce2f594c360f678b9d23f9baf230
4
+ data.tar.gz: 64906eed0282afa83f0905db2e3a75e607a22bacf5e9e40cafa3c0007bdc8fec
5
5
  SHA512:
6
- metadata.gz: 05d5cb08e286dac1099ff9c591e62358609059dc42e4f97b5b7b41f5e638fc1d27b81437729980d8477a946fa4eac43f895da316dfc3ae7916af12e3a70b9074
7
- data.tar.gz: 39d87718bc1687710b447618c547e567c6d324f05759000439343a450c3ce4cf7e327250654776066547dee768b9cf9dc0a7992a02969627930046f2bf95b815
6
+ metadata.gz: 62b3ca87767a8b942d78b22800b6765467532a194484c18f494bc29ff558adb57f2fcf92f7ea5e2bba5a05cac811c39d807c40885c247190452b33556ccf78f8
7
+ data.tar.gz: 1771fd424b8c31e9da2c6940b750c80af2ac38b4ae05e02d234894ee9df5cd5ad4dbd6a9486bbbee0060a3f956507a98a3bfdcc6dd1d6a074957f544649638ee
@@ -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 22:38:22 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,21 @@ 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
14
+ # Offense count: 2
90
15
  # 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:
16
+ # Configuration parameters: AllowForAlignment.
17
+ Layout/CommentIndentation:
94
18
  Exclude:
95
- - 'spec/lutaml/model/cached_type_resolver_spec.rb'
96
- - 'spec/lutaml/xml/schema/xsd/liquid_methods/simple_content_spec.rb'
19
+ - 'lib/lutaml/model/mapping/listener.rb'
20
+ - 'lib/lutaml/model/services/base.rb'
97
21
 
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
22
+ # Offense count: 3210
117
23
  # This cop supports safe autocorrection (--autocorrect).
118
24
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
119
25
  # URISchemes: http, https
120
26
  Layout/LineLength:
121
27
  Enabled: false
122
28
 
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
29
  # Offense count: 21
158
30
  # Configuration parameters: AllowedMethods.
159
31
  # AllowedMethods: enums
@@ -170,15 +42,10 @@ Lint/ConstantDefinitionInBlock:
170
42
  Lint/DuplicateBranch:
171
43
  Enabled: false
172
44
 
173
- # Offense count: 21
45
+ # Offense count: 3
174
46
  Lint/DuplicateMethods:
175
47
  Exclude:
176
48
  - '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
49
 
183
50
  # Offense count: 1
184
51
  # This cop supports safe autocorrection (--autocorrect).
@@ -251,7 +118,7 @@ Lint/UselessConstantScoping:
251
118
  - 'lib/lutaml/xml/adapter/nokogiri_adapter.rb'
252
119
  - 'lib/lutaml/xml/mapping_rule.rb'
253
120
 
254
- # Offense count: 336
121
+ # Offense count: 340
255
122
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
256
123
  Metrics/AbcSize:
257
124
  Enabled: false
@@ -267,12 +134,12 @@ Metrics/BlockLength:
267
134
  Metrics/BlockNesting:
268
135
  Max: 6
269
136
 
270
- # Offense count: 297
137
+ # Offense count: 301
271
138
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
272
139
  Metrics/CyclomaticComplexity:
273
140
  Enabled: false
274
141
 
275
- # Offense count: 543
142
+ # Offense count: 551
276
143
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
277
144
  Metrics/MethodLength:
278
145
  Max: 514
@@ -283,7 +150,7 @@ Metrics/ParameterLists:
283
150
  Max: 24
284
151
  MaxOptionalParameters: 5
285
152
 
286
- # Offense count: 251
153
+ # Offense count: 255
287
154
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
288
155
  Metrics/PerceivedComplexity:
289
156
  Enabled: false
@@ -295,12 +162,11 @@ Naming/ClassAndModuleCamelCase:
295
162
  Exclude:
296
163
  - 'spec/support/xml_mapping_namespaces.rb'
297
164
 
298
- # Offense count: 8
165
+ # Offense count: 6
299
166
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
300
167
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
301
168
  Naming/MethodParameterName:
302
169
  Exclude:
303
- - 'lib/lutaml/model/configuration.rb'
304
170
  - 'lib/lutaml/model/error/invalid_attribute_type_error.rb'
305
171
  - 'lib/lutaml/model/error/unknown_adapter_type_error.rb'
306
172
  - 'lib/lutaml/model/type_context.rb'
@@ -376,7 +242,7 @@ RSpec/BeforeAfterAll:
376
242
  RSpec/ContextWording:
377
243
  Enabled: false
378
244
 
379
- # Offense count: 79
245
+ # Offense count: 81
380
246
  # Configuration parameters: IgnoredMetadata.
381
247
  RSpec/DescribeClass:
382
248
  Enabled: false
@@ -387,7 +253,7 @@ RSpec/DescribeMethod:
387
253
  - 'spec/lutaml/xml/schema/xsd/schema_helper_methods_spec.rb'
388
254
  - 'spec/lutaml/xml/serializable_namespace_spec.rb'
389
255
 
390
- # Offense count: 1155
256
+ # Offense count: 1164
391
257
  # Configuration parameters: CountAsOne.
392
258
  RSpec/ExampleLength:
393
259
  Max: 68
@@ -462,7 +328,7 @@ RSpec/MultipleDescribes:
462
328
  - 'spec/lutaml/xml/namespace_resolution_strategy_spec.rb'
463
329
  - 'spec/lutaml/xml/xml_space_type_spec.rb'
464
330
 
465
- # Offense count: 1300
331
+ # Offense count: 1336
466
332
  RSpec/MultipleExpectations:
467
333
  Max: 21
468
334
 
@@ -534,26 +400,6 @@ Security/MarshalLoad:
534
400
  Exclude:
535
401
  - 'scripts-xmi-profile/profile_xmi.rb'
536
402
 
537
- # Offense count: 46
538
- # 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'
556
-
557
403
  # Offense count: 1
558
404
  # This cop supports unsafe autocorrection (--autocorrect-all).
559
405
  # Configuration parameters: AllowedMethods, AllowedPatterns.
@@ -577,7 +423,7 @@ Style/EmptyElse:
577
423
  - 'lib/lutaml/xml/declaration_planner.rb'
578
424
  - 'lib/lutaml/xml/model_transform.rb'
579
425
 
580
- # Offense count: 48
426
+ # Offense count: 46
581
427
  # This cop supports safe autocorrection (--autocorrect).
582
428
  # Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
583
429
  # SupportedStyles: annotated, template, unannotated
@@ -588,33 +434,19 @@ Style/FormatStringToken:
588
434
  - 'bench/bench_mml.rb'
589
435
  - 'bench/bench_niso.rb'
590
436
  - 'bench/bench_sts.rb'
591
- - 'bench/bench_uniword.rb'
592
437
  - 'bench/bench_xmi.rb'
593
438
  - 'benchmark/quick_benchmark.rb'
594
439
  - 'benchmark/serialization_benchmark.rb'
595
440
 
596
- # Offense count: 6
441
+ # Offense count: 5
597
442
  Style/MixinUsage:
598
443
  Exclude:
599
444
  - 'bench/bench_mml.rb'
600
445
  - 'bench/bench_niso.rb'
601
446
  - 'bench/bench_sts.rb'
602
447
  - 'bench/bench_unitsml.rb'
603
- - 'bench/bench_uniword.rb'
604
448
  - 'bench/bench_xmi.rb'
605
449
 
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
450
  # Offense count: 12
619
451
  # Configuration parameters: AllowedClasses.
620
452
  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.
data/bench/bench_xmi.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Benchmark: XMI (Sparx EA XMI parsing)
5
- # Gate: parse time < 0.15s for ea251, < 3.5s for full-242
5
+ # Gate: see gate_config.rb for per-fixture thresholds
6
6
  #
7
7
  # Usage:
8
8
  # XMI_DIR=/path/to/xmi ITERATIONS=5 bundle exec ruby tmp/bench/bench_xmi.rb
@@ -34,18 +34,18 @@ xmi_files.each do |label, path|
34
34
  xml = File.read(path)
35
35
  size_kb = File.size(path) / 1024.0
36
36
  results[label] = measure("XMI #{label} (#{size_kb.round(0)}KB)") do
37
- Xmi::Sparx::SparxRoot.parse_xml(xml)
37
+ Xmi::Sparx::Root.parse_xml(xml)
38
38
  end
39
39
  end
40
40
 
41
41
  puts "\n Gate checks:"
42
42
  if results[:ea251]
43
- status = results[:ea251][:avg_time] < 0.15 ? "PASS" : "FAIL"
44
- printf " ea251 < 0.15s: %s (%.3fs)\n", status, results[:ea251][:avg_time]
43
+ status = results[:ea251][:avg_time] < 0.30 ? "PASS" : "FAIL"
44
+ printf " ea251 < 0.30s: %s (%.3fs)\n", status, results[:ea251][:avg_time]
45
45
  end
46
46
  if results[:large]
47
- status = results[:large][:avg_time] < 3.5 ? "PASS" : "FAIL"
48
- printf " full-242 < 3.5s: %s (%.3fs)\n", status, results[:large][:avg_time]
47
+ status = results[:large][:avg_time] < 6.0 ? "PASS" : "FAIL"
48
+ printf " full-242 < 6.0s: %s (%.3fs)\n", status, results[:large][:avg_time]
49
49
  end
50
50
 
51
51
  write_results_json(json_output_path, results) if json_output_path