metanorma-plugin-lutaml 0.7.27 → 0.7.28

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a13084276fa3469960665b5591f55c725bd5c0764694dc5c23874175539fcec7
4
- data.tar.gz: 36bc60f0e6c845c629c42658d7ec05f660378d5083dfd3199c066a50030ae865
3
+ metadata.gz: 54d77b60de59ac664edec38812678d7ebd0c994afaf9f7d4ef60a7bad36046bf
4
+ data.tar.gz: fd77fded1a6aae8ecfcf2b3b15b0389e3ee74e785a5f181050e027c4b5720f37
5
5
  SHA512:
6
- metadata.gz: 26804996b13e88130f617c11ed5689117adcfe944acc3f2910e87ad7b8f25048268c63d0986787fe6470ffa80fb7a2eeaed8a73f449d98b91de07623ec93af34
7
- data.tar.gz: 34cb8cd2cad5803b28e998a1d9496b634ac14a091a75199c004147b94f45477cd47362d5bd6f12d7c8d12a1730fac515f82f653a9cbd55e7bc3af2293be81c69
6
+ metadata.gz: ebfe9b260d0a4630bbf8a3c41ca70b998f5c23be260e494f53adc02e0ec29521cf4fcb18e436147823b4854a1a8a2c6020b9ca1116be22086b55855e95d44b38
7
+ data.tar.gz: 73404de51765b8f5190de28ede422d3f9c398029d49f43071b1e5ec53c297a7f06ce3adecfaa6b7050529da677cef5e38d51488f11a63d07f5f13ae733c251f4
data/README.adoc CHANGED
@@ -252,8 +252,8 @@ per-block via a separate YAML file.
252
252
 
253
253
  [lutaml_express_liquid,all_schemas,context,config_yaml=schemas.yaml]
254
254
  ---
255
- {% assign selected = context.schemas | where: "selected" %}
256
- {% render "templates/resources/schema" for selected as schema %}
255
+ {% assign all_schemas = repo.schemas %}
256
+ {% render "templates/resources/schema" for ordered_schemas as schema %}
257
257
  ----
258
258
  -----
259
259
 
@@ -284,16 +284,16 @@ schemas:
284
284
  anything: ...
285
285
  ----
286
286
 
287
- The resulting block adds the `select` attribute to every schema of the the
288
- "context" object, which allows you to filter those out for complex operations
289
- via Liquid:
287
+ The resulting block adds the `ordered_schemas` context to allows you to filter
288
+ out the schemas you want to render according to the order in the config_yaml.
290
289
 
291
290
  [source,liquid]
292
291
  ----
293
292
  [lutaml_express_liquid,schemas_1,repo,config_yaml=select.yaml]
294
293
  ---
295
- {% assign selected = repo.schemas | where: "selected" %}
296
- ... do things with `selected` ...
294
+ {% assign all_schemas = repo.schemas %}
295
+ {% render "templates/resources/schema" for ordered_schemas as schema %}
296
+ ...
297
297
  ---
298
298
  ----
299
299
 
@@ -311,8 +311,9 @@ from the paths other than the location of the document.
311
311
 
312
312
  [lutaml_express_liquid,all_schemas,context,config_yaml=schemas.yaml,include_path=../templates]
313
313
  ---
314
- {% assign selected = context.schemas | where: "selected" %}
315
- {% render "templates/resources/schema" for selected as schema %}
314
+ {% assign all_schemas = repo.schemas %}
315
+ {% render "templates/resources/schema" for ordered_schemas as schema %}
316
+ ...
316
317
  ----
317
318
  -----
318
319
 
@@ -137,7 +137,6 @@ module Metanorma
137
137
 
138
138
  # Process each schema
139
139
  repo.schemas.each do |schema|
140
- update_schema_selection(schema, options)
141
140
  options["relative_path_prefix"] =
142
141
  relative_path_prefix(options, schema)
143
142
  update_remarks(schema, options)
@@ -146,13 +145,6 @@ module Metanorma
146
145
  repo
147
146
  end
148
147
 
149
- def update_schema_selection(schema, options)
150
- return unless options["selected_schemas"]
151
-
152
- schema.selected = options["selected_schemas"].include?(schema.file_basename) ||
153
- options["selected_schemas"].include?(schema.id)
154
- end
155
-
156
148
  def update_remarks(model, options)
157
149
  model.remarks = decorate_remarks(options, model.remarks)
158
150
  model.remark_items&.each do |ri|
@@ -215,10 +207,8 @@ module Metanorma
215
207
 
216
208
  # Get all context items in one go
217
209
  all_items = gather_context_liquid_items(
218
- index_names: index_names,
219
- document: document,
220
- indexes: indexes,
221
- options: options.merge("document" => document),
210
+ index_names: index_names, document: document, indexes: indexes,
211
+ options: options.merge("document" => document)
222
212
  )
223
213
 
224
214
  # Setup include paths for liquid templates
@@ -238,17 +228,33 @@ module Metanorma
238
228
  # Render for each item
239
229
  all_items.map do |item|
240
230
  template.assigns[context_name] = item[:liquid_drop]
231
+ template.assigns["ordered_schemas"] = reorder_schemas(
232
+ item[:liquid_drop], options
233
+ )
241
234
  template.assigns["schemas_order"] = options["selected_schemas"]
242
235
  template.render
243
236
  end.flatten
244
237
  rescue StandardError => e
245
- ::Metanorma::Util.log(
246
- "[LutamlPreprocessor] Failed to parse LutaML block: #{e.message}",
247
- :error,
248
- )
238
+ ::Metanorma::Util
239
+ .log("[LutamlPreprocessor] Failed to parse LutaML block: " \
240
+ "#{e.message}", :error)
249
241
  raise e
250
242
  end
251
243
 
244
+ def reorder_schemas(repo_liquid, options)
245
+ return repo_liquid.schemas unless options["selected_schemas"]
246
+
247
+ ordered_schemas = []
248
+ options["selected_schemas"].each do |schema_name|
249
+ ordered_schema = repo_liquid.schemas.find do |schema|
250
+ schema.id == schema_name || schema.file_basename == schema_name
251
+ end
252
+ ordered_schemas.push(ordered_schema)
253
+ end
254
+
255
+ ordered_schemas
256
+ end
257
+
252
258
  def process_options(document, options)
253
259
  # Process config file if specified
254
260
  if (config_yaml_path = options.delete("config_yaml"))
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.27".freeze
4
+ VERSION = "0.7.28".freeze
5
5
  end
6
6
  end
7
7
  end
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.27
4
+ version: 0.7.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-24 00:00:00.000000000 Z
11
+ date: 2025-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor