metanorma-plugin-lutaml 0.6.3 → 0.6.4

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: 19d2399f31818f5f72d0f6237199042a1b729457039c033e5a45d29645b56eda
4
- data.tar.gz: 0a3a779c6e6b556c7597fc2f9fc708565fb3e0841969eccc855334fcf9e98a88
3
+ metadata.gz: e52ac2333cb4e251e5d531e8909d1a763a6f05960ad886136741676639235e44
4
+ data.tar.gz: 7f3e2daffb58c5074928121da9f4951f85a704e1cb8d8e666e5cfcfcdff90e7c
5
5
  SHA512:
6
- metadata.gz: a03c8868605097a556281eae23b1f2a9b40f3991e7f7304c0f70ef2d3f8e8477fbd69389c2c49482b0774b729dbb02a8bbb39f3949b7453a5542e4a957c4a70e
7
- data.tar.gz: 1001f84dc00d0430552d89f63525af328fa1d2fec6143ce7fbf5c49764f83f5d27b0673d4c57756514498236eb91857cadaf981400097e2d1556f8a554d962c1
6
+ metadata.gz: bc3b7a23fef7ba9b8b7537ea94d5b28c548b0f55409e4dbf6e8cac0d35742d2126d4831a9bc1747647ac5d9e3c3f4f1ed3d4b00eb0ffeeae0251b65d6301833e
7
+ data.tar.gz: e56cad378a1131c70ebc0a47e2d44cbdba2fda3bc4a56f866a4a3e3b45268eeb02fa859e02d48904a8b4b90fe0699fc99c607853e9509b41221953917ed2a0f0
data/README.adoc CHANGED
@@ -154,11 +154,11 @@ per-block via a separate YAML file.
154
154
 
155
155
  [source,adoc]
156
156
  ----
157
- :lutaml-express-index: schemas_1; schemas_all.yaml;
157
+ :lutaml-express-index: all_schemas; ../schemas_all.yaml;
158
158
 
159
- [lutaml_express,schemas_1,repo,leveloffset=+1,config_yaml=select.yaml]
159
+ [lutaml_express,all_schemas,context,leveloffset=+1,config_yaml=schemas.yaml]
160
160
  ---
161
- {% assign selected = repo.schemas | where: "selected" %}
161
+ {% assign selected = context.schemas | where: "selected" %}
162
162
  {% render "templates/resources/schema" for selected as schema %}
163
163
  ---
164
164
  ----
@@ -178,14 +178,16 @@ schemas:
178
178
  ...
179
179
  ----
180
180
 
181
- And `select.yaml` only selects 2 schemas:
181
+ And `schemas.yaml` only selects 2 schemas:
182
182
 
183
183
  [source,yaml]
184
184
  ----
185
185
  ---
186
186
  schemas:
187
- - action_schema
188
- - application_context_schema
187
+ action_schema:
188
+ anything: ...
189
+ application_context_schema:
190
+ anything: ...
189
191
  ----
190
192
 
191
193
  The resulting block adds the `select` attribute to every schema of the the
@@ -143,11 +143,27 @@ module Metanorma
143
143
  end
144
144
  end
145
145
 
146
- def parse_yaml_config_file(document, file_path)
147
- return nil if file_path.nil?
146
+ def read_config_yaml_file(document, file_path)
147
+ return {} if file_path.nil?
148
148
 
149
149
  relative_file_path = Utils.relative_file_path(document, file_path)
150
- YAML.safe_load(File.read(relative_file_path, encoding: "UTF-8"))
150
+ config_yaml = YAML.safe_load(
151
+ File.read(relative_file_path, encoding: "UTF-8")
152
+ )
153
+
154
+ options = {}
155
+ if config_yaml["schemas"]
156
+ unless config_yaml["schemas"].is_a?(Hash)
157
+ raise StandardError.new(
158
+ "[lutaml_express] attribute `config_yaml` must point to a YAML " \
159
+ "file that has the `schema` key containing a hash."
160
+ )
161
+ end
162
+
163
+ options["selected_schemas"] = config_yaml["schemas"].keys
164
+ end
165
+
166
+ options
151
167
  end
152
168
 
153
169
  def decorate_schema_object(schema:, document:, indexes:, index_names:, selected:, options:)
@@ -178,11 +194,8 @@ module Metanorma
178
194
  def render_template(document:, lines:, context_name:, index_names:, options:, indexes:)
179
195
 
180
196
  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"]
197
+ config = read_config_yaml_file(document, config_yaml_path)
198
+ selected_schemas = config["selected_schemas"]
186
199
 
187
200
  gather_context_items(
188
201
  index_names: index_names,
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.6.3".freeze
4
+ VERSION = "0.6.4".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.6.3
4
+ version: 0.6.4
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-05-07 00:00:00.000000000 Z
11
+ date: 2024-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor