lutaml-model 0.8.4 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/dependent-tests.yml +5 -0
- data/.rubocop.yml +18 -0
- data/.rubocop_todo.yml +91 -22
- data/Gemfile +2 -0
- data/README.adoc +114 -2
- data/docs/_guides/index.adoc +18 -0
- data/docs/_guides/jsonld-serialization.adoc +217 -0
- data/docs/_guides/rdf-serialization.adoc +344 -0
- data/docs/_guides/turtle-serialization.adoc +224 -0
- data/docs/_migrations/0-8-0-namespace-restructuring.adoc +90 -0
- data/docs/_pages/serialization_adapters.adoc +31 -0
- data/docs/_references/index.adoc +1 -0
- data/docs/_references/rdf-namespaces.adoc +243 -0
- data/docs/index.adoc +3 -2
- data/lib/lutaml/jsonld/adapter.rb +23 -0
- data/lib/lutaml/jsonld/context.rb +69 -0
- data/lib/lutaml/jsonld/term_definition.rb +39 -0
- data/lib/lutaml/jsonld/transform.rb +174 -0
- data/lib/lutaml/jsonld.rb +23 -0
- data/lib/lutaml/model/format_registry.rb +10 -1
- data/lib/lutaml/model/serialize/format_conversion.rb +17 -1
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/model.rb +6 -0
- data/lib/lutaml/rdf/error.rb +7 -0
- data/lib/lutaml/rdf/iri.rb +44 -0
- data/lib/lutaml/rdf/language_tagged.rb +11 -0
- data/lib/lutaml/rdf/literal.rb +62 -0
- data/lib/lutaml/rdf/mapping.rb +71 -0
- data/lib/lutaml/rdf/mapping_rule.rb +35 -0
- data/lib/lutaml/rdf/member_rule.rb +13 -0
- data/lib/lutaml/rdf/namespace.rb +58 -0
- data/lib/lutaml/rdf/namespace_set.rb +69 -0
- data/lib/lutaml/rdf/namespaces/dcterms_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces/owl_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces/rdf_namespace.rb +14 -0
- data/lib/lutaml/rdf/namespaces/rdfs_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces/skos_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces/xsd_namespace.rb +12 -0
- data/lib/lutaml/rdf/namespaces.rb +14 -0
- data/lib/lutaml/rdf/transform.rb +36 -0
- data/lib/lutaml/rdf.rb +19 -0
- data/lib/lutaml/turtle/adapter.rb +35 -0
- data/lib/lutaml/turtle/mapping.rb +7 -0
- data/lib/lutaml/turtle/transform.rb +158 -0
- data/lib/lutaml/turtle.rb +22 -0
- data/lib/lutaml/xml/adapter/adapter_helpers.rb +1 -42
- data/lib/lutaml/xml/adapter/base_adapter.rb +48 -458
- data/lib/lutaml/xml/adapter/namespace_data.rb +0 -17
- data/lib/lutaml/xml/adapter/namespace_uri_collector.rb +71 -0
- data/lib/lutaml/xml/adapter/nokogiri_adapter.rb +5 -1110
- data/lib/lutaml/xml/adapter/oga_adapter.rb +6 -846
- data/lib/lutaml/xml/adapter/ox_adapter.rb +7 -884
- data/lib/lutaml/xml/adapter/plan_based_builder.rb +929 -0
- data/lib/lutaml/xml/adapter/rexml_adapter.rb +10 -864
- data/lib/lutaml/xml/adapter/xml_parser.rb +86 -0
- data/lib/lutaml/xml/adapter/xml_serializer.rb +291 -0
- data/lib/lutaml/xml/adapter.rb +0 -1
- data/lib/lutaml/xml/adapter_element.rb +7 -1
- data/lib/lutaml/xml/builder/base.rb +0 -1
- data/lib/lutaml/xml/data_model.rb +9 -1
- data/lib/lutaml/xml/document.rb +3 -1
- data/lib/lutaml/xml/element.rb +13 -10
- data/lib/lutaml/xml/serialization/format_conversion.rb +19 -42
- data/lib/lutaml/xml/serialization/instance_methods.rb +26 -35
- data/lib/lutaml/xml/transformation/custom_method_wrapper.rb +34 -55
- data/lib/lutaml/xml/transformation/rule_applier.rb +1 -1
- data/lib/lutaml/xml/xml_element.rb +24 -20
- data/spec/lutaml/integration/edge_cases_spec.rb +109 -0
- data/spec/lutaml/integration/multi_format_spec.rb +106 -0
- data/spec/lutaml/integration/round_trip_spec.rb +170 -0
- data/spec/lutaml/jsonld/adapter_spec.rb +46 -0
- data/spec/lutaml/jsonld/context_spec.rb +114 -0
- data/spec/lutaml/jsonld/term_definition_spec.rb +55 -0
- data/spec/lutaml/jsonld/transform_spec.rb +211 -0
- data/spec/lutaml/rdf/graph_serialization_spec.rb +137 -0
- data/spec/lutaml/rdf/iri_spec.rb +73 -0
- data/spec/lutaml/rdf/literal_spec.rb +98 -0
- data/spec/lutaml/rdf/mapping_spec.rb +164 -0
- data/spec/lutaml/rdf/member_rule_spec.rb +17 -0
- data/spec/lutaml/rdf/namespace_set_spec.rb +115 -0
- data/spec/lutaml/rdf/namespace_spec.rb +241 -0
- data/spec/lutaml/rdf/rdf_transform_spec.rb +82 -0
- data/spec/lutaml/turtle/adapter_spec.rb +47 -0
- data/spec/lutaml/turtle/mapping_spec.rb +123 -0
- data/spec/lutaml/turtle/transform_spec.rb +273 -0
- data/spec/lutaml/xml/adapter/base_adapter_regression_spec.rb +151 -0
- data/spec/lutaml/xml/adapter/order_spec.rb +150 -0
- data/spec/lutaml/xml/clear_parse_state_spec.rb +139 -0
- data/spec/lutaml/xml/doubly_defined_namespace_spec.rb +0 -2
- data/spec/lutaml/xml/schema/compiler_spec.rb +75 -69
- data/spec/lutaml/xml/transformation/custom_method_wrapper_spec.rb +213 -14
- metadata +58 -3
- data/lib/lutaml/xml/adapter/xml_serialization.rb +0 -145
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c356719b1c0c3434ba1acb3f59be81cb9374403c8020710ee4d4a5ea78748765
|
|
4
|
+
data.tar.gz: ac2aa51ef80ce8db3c50b8055df95b6a3732e3e40b72689c635e8ac22fe889f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b63ac862dc2eeef4a599ff5ada8c6f2434b3bf71187b5813a2637e69f25170692d373bffb2b9413b48323b1cd6161a8529a2ec6582a2fc313d46c95fa8b67088
|
|
7
|
+
data.tar.gz: 24e23bdedad47cc0796cff0bad1b32809c649bad4a13a64b23d08b3bef2dad4c769cfc299cdb85abeffd9a53ea677c41f91c759114f320a5047787cafc6c253e
|
|
@@ -22,3 +22,8 @@ jobs:
|
|
|
22
22
|
uses: metanorma/ci/.github/workflows/dependent-rake.yml@main
|
|
23
23
|
with:
|
|
24
24
|
command: bundle exec rspec
|
|
25
|
+
setup-tools: 'inkscape,ghostscript,exiftool,ffmpeg,imagemagick'
|
|
26
|
+
after-setup-ruby: |
|
|
27
|
+
if [ -f frontend/package.json ]; then cd frontend && npm install && npm run build; fi
|
|
28
|
+
secrets:
|
|
29
|
+
pat_token: ${{ secrets.LUTAML_CI_PAT_TOKEN }}
|
data/.rubocop.yml
CHANGED
|
@@ -24,3 +24,21 @@ Style/OneClassPerFile:
|
|
|
24
24
|
- Exclude
|
|
25
25
|
Exclude:
|
|
26
26
|
- 'spec/**/*'
|
|
27
|
+
|
|
28
|
+
RSpec/EmptyExampleGroup:
|
|
29
|
+
inherit_mode:
|
|
30
|
+
merge:
|
|
31
|
+
- Exclude
|
|
32
|
+
Exclude:
|
|
33
|
+
- 'spec/lutaml/jsonld/transform_spec.rb'
|
|
34
|
+
|
|
35
|
+
RSpec/NamedSubject:
|
|
36
|
+
inherit_mode:
|
|
37
|
+
merge:
|
|
38
|
+
- Exclude
|
|
39
|
+
Exclude:
|
|
40
|
+
- 'spec/lutaml/turtle/transform_spec.rb'
|
|
41
|
+
|
|
42
|
+
RSpec/ContextMethod:
|
|
43
|
+
Exclude:
|
|
44
|
+
- 'spec/lutaml/jsonld/transform_spec.rb'
|
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-
|
|
3
|
+
# on 2026-05-13 07:30:26 UTC using RuboCop version 1.86.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
|
|
@@ -11,13 +11,67 @@ Gemspec/RequiredRubyVersion:
|
|
|
11
11
|
Exclude:
|
|
12
12
|
- 'lutaml-model.gemspec'
|
|
13
13
|
|
|
14
|
-
# Offense count:
|
|
14
|
+
# Offense count: 4
|
|
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/xml/adapter/plan_based_builder.rb'
|
|
21
|
+
- 'lib/lutaml/xml/adapter/xml_parser.rb'
|
|
22
|
+
- 'lib/lutaml/xml/serialization/instance_methods.rb'
|
|
23
|
+
- 'spec/lutaml/xml/schema/compiler_spec.rb'
|
|
24
|
+
|
|
25
|
+
# Offense count: 1
|
|
26
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
27
|
+
# Configuration parameters: IndentationWidth.
|
|
28
|
+
Layout/AssignmentIndentation:
|
|
29
|
+
Exclude:
|
|
30
|
+
- 'lib/lutaml/xml/adapter/xml_serializer.rb'
|
|
31
|
+
|
|
32
|
+
# Offense count: 3
|
|
33
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
34
|
+
# Configuration parameters: EnforcedStyleAlignWith.
|
|
35
|
+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
|
36
|
+
Layout/BlockAlignment:
|
|
37
|
+
Exclude:
|
|
38
|
+
- 'lib/lutaml/xml/serialization/format_conversion.rb'
|
|
39
|
+
- 'lib/lutaml/xml/xml_element.rb'
|
|
40
|
+
|
|
41
|
+
# Offense count: 3
|
|
42
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
43
|
+
Layout/BlockEndNewline:
|
|
44
|
+
Exclude:
|
|
45
|
+
- 'lib/lutaml/xml/serialization/format_conversion.rb'
|
|
46
|
+
- 'lib/lutaml/xml/xml_element.rb'
|
|
47
|
+
|
|
48
|
+
# Offense count: 6
|
|
49
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
50
|
+
# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
|
|
51
|
+
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
|
|
52
|
+
Layout/IndentationWidth:
|
|
53
|
+
Exclude:
|
|
54
|
+
- 'lib/lutaml/xml/serialization/format_conversion.rb'
|
|
55
|
+
- 'lib/lutaml/xml/xml_element.rb'
|
|
56
|
+
|
|
57
|
+
# Offense count: 2981
|
|
15
58
|
# This cop supports safe autocorrection (--autocorrect).
|
|
16
59
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
17
60
|
# URISchemes: http, https
|
|
18
61
|
Layout/LineLength:
|
|
19
62
|
Enabled: false
|
|
20
63
|
|
|
64
|
+
# Offense count: 5
|
|
65
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
66
|
+
# Configuration parameters: AllowInHeredoc.
|
|
67
|
+
Layout/TrailingWhitespace:
|
|
68
|
+
Exclude:
|
|
69
|
+
- 'lib/lutaml/xml/adapter/plan_based_builder.rb'
|
|
70
|
+
- 'lib/lutaml/xml/adapter/xml_parser.rb'
|
|
71
|
+
- 'lib/lutaml/xml/adapter/xml_serializer.rb'
|
|
72
|
+
- 'lib/lutaml/xml/serialization/instance_methods.rb'
|
|
73
|
+
- 'spec/lutaml/xml/schema/compiler_spec.rb'
|
|
74
|
+
|
|
21
75
|
# Offense count: 21
|
|
22
76
|
# Configuration parameters: AllowedMethods.
|
|
23
77
|
# AllowedMethods: enums
|
|
@@ -96,13 +150,12 @@ Lint/StructNewOverride:
|
|
|
96
150
|
Exclude:
|
|
97
151
|
- 'lib/lutaml/model/import_registry.rb'
|
|
98
152
|
|
|
99
|
-
# Offense count:
|
|
153
|
+
# Offense count: 14
|
|
100
154
|
# This cop supports safe autocorrection (--autocorrect).
|
|
101
155
|
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
|
|
102
156
|
# NotImplementedExceptions: NotImplementedError
|
|
103
157
|
Lint/UnusedMethodArgument:
|
|
104
158
|
Exclude:
|
|
105
|
-
- 'lib/lutaml/xml/adapter/nokogiri_adapter.rb'
|
|
106
159
|
- 'lib/lutaml/xml/declaration_planner.rb'
|
|
107
160
|
- 'lib/lutaml/xml/mapping.rb'
|
|
108
161
|
- 'lib/lutaml/xml/namespace_collector.rb'
|
|
@@ -110,45 +163,44 @@ Lint/UnusedMethodArgument:
|
|
|
110
163
|
- 'lib/lutaml/xml/unqualified_inheritance_strategy.rb'
|
|
111
164
|
- 'spec/support/xml/xsd/code_example_validator.rb'
|
|
112
165
|
|
|
113
|
-
# Offense count:
|
|
166
|
+
# Offense count: 1
|
|
114
167
|
Lint/UselessConstantScoping:
|
|
115
168
|
Exclude:
|
|
116
|
-
- 'lib/lutaml/xml/adapter/nokogiri_adapter.rb'
|
|
117
169
|
- 'lib/lutaml/xml/mapping_rule.rb'
|
|
118
170
|
|
|
119
|
-
# Offense count:
|
|
171
|
+
# Offense count: 342
|
|
120
172
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
121
173
|
Metrics/AbcSize:
|
|
122
174
|
Enabled: false
|
|
123
175
|
|
|
124
|
-
# Offense count:
|
|
176
|
+
# Offense count: 39
|
|
125
177
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
|
|
126
178
|
# AllowedMethods: refine
|
|
127
179
|
Metrics/BlockLength:
|
|
128
180
|
Max: 127
|
|
129
181
|
|
|
130
|
-
# Offense count:
|
|
182
|
+
# Offense count: 16
|
|
131
183
|
# Configuration parameters: CountBlocks, CountModifierForms.
|
|
132
184
|
Metrics/BlockNesting:
|
|
133
185
|
Max: 6
|
|
134
186
|
|
|
135
|
-
# Offense count:
|
|
187
|
+
# Offense count: 300
|
|
136
188
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
137
189
|
Metrics/CyclomaticComplexity:
|
|
138
190
|
Enabled: false
|
|
139
191
|
|
|
140
|
-
# Offense count:
|
|
192
|
+
# Offense count: 549
|
|
141
193
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
142
194
|
Metrics/MethodLength:
|
|
143
195
|
Max: 514
|
|
144
196
|
|
|
145
|
-
# Offense count:
|
|
197
|
+
# Offense count: 81
|
|
146
198
|
# Configuration parameters: CountKeywordArgs.
|
|
147
199
|
Metrics/ParameterLists:
|
|
148
200
|
Max: 24
|
|
149
201
|
MaxOptionalParameters: 5
|
|
150
202
|
|
|
151
|
-
# Offense count:
|
|
203
|
+
# Offense count: 251
|
|
152
204
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
153
205
|
Metrics/PerceivedComplexity:
|
|
154
206
|
Enabled: false
|
|
@@ -240,7 +292,7 @@ RSpec/BeforeAfterAll:
|
|
|
240
292
|
RSpec/ContextWording:
|
|
241
293
|
Enabled: false
|
|
242
294
|
|
|
243
|
-
# Offense count:
|
|
295
|
+
# Offense count: 94
|
|
244
296
|
# Configuration parameters: IgnoredMetadata.
|
|
245
297
|
RSpec/DescribeClass:
|
|
246
298
|
Enabled: false
|
|
@@ -251,7 +303,7 @@ RSpec/DescribeMethod:
|
|
|
251
303
|
- 'spec/lutaml/xml/schema/xsd/schema_helper_methods_spec.rb'
|
|
252
304
|
- 'spec/lutaml/xml/serializable_namespace_spec.rb'
|
|
253
305
|
|
|
254
|
-
# Offense count:
|
|
306
|
+
# Offense count: 1238
|
|
255
307
|
# Configuration parameters: CountAsOne.
|
|
256
308
|
RSpec/ExampleLength:
|
|
257
309
|
Max: 68
|
|
@@ -326,7 +378,7 @@ RSpec/MultipleDescribes:
|
|
|
326
378
|
- 'spec/lutaml/xml/namespace_resolution_strategy_spec.rb'
|
|
327
379
|
- 'spec/lutaml/xml/xml_space_type_spec.rb'
|
|
328
380
|
|
|
329
|
-
# Offense count:
|
|
381
|
+
# Offense count: 1468
|
|
330
382
|
RSpec/MultipleExpectations:
|
|
331
383
|
Max: 21
|
|
332
384
|
|
|
@@ -350,7 +402,7 @@ RSpec/NoExpectationExample:
|
|
|
350
402
|
- 'spec/lutaml/model/global_context_spec.rb'
|
|
351
403
|
- 'spec/lutaml/model/type_context_spec.rb'
|
|
352
404
|
|
|
353
|
-
# Offense count:
|
|
405
|
+
# Offense count: 10
|
|
354
406
|
RSpec/RemoveConst:
|
|
355
407
|
Exclude:
|
|
356
408
|
- 'spec/lutaml/xml/schema/compiler_spec.rb'
|
|
@@ -374,7 +426,7 @@ RSpec/RepeatedExampleGroupDescription:
|
|
|
374
426
|
Exclude:
|
|
375
427
|
- 'spec/lutaml/model/mixed_content_spec.rb'
|
|
376
428
|
|
|
377
|
-
# Offense count:
|
|
429
|
+
# Offense count: 40
|
|
378
430
|
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
|
|
379
431
|
# SupportedInflectors: default, active_support
|
|
380
432
|
RSpec/SpecFilePathFormat:
|
|
@@ -399,6 +451,18 @@ Security/MarshalLoad:
|
|
|
399
451
|
Exclude:
|
|
400
452
|
- 'scripts-xmi-profile/profile_xmi.rb'
|
|
401
453
|
|
|
454
|
+
# Offense count: 4
|
|
455
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
456
|
+
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
|
457
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
|
458
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
459
|
+
# FunctionalMethods: let, let!, subject, watch
|
|
460
|
+
# AllowedMethods: lambda, proc, it
|
|
461
|
+
Style/BlockDelimiters:
|
|
462
|
+
Exclude:
|
|
463
|
+
- 'lib/lutaml/xml/serialization/format_conversion.rb'
|
|
464
|
+
- 'lib/lutaml/xml/xml_element.rb'
|
|
465
|
+
|
|
402
466
|
# Offense count: 2
|
|
403
467
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
404
468
|
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
@@ -408,7 +472,7 @@ Style/ClassEqualityComparison:
|
|
|
408
472
|
- 'lib/lutaml/model/attribute.rb'
|
|
409
473
|
- 'lib/lutaml/model/validation/profile.rb'
|
|
410
474
|
|
|
411
|
-
# Offense count:
|
|
475
|
+
# Offense count: 7
|
|
412
476
|
# This cop supports safe autocorrection (--autocorrect).
|
|
413
477
|
# Configuration parameters: EnforcedStyle, AllowComments.
|
|
414
478
|
# SupportedStyles: empty, nil, both
|
|
@@ -417,9 +481,6 @@ Style/EmptyElse:
|
|
|
417
481
|
- 'lib/lutaml/key_value/data_model/element.rb'
|
|
418
482
|
- 'lib/lutaml/key_value/transformation.rb'
|
|
419
483
|
- 'lib/lutaml/model/mapping/mapping_rule.rb'
|
|
420
|
-
- 'lib/lutaml/xml/adapter/nokogiri_adapter.rb'
|
|
421
|
-
- 'lib/lutaml/xml/adapter/oga_adapter.rb'
|
|
422
|
-
- 'lib/lutaml/xml/adapter/ox_adapter.rb'
|
|
423
484
|
- 'lib/lutaml/xml/declaration_planner.rb'
|
|
424
485
|
- 'lib/lutaml/xml/model_transform.rb'
|
|
425
486
|
|
|
@@ -447,6 +508,14 @@ Style/MixinUsage:
|
|
|
447
508
|
- 'bench/bench_unitsml.rb'
|
|
448
509
|
- 'bench/bench_xmi.rb'
|
|
449
510
|
|
|
511
|
+
# Offense count: 3
|
|
512
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
513
|
+
Style/MultilineIfModifier:
|
|
514
|
+
Exclude:
|
|
515
|
+
- 'lib/lutaml/xml/adapter/xml_parser.rb'
|
|
516
|
+
- 'lib/lutaml/xml/adapter/xml_serializer.rb'
|
|
517
|
+
- 'spec/lutaml/xml/schema/compiler_spec.rb'
|
|
518
|
+
|
|
450
519
|
# Offense count: 12
|
|
451
520
|
# Configuration parameters: AllowedClasses.
|
|
452
521
|
Style/OneClassPerFile:
|
data/Gemfile
CHANGED
|
@@ -12,6 +12,7 @@ gem "base64"
|
|
|
12
12
|
gem "benchmark-ips"
|
|
13
13
|
gem "bigdecimal"
|
|
14
14
|
gem "canon" # , path: "../canon"
|
|
15
|
+
gem "json-ld", "~> 3.3"
|
|
15
16
|
gem "liquid", "~> 5"
|
|
16
17
|
gem "multi_json"
|
|
17
18
|
gem "nokogiri"
|
|
@@ -20,6 +21,7 @@ gem "oj"
|
|
|
20
21
|
gem "openssl", "~> 3.0"
|
|
21
22
|
gem "ox"
|
|
22
23
|
gem "rake"
|
|
24
|
+
gem "rdf-turtle", "~> 3.3"
|
|
23
25
|
gem "rexml"
|
|
24
26
|
gem "rspec"
|
|
25
27
|
gem "rubocop"
|
data/README.adoc
CHANGED
|
@@ -27,7 +27,7 @@ for:
|
|
|
27
27
|
|
|
28
28
|
It provides simple, flexible and comprehensive mechanisms for defining
|
|
29
29
|
information models with attributes and types, and the serialization of them
|
|
30
|
-
to/from serialization formats including JSON, XML, YAML, and
|
|
30
|
+
to/from serialization formats including JSON, XML, YAML, TOML, JSON-LD, and Turtle, as well as
|
|
31
31
|
transformation to other formats like Hash.
|
|
32
32
|
|
|
33
33
|
For serialization formats, it uses an adapter pattern to support multiple
|
|
@@ -48,7 +48,7 @@ link:docs/migration-guides/0-1-0-migrate-from-shale.adoc[Migrating from Shale to
|
|
|
48
48
|
== Features
|
|
49
49
|
|
|
50
50
|
* Define models with attributes and types
|
|
51
|
-
* Serialize and deserialize models to/from JSON, XML, YAML, and
|
|
51
|
+
* Serialize and deserialize models to/from JSON, XML, YAML, TOML, JSON-LD, and Turtle
|
|
52
52
|
* Transform models to other formats like Hash
|
|
53
53
|
* Support for multiple serialization libraries (e.g., `toml-rb`, `tomlib`)
|
|
54
54
|
* Configurable adapters for different serialization formats
|
|
@@ -65,6 +65,7 @@ link:docs/migration-guides/0-1-0-migrate-from-shale.adoc[Migrating from Shale to
|
|
|
65
65
|
* Symmetric OOP architecture for all formats with KeyValueDataModel (see <<keyvaluedatamodel-architecture>>)
|
|
66
66
|
* Parse XSD schemas into Ruby objects for inspection and manipulation (see <<xsd-schema-parsing>>)
|
|
67
67
|
* Reusable XML mapping classes for sharing mappings across models
|
|
68
|
+
* RDF namespace classes and JSON-LD/Turtle format adapters for Linked Data serialization
|
|
68
69
|
* Consolidation mapping: group sibling XML elements into structured model instances (see <<consolidation-mapping>>)
|
|
69
70
|
* Document-level validation framework with composable rules, profiles, and remediation (see <<document-validation-framework>>)
|
|
70
71
|
|
|
@@ -5391,6 +5392,11 @@ Collection serialization formats::
|
|
|
5391
5392
|
`jsonl`::: JSONL (JSON Lines) (see <<mapping-collections>>)
|
|
5392
5393
|
`yamls`::: YAML Stream (multi-document format) (see <<mapping-collections>>)
|
|
5393
5394
|
|
|
5395
|
+
RDF serialization formats::
|
|
5396
|
+
|
|
5397
|
+
`rdf`::: Unified RDF mapping for both JSON-LD and Turtle (see <<mapping-rdf>>)
|
|
5398
|
+
`turtle`::: Turtle (see link:docs/_guides/turtle-serialization.adoc[Turtle Serialization])
|
|
5399
|
+
|
|
5394
5400
|
|
|
5395
5401
|
.Using the `xml`, `hsh`, `json`, `yaml`, `toml` and `key_value` blocks to define serialization mappings
|
|
5396
5402
|
[example]
|
|
@@ -5439,6 +5445,73 @@ end
|
|
|
5439
5445
|
====
|
|
5440
5446
|
|
|
5441
5447
|
|
|
5448
|
+
[[mapping-rdf]]
|
|
5449
|
+
=== Unified RDF mapping (`rdf`)
|
|
5450
|
+
|
|
5451
|
+
The `rdf` block defines predicate-based mappings once for both JSON-LD and
|
|
5452
|
+
Turtle serialization. It follows the same unified-mapping principle as
|
|
5453
|
+
`key_value` (which serves JSON, YAML, TOML).
|
|
5454
|
+
|
|
5455
|
+
.Using the `rdf` block to define unified RDF mappings
|
|
5456
|
+
[example]
|
|
5457
|
+
====
|
|
5458
|
+
[source,ruby]
|
|
5459
|
+
----
|
|
5460
|
+
class Concept < Lutaml::Model::Serializable
|
|
5461
|
+
attribute :code, :string
|
|
5462
|
+
attribute :name, :string
|
|
5463
|
+
|
|
5464
|
+
rdf do
|
|
5465
|
+
namespace SkosNamespace
|
|
5466
|
+
|
|
5467
|
+
subject { |m| "http://example.org/concept/#{m.code}" }
|
|
5468
|
+
type "skos:Concept"
|
|
5469
|
+
|
|
5470
|
+
predicate :notation, namespace: SkosNamespace, to: :code
|
|
5471
|
+
predicate :prefLabel, namespace: SkosNamespace, to: :name
|
|
5472
|
+
end
|
|
5473
|
+
end
|
|
5474
|
+
----
|
|
5475
|
+
|
|
5476
|
+
Serializes to both formats:
|
|
5477
|
+
|
|
5478
|
+
[source,ruby]
|
|
5479
|
+
----
|
|
5480
|
+
concept = Concept.new(code: "2119", name: "component")
|
|
5481
|
+
concept.to_turtle # => Turtle with @prefix, a skos:Concept, predicates
|
|
5482
|
+
concept.to_jsonld # => JSON-LD with @context, @type, @id, properties
|
|
5483
|
+
----
|
|
5484
|
+
====
|
|
5485
|
+
|
|
5486
|
+
Graph-level serialization uses `members` to emit all contained resources as
|
|
5487
|
+
separate subjects in the same document:
|
|
5488
|
+
|
|
5489
|
+
[source,ruby]
|
|
5490
|
+
----
|
|
5491
|
+
class Vocabulary < Lutaml::Model::Serializable
|
|
5492
|
+
attribute :id, :string
|
|
5493
|
+
attribute :concepts, Concept, collection: true
|
|
5494
|
+
|
|
5495
|
+
rdf do
|
|
5496
|
+
namespace SkosNamespace
|
|
5497
|
+
subject { |v| "http://example.org/vocab/#{v.id}" }
|
|
5498
|
+
type "skos:ConceptScheme"
|
|
5499
|
+
predicate :prefLabel, namespace: SkosNamespace, to: :id
|
|
5500
|
+
members :concepts
|
|
5501
|
+
end
|
|
5502
|
+
end
|
|
5503
|
+
|
|
5504
|
+
# Turtle: single document with ConceptScheme + all Concept triples
|
|
5505
|
+
# JSON-LD: @graph array with ConceptScheme + all Concept objects
|
|
5506
|
+
vocab.to_turtle
|
|
5507
|
+
vocab.to_jsonld
|
|
5508
|
+
----
|
|
5509
|
+
|
|
5510
|
+
See link:docs/_guides/rdf-serialization.adoc[Unified RDF Serialization] for the
|
|
5511
|
+
complete guide including language-tagged values, graph serialization, and
|
|
5512
|
+
architecture details.
|
|
5513
|
+
|
|
5514
|
+
|
|
5442
5515
|
== Serialization: XML
|
|
5443
5516
|
|
|
5444
5517
|
=== General
|
|
@@ -10100,8 +10173,14 @@ Key-value data models supported are identified by their short name:
|
|
|
10100
10173
|
`json`:: JSON
|
|
10101
10174
|
`yaml`:: YAML
|
|
10102
10175
|
`toml`:: TOML
|
|
10176
|
+
`jsonld`:: JSON-LD (extends key-value with `@context`, `@type`, `@id`)
|
|
10103
10177
|
`key_value`:: A way to configure key-value mappings for all supported key-value data models.
|
|
10104
10178
|
|
|
10179
|
+
RDF serialization formats::
|
|
10180
|
+
|
|
10181
|
+
`rdf`:: Unified RDF mapping for both JSON-LD and Turtle (see <<mapping-rdf>>)
|
|
10182
|
+
`turtle`:: Turtle (see link:docs/_guides/turtle-serialization.adoc[Turtle Serialization])
|
|
10183
|
+
|
|
10105
10184
|
|
|
10106
10185
|
=== Mapping
|
|
10107
10186
|
|
|
@@ -15735,6 +15814,8 @@ LutaML, out of the box, supports the following serialization formats:
|
|
|
15735
15814
|
* YAML (https://yaml.org/[YAML version 1.2])
|
|
15736
15815
|
* JSON (https://www.ecma-international.org/publications-and-standards/standards/ecma-404/[ECMA-404 The JSON Data Interchange Standard], unofficial link: https://www.json.org[JSON])
|
|
15737
15816
|
* TOML (https://toml.io/en[TOML version 1.0])
|
|
15817
|
+
* JSON-LD (https://www.w3.org/TR/json-ld11/[W3C JSON-LD 1.1])
|
|
15818
|
+
* Turtle (https://www.w3.org/TR/turtle/[W3C RDF 1.1 Turtle])
|
|
15738
15819
|
|
|
15739
15820
|
The adapter interface is also used to support certain transformation of models
|
|
15740
15821
|
into an "end format", which is not a serialization format. For example, the
|
|
@@ -15977,6 +16058,37 @@ end
|
|
|
15977
16058
|
----
|
|
15978
16059
|
|
|
15979
16060
|
|
|
16061
|
+
=== JSON-LD
|
|
16062
|
+
|
|
16063
|
+
Lutaml::Model supports serialization to and from JSON-LD (W3C JSON-LD 1.1).
|
|
16064
|
+
JSON-LD is a key-value format that extends JSON with `@context`, `@type`, and
|
|
16065
|
+
`@id`. No additional gem is required beyond `lutaml-model`.
|
|
16066
|
+
|
|
16067
|
+
For unified RDF mapping (both JSON-LD and Turtle from a single `rdf` block), see
|
|
16068
|
+
link:docs/_guides/rdf-serialization.adoc[Unified RDF Serialization].
|
|
16069
|
+
|
|
16070
|
+
See link:docs/_guides/jsonld-serialization.adoc[JSON-LD Serialization] for the
|
|
16071
|
+
legacy `jsonld do` block DSL and usage examples.
|
|
16072
|
+
|
|
16073
|
+
|
|
16074
|
+
=== Turtle
|
|
16075
|
+
|
|
16076
|
+
Lutaml::Model supports serialization to and from W3C RDF Turtle format.
|
|
16077
|
+
Turtle is a non-key-value format based on RDF triples. Requires the
|
|
16078
|
+
`rdf-turtle` gem:
|
|
16079
|
+
|
|
16080
|
+
[source,ruby]
|
|
16081
|
+
----
|
|
16082
|
+
gem "rdf-turtle", "~> 3.3"
|
|
16083
|
+
----
|
|
16084
|
+
|
|
16085
|
+
For unified RDF mapping (both JSON-LD and Turtle from a single `rdf` block), see
|
|
16086
|
+
link:docs/_guides/rdf-serialization.adoc[Unified RDF Serialization].
|
|
16087
|
+
|
|
16088
|
+
See link:docs/_guides/turtle-serialization.adoc[Turtle Serialization] for the
|
|
16089
|
+
legacy `turtle do` block DSL and usage examples.
|
|
16090
|
+
|
|
16091
|
+
|
|
15980
16092
|
=== Per-operation adapter override
|
|
15981
16093
|
|
|
15982
16094
|
Override the adapter for a single serialization/deserialization call using the `adapter:` option:
|
data/docs/_guides/index.adoc
CHANGED
|
@@ -22,6 +22,17 @@ Task-oriented guides for accomplishing specific goals with Lutaml::Model.
|
|
|
22
22
|
* link:../keyvalue-serialization[Key-Value Serialization] - JSON/YAML/TOML/Hash
|
|
23
23
|
* link:../collection-serialization[Collection Serialization] - JSONL and YAML Stream
|
|
24
24
|
|
|
25
|
+
== Linked Data serialization
|
|
26
|
+
|
|
27
|
+
* link:../rdf-serialization[Unified RDF Serialization] - One `rdf` block for both JSON-LD and Turtle
|
|
28
|
+
* link:../jsonld-serialization[JSON-LD Serialization] - W3C JSON-LD 1.1 with `@context`
|
|
29
|
+
* link:../turtle-serialization[Turtle Serialization] - W3C RDF Turtle format
|
|
30
|
+
|
|
31
|
+
== RDF infrastructure
|
|
32
|
+
|
|
33
|
+
See link:../references/rdf-namespaces[RDF Namespaces] for namespace classes,
|
|
34
|
+
`NamespaceSet`, `Iri`, and `Literal` value objects.
|
|
35
|
+
|
|
25
36
|
== Advanced features
|
|
26
37
|
|
|
27
38
|
* link:../value-transformations[Value Transformations] - Transform values during serialization
|
|
@@ -49,6 +60,13 @@ Task-oriented guides for accomplishing specific goals with Lutaml::Model.
|
|
|
49
60
|
. link:../value-transformations[Transform values if needed]
|
|
50
61
|
. link:../missing-values-handling[Handle nil/empty values]
|
|
51
62
|
|
|
63
|
+
=== I want to serialize to JSON-LD or Turtle (Linked Data)
|
|
64
|
+
|
|
65
|
+
. link:../rdf-serialization[Unified RDF Serialization] (recommended — one block for both formats)
|
|
66
|
+
. link:../jsonld-serialization[JSON-LD Serialization guide] (legacy `jsonld do` block)
|
|
67
|
+
. link:../turtle-serialization[Turtle Serialization guide] (legacy `turtle do` block)
|
|
68
|
+
. link:../references/rdf-namespaces[RDF Namespaces reference]
|
|
69
|
+
|
|
52
70
|
=== I want to work with collections
|
|
53
71
|
|
|
54
72
|
. link:../collection-serialization[Collection Serialization]
|