metanorma-plugin-lutaml 0.6.0 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e9b3ce23d274ff457c34d3c5a9e2bf73d12d8cd4de898a061f6a3522bb45439
4
- data.tar.gz: 79a063b985b79fa7b835bbc73acd0ada7761c496f058bcfc8d455882cb6d95ea
3
+ metadata.gz: 19d2399f31818f5f72d0f6237199042a1b729457039c033e5a45d29645b56eda
4
+ data.tar.gz: 0a3a779c6e6b556c7597fc2f9fc708565fb3e0841969eccc855334fcf9e98a88
5
5
  SHA512:
6
- metadata.gz: 20896ef23b4b4a2258e3803a9d07bca26778f495aa57dfdd5bcd878ac6db1c09d139a066b7e6dde086e25b1c4a77b74266ae7f51f251613c783a4be7d38771da
7
- data.tar.gz: b10b0ce496d8ac08e4cd83d85065c94292f4846dcaf27544fdc122fba228c9303395076d42e2fd5eecc12090f16faeb564b0300c7bc40ea37f3648dae433ec25
6
+ metadata.gz: a03c8868605097a556281eae23b1f2a9b40f3991e7f7304c0f70ef2d3f8e8477fbd69389c2c49482b0774b729dbb02a8bbb39f3949b7453a5542e4a957c4a70e
7
+ data.tar.gz: 1001f84dc00d0430552d89f63525af328fa1d2fec6143ce7fbf5c49764f83f5d27b0673d4c57756514498236eb91857cadaf981400097e2d1556f8a554d962c1
data/README.adoc CHANGED
@@ -28,9 +28,9 @@ LutaML supports accessing EXPRESS models via the
28
28
  https://github.com/lutaml/expressir[Expressir] parser.
29
29
 
30
30
 
31
- === Usage of the `lutaml` macro
31
+ === Usage of the `lutaml` command
32
32
 
33
- Given an `example.exp` EXPRESS file with the content:
33
+ Given an `example.exp` EXPRESS file with content:
34
34
 
35
35
  [source,exp]
36
36
  ----
@@ -57,7 +57,7 @@ SCHEMA test_schema 'test';
57
57
  END_SCHEMA;
58
58
  ----
59
59
 
60
- And the `lutaml` macro block:
60
+ And the `lutaml` block:
61
61
 
62
62
  [source,adoc]
63
63
  -----
@@ -137,6 +137,7 @@ Example of usage:
137
137
  = Document title
138
138
  Author
139
139
  :lutaml-express-index: index_name; /path/to/express_files; cache=/path/to/cache_file.yaml
140
+
140
141
  [lutaml,index_name,context]
141
142
  ----
142
143
  {% for schema in context.schemas %}
@@ -145,6 +146,64 @@ Author
145
146
  ----
146
147
  -----
147
148
 
149
+ === Using `config.yaml`
150
+
151
+ This functionality allows `[lutaml_express]` blocks to load a full set of
152
+ EXPRESS schemas in one index, and then provide a select ("filter") option
153
+ per-block via a separate YAML file.
154
+
155
+ [source,adoc]
156
+ ----
157
+ :lutaml-express-index: schemas_1; schemas_all.yaml;
158
+
159
+ [lutaml_express,schemas_1,repo,leveloffset=+1,config_yaml=select.yaml]
160
+ ---
161
+ {% assign selected = repo.schemas | where: "selected" %}
162
+ {% render "templates/resources/schema" for selected as schema %}
163
+ ---
164
+ ----
165
+
166
+ Where `schemas_all.yml` provides all schemas:
167
+
168
+ [source,yaml]
169
+ ----
170
+ ---
171
+ schemas:
172
+ action_schema:
173
+ path: "../../schemas/resources/action_schema/action_schema.exp"
174
+ application_context_schema:
175
+ path: "../../schemas/resources/application_context_schema/application_context_schema.exp"
176
+ approval_schema:
177
+ path: "../../schemas/resources/approval_schema/approval_schema.exp"
178
+ ...
179
+ ----
180
+
181
+ And `select.yaml` only selects 2 schemas:
182
+
183
+ [source,yaml]
184
+ ----
185
+ ---
186
+ schemas:
187
+ - action_schema
188
+ - application_context_schema
189
+ ----
190
+
191
+ The resulting block adds the `select` attribute to every schema of the the
192
+ "context" object, which allows you to filter those out for complex operations
193
+ via Liquid:
194
+
195
+ [source,liquid]
196
+ ----
197
+ [lutaml_express,schemas_1,repo,leveloffset=+1,config_yaml=select.yaml]
198
+ ---
199
+ {% assign selected = repo.schemas | where: "selected" %}
200
+ ... do things with `selected` ...
201
+ ----
202
+
203
+ NOTE: This functionality is used in the ISO 10303 SRL to load the full schema
204
+ set at once but only render the selected schemas in individual documents.
205
+
206
+
148
207
  == Usage with UML
149
208
 
150
209
  === Rendering a LutaML view: `lutaml_diagram`
@@ -12,13 +12,18 @@ module Metanorma
12
12
 
13
13
  def read_template_file(template_path)
14
14
  full_path = full_path(template_path)
15
- raise FileSystemError, "No such template '#{template_path}'" unless File.exist?(full_path)
15
+
16
+ unless File.exist?(full_path)
17
+ raise FileSystemError, "No such template '#{template_path}'"
18
+ end
16
19
 
17
20
  File.read(full_path)
18
21
  end
19
22
 
20
23
  def full_path(template_path)
21
- raise ::Liquid::FileSystemError, "Illegal template name '#{template_path}'" unless %r{\A[^./][a-zA-Z0-9_/]+\z}.match?(template_path)
24
+ unless %r{\A[^./][a-zA-Z0-9_/]+\z}.match?(template_path)
25
+ raise ::Liquid::FileSystemError, "Illegal template name '#{template_path}'"
26
+ end
22
27
 
23
28
  result_path = if template_path.include?('/')
24
29
  roots
@@ -40,6 +45,10 @@ module Metanorma
40
45
  .find { |path| File.file?(path) }
41
46
  end
42
47
 
48
+ if result_path.nil?
49
+ raise ::Liquid::FileSystemError, "No documents in template path '#{File.expand_path(template_path)}'"
50
+ end
51
+
43
52
  unless roots.any? { |root| File.expand_path(result_path).start_with?(File.expand_path(root)) }
44
53
  raise ::Liquid::FileSystemError, "Illegal template path '#{File.expand_path(result_path)}'"
45
54
  end
@@ -16,164 +16,256 @@ module Metanorma
16
16
  REMARKS_ATTRIBUTE = "remarks"
17
17
 
18
18
  def process(document, reader)
19
- r = Asciidoctor::PreprocessorNoIfdefsReader.new document, reader.lines
19
+ r = Asciidoctor::PreprocessorNoIfdefsReader.new(document, reader.lines)
20
20
  input_lines = r.readlines.to_enum
21
- has_lutaml = !input_lines.select { |x| lutaml?(x) }.empty?
21
+
22
+ has_lutaml = input_lines.any? { |line| lutaml?(line) }
23
+
22
24
  express_indexes = Utils.parse_document_express_indexes(
23
- document, input_lines
25
+ document,
26
+ input_lines
24
27
  )
25
- result_content = processed_lines(document, input_lines,
26
- express_indexes)
27
- has_lutaml and log(document, result_content)
28
+
29
+ result_content = process_input_lines(
30
+ document: document,
31
+ input_lines: input_lines,
32
+ express_indexes: express_indexes,
33
+ )
34
+
35
+ log(document, result_content) if has_lutaml
36
+
28
37
  Asciidoctor::PreprocessorNoIfdefsReader.new(document, result_content)
29
38
  end
30
39
 
31
40
  protected
32
41
 
33
- def log(document, result)
34
- File.open("#{document.attr('docfile')}.lutaml.log.txt",
35
- "w:UTF-8") do |f|
36
- f.write(result.join("\n"))
42
+ def log(doc, text)
43
+ File.open("#{doc.attr('docfile')}.lutaml.log.txt", "w:UTF-8") do |f|
44
+ f.write(text.join("\n"))
37
45
  end
38
46
  end
39
47
 
40
48
  def lutaml?(line)
41
- line.match(/^\[(?:\blutaml\b|\blutaml_express\b),([^,]+)?,?([^,]+)?,?([^,]+)?\]/)
49
+ line.match(/^\[(?:\blutaml\b|\blutaml_express\b),(?<index_names>[^,]+)?,?(?<context_name>[^,]+)?(?<options>,.*)?\]/)
42
50
  end
43
51
 
44
- def content_from_files(document, file_paths)
45
- file_list = file_paths.map do |file_path|
46
- File.new(Utils.relative_file_path(document, file_path),
47
- encoding: "UTF-8")
48
- end
49
- ::Lutaml::Parser.parse(file_list)
52
+ def load_lutaml_file(document, file_path)
53
+ ::Lutaml::Parser.parse(
54
+ File.new(
55
+ Utils.relative_file_path(document, file_path),
56
+ encoding: "UTF-8"
57
+ )
58
+ )
50
59
  end
51
60
 
52
61
  private
53
62
 
54
- def processed_lines(document, input_lines, express_indexes)
63
+ def process_input_lines(
64
+ document:,
65
+ input_lines:,
66
+ express_indexes:
67
+ )
68
+
55
69
  result = []
56
70
  loop do
57
- result
58
- .push(*process_text_blocks(
71
+ result.push(
72
+ *process_text_blocks(
59
73
  document,
60
74
  input_lines,
61
75
  express_indexes,
62
- ))
76
+ )
77
+ )
63
78
  end
64
79
  result
65
80
  end
66
81
 
67
82
  def process_text_blocks(document, input_lines, express_indexes)
68
83
  line = input_lines.next
69
- block_match = lutaml?(line)
70
- return [line] if block_match.nil?
84
+ block_header_match = lutaml?(line)
85
+
86
+ return [line] if block_header_match.nil?
87
+
88
+ index_names = block_header_match[:index_names].split(";").map(&:strip)
89
+ context_name = block_header_match[:context_name].strip
90
+
91
+ options = block_header_match[:options] &&
92
+ parse_options(block_header_match[:options].to_s.strip) || {}
71
93
 
72
94
  end_mark = input_lines.next
73
- parse_template(document,
74
- collect_internal_block_lines(document,
75
- input_lines,
76
- end_mark),
77
- block_match,
78
- express_indexes)
95
+
96
+ render_template(
97
+ document: document,
98
+ lines: extract_block_lines(input_lines, end_mark),
99
+ index_names: index_names,
100
+ context_name: context_name,
101
+ options: options,
102
+ indexes: express_indexes
103
+ )
79
104
  end
80
105
 
81
- def collect_internal_block_lines(_document, input_lines, end_mark)
82
- current_block = []
106
+ def extract_block_lines(input_lines, end_mark)
107
+ block = []
83
108
  while (block_line = input_lines.next) != end_mark
84
- current_block.push(block_line)
109
+ block.push(block_line)
85
110
  end
86
- current_block
111
+ block
87
112
  end
88
113
 
89
- def contexts_items(block_match, document, express_indexes)
90
- contexts_names = block_match[1].split(";").map(&:strip)
91
- file_paths = []
92
- result = contexts_names.each_with_object([]) do |path, res|
93
- if express_indexes[path]
94
- res.push(express_indexes[path])
114
+ def gather_context_items(index_names:, document:, indexes:)
115
+ index_names.map do |path|
116
+ # TODO: Rephrase of the below TODO message.
117
+ # ::Lutaml::Parser.parse(file_list) can return an Array or just one.
118
+ # TODO: decide how to handle expressir multiply file parse as one
119
+ # object and lutaml
120
+
121
+ # Does this condition ever happen? That is only if the
122
+ # `lutaml-express-index` condition is not set
123
+ unless indexes[path]
124
+
125
+ full_path = Utils.relative_file_path(document, path)
126
+ unless File.file?(full_path)
127
+ raise StandardError.new(
128
+ "Unable to load EXPRESS index for `#{path}`, " \
129
+ "please define it at `:lutaml-express-index:` or specify " \
130
+ "the full path."
131
+ )
132
+ end
133
+ wrapper = load_lutaml_file(document, path)
134
+ indexes[path] = {
135
+ wrapper: wrapper,
136
+ serialized_hash: wrapper.to_liquid
137
+ }
95
138
  else
96
- file_paths.push(path)
139
+ indexes[path][:serialized_hash] ||= indexes[path][:wrapper].to_liquid
97
140
  end
141
+
142
+ indexes[path]
98
143
  end
99
- if !file_paths.empty?
100
- from_files = content_from_files(document, file_paths)
101
- # TODO: decide how to handle expressir multiply file parse as one object and lutaml
102
- if from_files.is_a?(Array)
103
- result.push(*from_files.map(&:to_liquid))
104
- else
105
- from_files = from_files.to_liquid
106
- from_files["schemas"] = from_files["schemas"].map do |n|
107
- n.merge("relative_path_prefix" => Utils.relative_file_path(document, File.dirname(n["file"])))
108
- end
109
- result.push(from_files)
144
+ end
145
+
146
+ def parse_yaml_config_file(document, file_path)
147
+ return nil if file_path.nil?
148
+
149
+ relative_file_path = Utils.relative_file_path(document, file_path)
150
+ YAML.safe_load(File.read(relative_file_path, encoding: "UTF-8"))
151
+ end
152
+
153
+ def decorate_schema_object(schema:, document:, indexes:, index_names:, selected:, options:)
154
+ # Mark a schema as "selected" with `.selected`
155
+ schema["selected"] = true if selected
156
+
157
+ # Provide pretty-formatted code under `.formatted`
158
+ index_found_key, index_found_value = indexes.detect do |k,v|
159
+ found = v[:wrapper].original_document.schemas.detect do |s|
160
+ s.id == schema["id"]
110
161
  end
111
162
  end
112
- result
163
+
164
+ schema["formatted"] = index_found_value[:wrapper].original_document.schemas.detect do |s|
165
+ s.id == schema["id"]
166
+ end.to_s(no_remarks: true)
167
+
168
+ # Decorate the remaining things
169
+ decorate_context_items(
170
+ schema,
171
+ options.merge(
172
+ "relative_path_prefix" =>
173
+ Utils.relative_file_path(document, File.dirname(schema["file"]))
174
+ )
175
+ ) || {}
113
176
  end
114
177
 
115
- def parse_template(document, current_block, block_match,
116
- express_indexes)
117
- options = parse_options(block_match[3])
118
- contexts_items(block_match, document, express_indexes)
119
- .map do |items|
120
- if items["schemas"]
121
- items["schemas"] = items["schemas"].map do |j|
122
- opts = options.merge("relative_path_prefix" => j["relative_path_prefix"])
123
- decorate_context_items(j, opts)
124
- end
178
+ def render_template(document:, lines:, context_name:, index_names:, options:, indexes:)
179
+
180
+ config_yaml_path = options.delete("config_yaml")
181
+ config_yaml = config_yaml_path ?
182
+ parse_yaml_config_file(document, config_yaml_path) :
183
+ {}
184
+
185
+ selected_schemas = config_yaml["schemas"]
186
+
187
+ gather_context_items(
188
+ index_names: index_names,
189
+ document: document,
190
+ indexes: indexes
191
+ ).map do |items|
192
+
193
+ serialized_hash = items[:serialized_hash]
194
+
195
+ if serialized_hash["schemas"]
196
+ serialized_hash["schemas"].map! do |schema|
197
+
198
+ decorate_schema_object(
199
+ schema: schema,
200
+ document: document,
201
+ index_names: index_names,
202
+ indexes: indexes,
203
+ selected: selected_schemas && selected_schemas.include?(schema["id"]),
204
+ options: options
205
+ )
125
206
  end
126
- parse_context_block(document: document,
127
- context_lines: current_block,
128
- context_items: items,
129
- context_name: block_match[2].strip)
130
- end.flatten
207
+ end
208
+
209
+ render_block(
210
+ document: document,
211
+ block_lines: lines,
212
+ context_items: serialized_hash,
213
+ context_name: context_name
214
+ )
215
+ end.flatten
131
216
  rescue StandardError => e
132
- document.logger.warn("Failed to parse lutaml block: #{e.message}")
217
+ raise e
218
+ document.logger.warn("Failed to parse LutaML block: #{e.message}")
133
219
  []
134
220
  end
135
221
 
136
222
  def parse_options(options_string)
137
223
  options_string
138
224
  .to_s
139
- .scan(/(.+?)=(\s?[^\s]+)/)
225
+ .scan(/,\s*([^=]+?)=(\s*[^,]+)/)
140
226
  .map { |elem| elem.map(&:strip) }
141
227
  .to_h
142
228
  end
143
229
 
144
- def decorate_context_items(context_items, options)
145
- return context_items if !context_items.is_a?(Hash)
146
-
147
- context_items
148
- .map do |(key, val)|
149
- if val.is_a?(Hash)
150
- [key, decorate_context_items(val, options)]
151
- elsif key == REMARKS_ATTRIBUTE
152
- [key,
153
- val&.map do |remark|
154
- Metanorma::Plugin::Lutaml::ExpressRemarksDecorator
155
- .call(remark, options)
156
- end]
157
- elsif val.is_a?(Array)
158
- [key, val.map { |n| decorate_context_items(n, options) }]
159
- else
160
- [key, val]
230
+ def decorate_context_item(key, val, options)
231
+ if key == REMARKS_ATTRIBUTE
232
+ return [
233
+ key,
234
+ val&.map do |remark|
235
+ Metanorma::Plugin::Lutaml::ExpressRemarksDecorator
236
+ .call(remark, options)
161
237
  end
162
- end
163
- .to_h
238
+ ]
239
+ end
240
+
241
+ case val
242
+ when Hash
243
+ [key, decorate_context_items(val, options)]
244
+ when Array
245
+ [key, val.map { |n| decorate_context_items(n, options) }]
246
+ else
247
+ [key, val]
248
+ end
249
+ end
250
+
251
+ def decorate_context_items(item, options)
252
+ return item unless item.is_a?(Hash)
253
+
254
+ item.map do |(key, val)|
255
+ decorate_context_item(key, val, options)
256
+ end.to_h
164
257
  end
165
258
 
166
- def parse_context_block(context_lines:,
167
- context_items:,
168
- context_name:,
169
- document:)
259
+ def render_block(block_lines:, context_items:, context_name:, document:)
170
260
  render_result, errors = Utils.render_liquid_string(
171
- template_string: context_lines.join("\n"),
261
+ template_string: block_lines.join("\n"),
172
262
  context_items: context_items,
173
263
  context_name: context_name,
174
264
  document: document,
175
265
  )
266
+
176
267
  Utils.notify_render_errors(document, errors)
268
+
177
269
  render_result.split("\n")
178
270
  end
179
271
  end
@@ -201,7 +201,8 @@ options)
201
201
  end
202
202
 
203
203
  def package_entities(options)
204
- options["packages"] or return {}
204
+ return {} unless options["packages"]
205
+
205
206
  options["packages"]
206
207
  .find_all { |entity| entity.is_a?(Hash) && entity.values.first["render_entities"] }
207
208
  .map do |entity|
@@ -27,16 +27,22 @@ module Metanorma
27
27
  def render_liquid_string(template_string:, context_items:,
28
28
  context_name:, document:, include_path: nil)
29
29
  liquid_template = ::Liquid::Template.parse(template_string)
30
+
30
31
  # Allow includes for the template
31
- include_paths = [Utils.relative_file_path(document, ""),
32
- include_path].compact
32
+ include_paths = [
33
+ Utils.relative_file_path(document, ""),
34
+ include_path
35
+ ].compact
36
+
33
37
  liquid_template.registers[:file_system] =
34
38
  ::Metanorma::Plugin::Lutaml::Liquid::LocalFileSystem
35
39
  .new(include_paths, ["_%s.liquid", "_%s.adoc"])
40
+
36
41
  rendered_string = liquid_template
37
42
  .render(context_name => context_items,
38
43
  strict_variables: true,
39
44
  error_mode: :warn)
45
+
40
46
  [rendered_string, liquid_template.errors]
41
47
  end
42
48
 
@@ -48,37 +54,52 @@ module Metanorma
48
54
  end
49
55
  end
50
56
 
51
- def process_express_index(path, cache_path, document,
52
- force_read = false)
53
- if cache_path
54
- cache_full_path = Utils.relative_file_path(document,
55
- cache_path)
56
- end
57
+ def load_express_repositories(path:, cache_path:, document:, force_read: false)
58
+
59
+ cache_full_path = cache_path &&
60
+ Utils.relative_file_path(document, cache_path)
61
+
62
+ # If there is cache and "force read" not set.
57
63
  if !force_read && cache_full_path && File.file?(cache_full_path)
58
- return express_from_cache(cache_full_path)
64
+ return load_express_repo_from_cache(cache_full_path)
59
65
  end
60
66
 
67
+ # If there is no cache or "force read" is set.
61
68
  full_path = Utils.relative_file_path(document, path)
62
- wrapper = express_from_path(document, full_path)
69
+ lutaml_wrapper = load_express_repo_from_path(document, full_path)
70
+
63
71
  if cache_full_path && !File.file?(cache_full_path)
64
- express_write_cache(cache_full_path, wrapper.original_document,
65
- document)
72
+ save_express_repo_to_cache(
73
+ cache_full_path,
74
+ lutaml_wrapper.original_document,
75
+ document
76
+ )
66
77
  end
67
- wrapper
78
+
79
+ lutaml_wrapper
80
+
68
81
  rescue Expressir::Error
69
82
  FileUtils.rm_rf(cache_full_path)
70
- process_express_index(path, cache_path, document, true)
83
+
84
+ load_express_repositories(
85
+ path: path,
86
+ cache_path: cache_path,
87
+ document: document,
88
+ force_read: true
89
+ )
90
+
71
91
  rescue StandardError => e
72
92
  document.logger.warn("Failed to load #{full_path}: #{e.message}")
73
- nil
93
+ raise e
94
+ # nil
74
95
  end
75
96
 
76
- def express_from_cache(path)
97
+ def load_express_repo_from_cache(path)
77
98
  ::Lutaml::Parser
78
99
  .parse(File.new(path), ::Lutaml::Parser::EXPRESS_CACHE_PARSE_TYPE)
79
100
  end
80
101
 
81
- def express_write_cache(path, repository, document)
102
+ def save_express_repo_to_cache(path, repository, document)
82
103
  root_path = Pathname.new(relative_file_path(document, ""))
83
104
  Expressir::Express::Cache
84
105
  .to_file(path,
@@ -86,47 +107,33 @@ force_read = false)
86
107
  root_path: root_path)
87
108
  end
88
109
 
89
- def express_from_path(document, path)
90
- if File.directory?(path)
91
- return express_from_folder(path)
92
- end
110
+ def load_express_repo_from_path(document, path)
111
+ return load_express_from_folder(path) if File.directory?(path)
93
112
 
