metanorma-plugin-lutaml 0.7.40 → 0.7.41
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/.gitignore +3 -0
- data/.rubocop_todo.yml +50 -50
- data/Gemfile +0 -1
- data/lib/metanorma/plugin/lutaml/base_preprocessor.rb +13 -9
- data/lib/metanorma/plugin/lutaml/lutaml_xsd_preprocessor.rb +54 -0
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- data/metanorma-plugin-lutaml.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4ce6ee99ec2b2d8f9d9457bc9dfec664df395b369cb506bfd2654ef197ce1454
|
|
4
|
+
data.tar.gz: 8f0d7030ae6087cc263bce330516a5125c6598bef022bdaee98d5169c8c95880
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 93a97b590a75c6e74e2bb36822b50813cbc9329a5f183e4117fd79a4e063a9d54cc3c4334886844fb87172fb653c137ffa24df793fa384851e652ff8f1d414fa
|
|
7
|
+
data.tar.gz: d35c301506861ec62b1bbb18c59a99cf2c5d011dec4cb4f878387a96543227b7bb0ee5ee77b1a7d3751a1c3f6c68afe2272cb5b2219ec957f42c429ed3bcad6e
|
data/.gitignore
CHANGED
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 23:15:25 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
|
|
@@ -12,75 +12,67 @@ Gemspec/RequireMFA:
|
|
|
12
12
|
Exclude:
|
|
13
13
|
- 'metanorma-plugin-lutaml.gemspec'
|
|
14
14
|
|
|
15
|
-
# Offense count:
|
|
15
|
+
# Offense count: 4
|
|
16
16
|
# This cop supports safe autocorrection (--autocorrect).
|
|
17
17
|
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
18
18
|
# SupportedStyles: with_first_argument, with_fixed_indentation
|
|
19
19
|
Layout/ArgumentAlignment:
|
|
20
20
|
Exclude:
|
|
21
|
-
- '
|
|
21
|
+
- 'spec/regen_expected.rb'
|
|
22
|
+
- 'spec/regen_expected_spec.rb'
|
|
22
23
|
|
|
23
24
|
# Offense count: 1
|
|
24
25
|
# This cop supports safe autocorrection (--autocorrect).
|
|
25
|
-
|
|
26
|
+
# Configuration parameters: IndentationWidth.
|
|
27
|
+
Layout/AssignmentIndentation:
|
|
26
28
|
Exclude:
|
|
27
|
-
- 'lib/metanorma/plugin/lutaml/
|
|
29
|
+
- 'lib/metanorma/plugin/lutaml/base_preprocessor.rb'
|
|
28
30
|
|
|
29
|
-
# Offense count:
|
|
31
|
+
# Offense count: 2
|
|
30
32
|
# This cop supports safe autocorrection (--autocorrect).
|
|
31
33
|
Layout/EmptyLines:
|
|
32
34
|
Exclude:
|
|
33
|
-
- '
|
|
34
|
-
|
|
35
|
-
# Offense count: 1
|
|
36
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
37
|
-
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
38
|
-
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
|
39
|
-
Layout/FirstArgumentIndentation:
|
|
40
|
-
Exclude:
|
|
41
|
-
- 'lib/metanorma/plugin/lutaml/lutaml_ea_xmi_base.rb'
|
|
35
|
+
- 'spec/regen_expected.rb'
|
|
42
36
|
|
|
43
|
-
# Offense count:
|
|
37
|
+
# Offense count: 12
|
|
44
38
|
# This cop supports safe autocorrection (--autocorrect).
|
|
45
39
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
46
40
|
# URISchemes: http, https
|
|
47
41
|
Layout/LineLength:
|
|
48
42
|
Exclude:
|
|
49
43
|
- 'Rakefile'
|
|
44
|
+
- 'lib/metanorma/plugin/lutaml/base_preprocessor.rb'
|
|
50
45
|
- 'lib/metanorma/plugin/lutaml/lutaml_ea_xmi_base.rb'
|
|
51
|
-
- 'lib/metanorma/plugin/lutaml/lutaml_klass_table_block_macro.rb'
|
|
52
46
|
- 'lib/metanorma/plugin/lutaml/utils.rb'
|
|
53
47
|
- 'spec/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor_spec.rb'
|
|
48
|
+
- 'spec/metanorma/plugin/lutaml/lutaml_xsd_preprocessor_spec.rb'
|
|
49
|
+
- 'spec/regen_expected.rb'
|
|
50
|
+
- 'spec/regen_expected_spec.rb'
|
|
54
51
|
- 'spec/support/shared_examples/structured_data_2_text_preprocessor.rb'
|
|
55
52
|
|
|
56
|
-
# Offense count:
|
|
53
|
+
# Offense count: 2
|
|
57
54
|
# This cop supports safe autocorrection (--autocorrect).
|
|
58
55
|
# Configuration parameters: EnforcedStyle.
|
|
59
|
-
# SupportedStyles:
|
|
60
|
-
Layout/
|
|
56
|
+
# SupportedStyles: final_newline, final_blank_line
|
|
57
|
+
Layout/TrailingEmptyLines:
|
|
61
58
|
Exclude:
|
|
62
|
-
- '
|
|
59
|
+
- 'Gemfile'
|
|
60
|
+
- 'spec/regen_expected.rb'
|
|
63
61
|
|
|
64
|
-
# Offense count:
|
|
62
|
+
# Offense count: 5
|
|
65
63
|
# This cop supports safe autocorrection (--autocorrect).
|
|
66
64
|
# Configuration parameters: AllowInHeredoc.
|
|
67
65
|
Layout/TrailingWhitespace:
|
|
68
66
|
Exclude:
|
|
69
|
-
- 'lib/metanorma/plugin/lutaml/
|
|
70
|
-
- '
|
|
67
|
+
- 'lib/metanorma/plugin/lutaml/base_preprocessor.rb'
|
|
68
|
+
- 'spec/regen_expected.rb'
|
|
69
|
+
- 'spec/regen_expected_spec.rb'
|
|
71
70
|
|
|
72
|
-
# Offense count:
|
|
73
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
74
|
-
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
|
|
75
|
-
# NotImplementedExceptions: NotImplementedError
|
|
76
|
-
Lint/UnusedMethodArgument:
|
|
77
|
-
Exclude:
|
|
78
|
-
- 'lib/metanorma/plugin/lutaml/lutaml_ea_xmi_base.rb'
|
|
79
|
-
|
|
80
|
-
# Offense count: 1
|
|
71
|
+
# Offense count: 2
|
|
81
72
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
82
73
|
Metrics/AbcSize:
|
|
83
74
|
Exclude:
|
|
75
|
+
- 'lib/metanorma/plugin/lutaml/lutaml_xsd_preprocessor.rb'
|
|
84
76
|
- 'lib/metanorma/plugin/lutaml/utils.rb'
|
|
85
77
|
|
|
86
78
|
# Offense count: 2
|
|
@@ -90,7 +82,7 @@ Metrics/CyclomaticComplexity:
|
|
|
90
82
|
- 'lib/metanorma/plugin/lutaml/lutaml_ea_xmi_base.rb'
|
|
91
83
|
- 'lib/metanorma/plugin/lutaml/utils.rb'
|
|
92
84
|
|
|
93
|
-
# Offense count:
|
|
85
|
+
# Offense count: 7
|
|
94
86
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
95
87
|
Metrics/MethodLength:
|
|
96
88
|
Max: 19
|
|
@@ -118,12 +110,6 @@ Naming/PredicateMethod:
|
|
|
118
110
|
- 'lib/metanorma/plugin/lutaml/asciidoctor/preprocessor.rb'
|
|
119
111
|
- 'lib/metanorma/plugin/lutaml/liquid/custom_filters/file_exist.rb'
|
|
120
112
|
|
|
121
|
-
# Offense count: 1
|
|
122
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
123
|
-
Performance/AncestorsInclude:
|
|
124
|
-
Exclude:
|
|
125
|
-
- 'lib/metanorma/plugin/lutaml/utils.rb'
|
|
126
|
-
|
|
127
113
|
# Offense count: 86
|
|
128
114
|
# Configuration parameters: Prefixes, AllowedPatterns.
|
|
129
115
|
# Prefixes: when, with, without
|
|
@@ -141,10 +127,16 @@ RSpec/ContextWording:
|
|
|
141
127
|
- 'spec/metanorma/plugin/lutaml/macros_data2text_spec.rb'
|
|
142
128
|
- 'spec/support/shared_examples/structured_data_2_text_preprocessor.rb'
|
|
143
129
|
|
|
144
|
-
# Offense count:
|
|
130
|
+
# Offense count: 1
|
|
131
|
+
# Configuration parameters: IgnoredMetadata.
|
|
132
|
+
RSpec/DescribeClass:
|
|
133
|
+
Exclude:
|
|
134
|
+
- 'spec/regen_expected_spec.rb'
|
|
135
|
+
|
|
136
|
+
# Offense count: 40
|
|
145
137
|
# Configuration parameters: CountAsOne.
|
|
146
138
|
RSpec/ExampleLength:
|
|
147
|
-
Max:
|
|
139
|
+
Max: 38
|
|
148
140
|
|
|
149
141
|
# Offense count: 13
|
|
150
142
|
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
|
|
@@ -169,11 +161,11 @@ RSpec/LeakyLocalVariable:
|
|
|
169
161
|
- 'spec/metanorma/plugin/lutaml/lutaml_uml_datamodel_description_preprocessor_spec.rb'
|
|
170
162
|
- 'spec/metanorma/plugin/lutaml/lutaml_xmi_index_spec.rb'
|
|
171
163
|
|
|
172
|
-
# Offense count:
|
|
164
|
+
# Offense count: 16
|
|
173
165
|
RSpec/MultipleExpectations:
|
|
174
166
|
Max: 6
|
|
175
167
|
|
|
176
|
-
# Offense count:
|
|
168
|
+
# Offense count: 15
|
|
177
169
|
# Configuration parameters: AllowSubject.
|
|
178
170
|
RSpec/MultipleMemoizedHelpers:
|
|
179
171
|
Max: 8
|
|
@@ -191,11 +183,17 @@ RSpec/NamedSubject:
|
|
|
191
183
|
- 'spec/metanorma/plugin/lutaml/lutaml_xmi_index_spec.rb'
|
|
192
184
|
- 'spec/metanorma/plugin/lutaml/source_extractor_spec.rb'
|
|
193
185
|
|
|
194
|
-
# Offense count:
|
|
186
|
+
# Offense count: 124
|
|
195
187
|
# Configuration parameters: AllowedGroups.
|
|
196
188
|
RSpec/NestedGroups:
|
|
197
189
|
Max: 7
|
|
198
190
|
|
|
191
|
+
# Offense count: 3
|
|
192
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
193
|
+
RSpec/Output:
|
|
194
|
+
Exclude:
|
|
195
|
+
- 'spec/regen_expected.rb'
|
|
196
|
+
|
|
199
197
|
# Offense count: 1
|
|
200
198
|
RSpec/PendingWithoutReason:
|
|
201
199
|
Exclude:
|
|
@@ -225,14 +223,16 @@ RSpec/SubjectDeclaration:
|
|
|
225
223
|
|
|
226
224
|
# Offense count: 1
|
|
227
225
|
# This cop supports safe autocorrection (--autocorrect).
|
|
228
|
-
|
|
226
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
|
227
|
+
# SupportedStyles: single_quotes, double_quotes
|
|
228
|
+
Style/StringLiterals:
|
|
229
229
|
Exclude:
|
|
230
|
-
- '
|
|
230
|
+
- 'metanorma-plugin-lutaml.gemspec'
|
|
231
231
|
|
|
232
232
|
# Offense count: 1
|
|
233
233
|
# This cop supports safe autocorrection (--autocorrect).
|
|
234
|
-
# Configuration parameters: EnforcedStyle
|
|
234
|
+
# Configuration parameters: EnforcedStyle.
|
|
235
235
|
# SupportedStyles: single_quotes, double_quotes
|
|
236
|
-
Style/
|
|
236
|
+
Style/StringLiteralsInInterpolation:
|
|
237
237
|
Exclude:
|
|
238
|
-
- 'metanorma
|
|
238
|
+
- 'spec/metanorma/plugin/lutaml/lutaml_xsd_preprocessor_spec.rb'
|
data/Gemfile
CHANGED
|
@@ -24,6 +24,8 @@ module Metanorma
|
|
|
24
24
|
class BasePreprocessor < ::Asciidoctor::Extensions::Preprocessor
|
|
25
25
|
include Utils
|
|
26
26
|
|
|
27
|
+
FILE_SYSTEM_PATTERNS = ["%s.liquid", "_%s.liquid", "_%s.adoc"].freeze
|
|
28
|
+
|
|
27
29
|
def process(document, reader)
|
|
28
30
|
input_lines = Asciidoctor::PreprocessorNoIfdefsReader
|
|
29
31
|
.new(document, reader.lines).readlines.to_enum
|
|
@@ -75,6 +77,15 @@ module Metanorma
|
|
|
75
77
|
"please specify the full path."
|
|
76
78
|
end
|
|
77
79
|
|
|
80
|
+
def build_file_system(document, options)
|
|
81
|
+
include_paths = [Utils.relative_file_path(document, "")]
|
|
82
|
+
options["include_path"]&.split(",")&.each do |path|
|
|
83
|
+
include_paths.push(Utils.relative_file_path(document, path))
|
|
84
|
+
end
|
|
85
|
+
::Metanorma::Plugin::Lutaml::Liquid::LocalFileSystem
|
|
86
|
+
.new(include_paths, FILE_SYSTEM_PATTERNS)
|
|
87
|
+
end
|
|
88
|
+
|
|
78
89
|
private
|
|
79
90
|
|
|
80
91
|
def process_input_lines(document:, input_lines:, express_indexes:)
|
|
@@ -151,16 +162,9 @@ module Metanorma
|
|
|
151
162
|
options: options.merge("document" => document)
|
|
152
163
|
)
|
|
153
164
|
|
|
154
|
-
include_paths = [Utils.relative_file_path(document, "")]
|
|
155
|
-
options["include_path"]&.split(",")&.each do |path|
|
|
156
|
-
include_paths.push(Utils.relative_file_path(document, path))
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
file_system = ::Metanorma::Plugin::Lutaml::Liquid::LocalFileSystem
|
|
160
|
-
.new(include_paths, ["%s.liquid", "_%s.liquid", "_%s.adoc"])
|
|
161
|
-
|
|
162
165
|
parsed_template = template(lines)
|
|
163
|
-
parsed_template.registers[:file_system] =
|
|
166
|
+
parsed_template.registers[:file_system] =
|
|
167
|
+
build_file_system(document, options)
|
|
164
168
|
|
|
165
169
|
all_items.map do |item|
|
|
166
170
|
parsed_template.assigns[context_name] = item[:liquid_drop]
|
|
@@ -9,6 +9,10 @@ module Metanorma
|
|
|
9
9
|
# lutaml-model's XSD parser and exposes the schema object to Liquid
|
|
10
10
|
# templates.
|
|
11
11
|
#
|
|
12
|
+
# Two syntaxes are supported:
|
|
13
|
+
# Block: [lutaml_xsd, path, context, options] .... ----
|
|
14
|
+
# Direct: lutaml_xsd::path[context, template, options]
|
|
15
|
+
#
|
|
12
16
|
# Caching: parsed XSD results are cached at two levels:
|
|
13
17
|
# - Class-level (@@xsd_cache) persists across document invocations
|
|
14
18
|
# - Document-level (document.attributes["lutaml_xsd_cache"]) within a
|
|
@@ -26,6 +30,19 @@ module Metanorma
|
|
|
26
30
|
\] # Closing bracket
|
|
27
31
|
}x
|
|
28
32
|
|
|
33
|
+
XSD_DIRECT_REGEX = %r{
|
|
34
|
+
^\s* # Start of line
|
|
35
|
+
lutaml_xsd:: # Macro prefix
|
|
36
|
+
(?<file_path>[^\[]+?) # XSD file path
|
|
37
|
+
\[ # Opening bracket
|
|
38
|
+
(?<context_name>[^,]+) # Context name
|
|
39
|
+
,\s* # Comma separator
|
|
40
|
+
(?<template>[^,\]]+) # Template file path
|
|
41
|
+
(?<options>,[^\]]+)? # Optional options
|
|
42
|
+
\] # Closing bracket
|
|
43
|
+
\s*$ # End of line
|
|
44
|
+
}x
|
|
45
|
+
|
|
29
46
|
def initialize(_config = {})
|
|
30
47
|
super
|
|
31
48
|
@@xsd_cache ||= {}
|
|
@@ -71,6 +88,43 @@ module Metanorma
|
|
|
71
88
|
|
|
72
89
|
private
|
|
73
90
|
|
|
91
|
+
def process_text_blocks(document, input_lines, express_indexes)
|
|
92
|
+
match = xsd_direct?(input_lines.peek)
|
|
93
|
+
return handle_direct_block(document, input_lines, match) if match
|
|
94
|
+
|
|
95
|
+
super
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def xsd_direct?(line)
|
|
99
|
+
line.match(XSD_DIRECT_REGEX)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def handle_direct_block(document, input_lines, match)
|
|
103
|
+
input_lines.next # consume the matched line
|
|
104
|
+
|
|
105
|
+
file_path = match[:file_path].strip
|
|
106
|
+
context_name = match[:context_name].strip
|
|
107
|
+
template_file = Utils.relative_file_path(document,
|
|
108
|
+
match[:template].strip)
|
|
109
|
+
options = match[:options] ? parse_options(match[:options].strip) : {}
|
|
110
|
+
|
|
111
|
+
schema = load_lutaml_file(document, file_path, options)
|
|
112
|
+
schema_drop = update_repo(options, schema).to_liquid
|
|
113
|
+
|
|
114
|
+
template_source = File.read(template_file, encoding: "UTF-8")
|
|
115
|
+
tmpl = template([template_source])
|
|
116
|
+
tmpl.registers[:file_system] = build_file_system(document, options)
|
|
117
|
+
tmpl.assigns[context_name] = schema_drop
|
|
118
|
+
|
|
119
|
+
tmpl.render.split("\n", -1)
|
|
120
|
+
rescue StandardError => e
|
|
121
|
+
::Metanorma::Util.log(
|
|
122
|
+
"[#{self.class.name}] Failed to parse LutaML block: #{e.message}",
|
|
123
|
+
:error,
|
|
124
|
+
)
|
|
125
|
+
raise e
|
|
126
|
+
end
|
|
127
|
+
|
|
74
128
|
def parse_xsd_file(full_path, location)
|
|
75
129
|
File.open(full_path, "r:UTF-8") do |file|
|
|
76
130
|
::Lutaml::Xml::Parsers::Xsd.parse(file, location: location)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-plugin-lutaml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.41
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|
|
@@ -240,7 +240,7 @@ homepage: https://github.com/metanorma/metanorma-plugin-lutaml
|
|
|
240
240
|
licenses:
|
|
241
241
|
- BSD-2-Clause
|
|
242
242
|
metadata:
|
|
243
|
-
rubygems_mfa_required: '
|
|
243
|
+
rubygems_mfa_required: 'true'
|
|
244
244
|
post_install_message:
|
|
245
245
|
rdoc_options: []
|
|
246
246
|
require_paths:
|