94
- express_from_index(document, path)
113
+ load_express_from_index(document, path)
95
114
  end
96
115
 
97
- def express_from_folder(folder)
116
+ def load_express_from_folder(folder)
98
117
  files = Dir["#{folder}/*.exp"].map do |nested_path|
99
118
  File.new(nested_path, encoding: "UTF-8")
100
119
  end
101
120
  ::Lutaml::Parser.parse(files)
102
121
  end
103
122
 
104
- def express_decorate_wrapper(wrapper, document)
105
- serialized = wrapper.to_liquid
106
- serialized["schemas"].map! do |j|
107
- j.merge(
108
- "relative_path_prefix" => Utils
109
- .relative_file_path(document, File.dirname(j["file"])),
110
- "formatted" => wrapper.original_document
111
- .schemas.detect {|s| s.id == j["id"] }.to_s(no_remarks: true)
112
- )
113
- end
114
- serialized
115
- end
116
-
117
- def express_from_index(document, path)
123
+ def load_express_from_index(document, path)
118
124
  yaml_content = YAML.safe_load(File.read(path))
119
125
  root_path = yaml_content["path"]
120
- schemas_paths = yaml_content
121
- .fetch("schemas")
126
+ schemas_paths = yaml_content["schemas"]
122
127
  .map do |(schema_name, schema_values)|
123
128
  schema_values["path"] || File.join(root_path.to_s,
124
129
  "#{schema_name}.exp")
125
130
  end
131
+
126
132
  files_to_load = schemas_paths.map do |path|
127
133
  File.new(Utils.relative_file_path(document, path),
128
134
  encoding: "UTF-8")
129
135
  end
136
+
130
137
  ::Lutaml::Parser.parse(files_to_load)
131
138
  end
132
139
 
@@ -134,20 +141,35 @@ force_read = false)
134
141
  express_indexes = {}
135
142
  loop do
136
143
  line = input_lines.next
144
+
145
+ # Finished parsing document attributes
137
146
  break if line.empty?
138
147
 
139
148
  match = line.match(LUTAML_EXP_IDX_TAG)
140
- if match
141
- name = match[:index_name]
142
- path = match[:index_path]
143
- cache = match[:cache_path]
144
- repositories = process_express_index(path.strip, cache, document)
145
- if repositories
146
- express_indexes[name.strip] =
147
- express_decorate_wrapper(repositories, document)
148
- end
149
+ next unless match
150
+
151
+ name = match[:index_name]&.strip
152
+ path = match[:index_path]&.strip
153
+ cache = match[:cache_path]&.strip
154
+
155
+ unless name && path
156
+ raise StandardError.new("No name and path set in `:lutaml-express-index:` attribute.")
157
+ end
158
+
159
+ lutaml_expressir_wrapper = load_express_repositories(
160
+ path: path,
161
+ cache_path: cache,
162
+ document: document
163
+ )
164
+
165
+ if lutaml_expressir_wrapper
166
+ express_indexes[name] = {
167
+ wrapper: lutaml_expressir_wrapper,
168
+ serialized_hash: nil
169
+ }
149
170
  end
150
171
  end
172
+
151
173
  express_indexes
152
174
  rescue StopIteration
153
175
  express_indexes
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.6.0".freeze
4
+ VERSION = "0.6.3".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "liquid"
31
31
  spec.add_dependency "lutaml"
32
32
  spec.add_dependency "relaton-cli"
33
- spec.add_dependency "reverse_adoc"
33
+ spec.add_dependency "reverse_adoc", "~> 0.3.7"
34
34
 
35
35
  spec.add_development_dependency "debug"
36
36
  spec.add_development_dependency "equivalent-xml"
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.6.0
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-23 00:00:00.000000000 Z
11
+ date: 2024-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: reverse_adoc
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.3.7
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.3.7
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: debug
99
99
  requirement: !ruby/object:Gem::Requirement