metanorma-plugin-datastruct 0.3.0 → 0.3.2
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/release.yml +4 -3
- data/Gemfile +5 -1
- data/README.adoc +115 -1
- data/lib/liquid/custom_blocks/key_iterator.rb +6 -2
- data/lib/liquid/custom_blocks/with_json_nested_context.rb +1 -1
- data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +1 -1
- data/lib/metanorma/plugin/datastruct/base_structured_text_preprocessor.rb +50 -24
- data/lib/metanorma/plugin/datastruct/content.rb +76 -0
- data/lib/metanorma/plugin/datastruct/data2_text_preprocessor.rb +45 -0
- data/lib/metanorma/plugin/datastruct/json2_text_preprocessor.rb +12 -20
- data/lib/metanorma/plugin/datastruct/source_extractor.rb +1 -1
- data/lib/metanorma/plugin/datastruct/version.rb +1 -1
- data/lib/metanorma/plugin/datastruct/yaml2_text_preprocessor.rb +2 -22
- data/lib/metanorma-plugin-datastruct.rb +1 -0
- data/metanorma-plugin-datastruct.gemspec +7 -2
- metadata +41 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dab2d2b2496a73636d10696dc5324749bfeb054dbeb5cf5944dac0a857327b17
|
4
|
+
data.tar.gz: d4790331414d8f4f3f02a3e14e21be2a2d70c4684df658cc329816a5e02b2709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abb03b267186c6860c7c99d141e179fc5bd8528fcc031e4117a4395b7a197d0ef2e6dbd3e97c87ab2f38211df1e483832477ea19a743e7253532b8dbeec91192
|
7
|
+
data.tar.gz: 8e00dceace62d6c6384d8d8c2576ec7185d0930e7f75ea1f11ba20655a6896cf6bc457a60867c8c96a927a17e839a60ac8a84fb789d0786bef74aeaf3b3daa26
|
@@ -7,11 +7,12 @@ on:
|
|
7
7
|
inputs:
|
8
8
|
next_version:
|
9
9
|
description: |
|
10
|
-
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
|
11
|
+
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
|
11
12
|
required: true
|
12
13
|
default: 'skip'
|
13
|
-
|
14
|
-
|
14
|
+
repository_dispatch:
|
15
|
+
types: [ do-release ]
|
15
16
|
|
16
17
|
jobs:
|
17
18
|
release:
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -427,7 +427,7 @@ And the block:
|
|
427
427
|
Where:
|
428
428
|
|
429
429
|
* file path is `strings.yaml`
|
430
|
-
* `limit` - how many items we
|
430
|
+
* `limit` - how many items we should take from the array
|
431
431
|
* `offset` - zero-based offset of item from which start the loop
|
432
432
|
* `{{item}}` gives the value of item in the array
|
433
433
|
|
@@ -578,3 +578,117 @@ Last item is dolor.
|
|
578
578
|
------
|
579
579
|
|
580
580
|
--
|
581
|
+
|
582
|
+
|
583
|
+
=== Multiple contexts
|
584
|
+
|
585
|
+
Multiple contexts can be defined in a single block.
|
586
|
+
|
587
|
+
EXAMPLE:
|
588
|
+
--
|
589
|
+
Given:
|
590
|
+
|
591
|
+
strings1.yaml
|
592
|
+
[source,yaml]
|
593
|
+
----
|
594
|
+
---
|
595
|
+
foo: bar
|
596
|
+
dead: beef
|
597
|
+
----
|
598
|
+
|
599
|
+
strings2.yaml
|
600
|
+
[source,yaml]
|
601
|
+
----
|
602
|
+
---
|
603
|
+
hello: world
|
604
|
+
color: red
|
605
|
+
shape: square
|
606
|
+
----
|
607
|
+
|
608
|
+
And the block:
|
609
|
+
[source,asciidoc]
|
610
|
+
------
|
611
|
+
[yaml2text,data1=strings1.yaml,data2=strings2.yaml]
|
612
|
+
----
|
613
|
+
I'm heading to the {{data1.foo}} for {{data1.dead}}.
|
614
|
+
|
615
|
+
This is hello {{data2.hello}}.
|
616
|
+
The color is {{data2.color}} and the shape is {{data2.shape}}.
|
617
|
+
|
618
|
+
----
|
619
|
+
------
|
620
|
+
|
621
|
+
The file path is `strings1.yaml`, and context name is `data1`.
|
622
|
+
`{{data1.foo}}` evaluates to the value of the key `foo` in `data1`.
|
623
|
+
|
624
|
+
The file path is `strings2.yaml`, and context name is `data2`.
|
625
|
+
`{{data2.hello}}` evaluates to the value of the key `hello` in `data2`.
|
626
|
+
|
627
|
+
Will render as:
|
628
|
+
[source,asciidoc]
|
629
|
+
----
|
630
|
+
I'm heading to the bar for beef.
|
631
|
+
|
632
|
+
This is hello world.
|
633
|
+
The color is red and the shape is square.
|
634
|
+
----
|
635
|
+
|
636
|
+
--
|
637
|
+
|
638
|
+
|
639
|
+
=== Multiple contexts with mixed json files and yaml files (data2text)
|
640
|
+
|
641
|
+
Multiple contexts can be mixed with json files and yaml files by using
|
642
|
+
`data2text`.
|
643
|
+
|
644
|
+
EXAMPLE:
|
645
|
+
--
|
646
|
+
Given:
|
647
|
+
|
648
|
+
strings1.json
|
649
|
+
[source,json]
|
650
|
+
----
|
651
|
+
{
|
652
|
+
"foo": "bar",
|
653
|
+
"dead": "beef"
|
654
|
+
}
|
655
|
+
----
|
656
|
+
|
657
|
+
strings2.yaml
|
658
|
+
[source,yaml]
|
659
|
+
----
|
660
|
+
---
|
661
|
+
hello: world
|
662
|
+
color: red
|
663
|
+
shape: square
|
664
|
+
----
|
665
|
+
|
666
|
+
And the block:
|
667
|
+
[source,asciidoc]
|
668
|
+
------
|
669
|
+
[data2text,my_json=strings1.json,my_yaml=strings2.yaml]
|
670
|
+
----
|
671
|
+
I'm heading to the {{my_json.foo}} for {{my_json.dead}}.
|
672
|
+
|
673
|
+
This is hello {{my_yaml.hello}}.
|
674
|
+
The color is {{my_yaml.color}} and the shape is {{my_yaml.shape}}.
|
675
|
+
|
676
|
+
----
|
677
|
+
------
|
678
|
+
|
679
|
+
The file path is `strings1.json`, and context name is `my_json`.
|
680
|
+
`{{my_json.foo}}` evaluates to the value of the key `foo` in `my_json`.
|
681
|
+
|
682
|
+
The file path is `strings2.yaml`, and context name is `my_yaml`.
|
683
|
+
`{{my_yaml.hello}}` evaluates to the value of the key `hello` in `my_yaml`.
|
684
|
+
|
685
|
+
Will render as:
|
686
|
+
[source,asciidoc]
|
687
|
+
----
|
688
|
+
I'm heading to the bar for beef.
|
689
|
+
|
690
|
+
This is hello world.
|
691
|
+
The color is red and the shape is square.
|
692
|
+
----
|
693
|
+
|
694
|
+
--
|
@@ -6,9 +6,13 @@ module Liquid
|
|
6
6
|
@context_name, @var_name = markup.split(",").map(&:strip)
|
7
7
|
end
|
8
8
|
|
9
|
-
def render(context)
|
9
|
+
def render(context) # rubocop:disable Metrics/MethodLength
|
10
10
|
res = ""
|
11
|
-
iterator = context[@context_name].is_a?(Hash)
|
11
|
+
iterator = if context[@context_name].is_a?(Hash)
|
12
|
+
context[@context_name].keys
|
13
|
+
else
|
14
|
+
context[@context_name]
|
15
|
+
end
|
12
16
|
iterator.each.with_index do |key, index|
|
13
17
|
context["index"] = index
|
14
18
|
context[@var_name] = key
|
@@ -10,14 +10,15 @@ require "liquid/custom_filters/values"
|
|
10
10
|
require "liquid/custom_filters/replace_regex"
|
11
11
|
require "metanorma/plugin/datastruct/source_extractor"
|
12
12
|
|
13
|
-
Liquid::
|
14
|
-
Liquid::
|
13
|
+
Liquid::Environment.default
|
14
|
+
.register_tag("keyiterator", Liquid::CustomBlocks::KeyIterator)
|
15
|
+
Liquid::Environment.default
|
15
16
|
.register_tag("with_yaml_nested_context",
|
16
17
|
Liquid::CustomBlocks::WithYamlNestedContext)
|
17
|
-
Liquid::
|
18
|
+
Liquid::Environment.default
|
18
19
|
.register_tag("with_json_nested_context",
|
19
20
|
Liquid::CustomBlocks::WithJsonNestedContext)
|
20
|
-
Liquid::
|
21
|
+
Liquid::Environment.default.register_filter(Liquid::CustomFilters)
|
21
22
|
|
22
23
|
module Asciidoctor
|
23
24
|
class PreprocessorNoIfdefsReader < PreprocessorReader
|
@@ -90,7 +91,7 @@ module Metanorma
|
|
90
91
|
block_match)
|
91
92
|
end
|
92
93
|
|
93
|
-
def collect_internal_block_lines(document, input_lines, end_mark)
|
94
|
+
def collect_internal_block_lines(document, input_lines, end_mark) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
94
95
|
current_block = []
|
95
96
|
nested_marks = []
|
96
97
|
while (block_line = input_lines.next) != end_mark
|
@@ -104,7 +105,9 @@ module Metanorma
|
|
104
105
|
end
|
105
106
|
|
106
107
|
if nested_marks.include?(block_line)
|
107
|
-
current_block.push(
|
108
|
+
current_block.push(
|
109
|
+
"{% endwith_#{data_file_type}_nested_context %}",
|
110
|
+
)
|
108
111
|
next nested_marks.delete(block_line)
|
109
112
|
end
|
110
113
|
current_block.push(block_line)
|
@@ -126,9 +129,16 @@ module Metanorma
|
|
126
129
|
TEMPLATE
|
127
130
|
end
|
128
131
|
|
129
|
-
def parse_template(document, current_block, block_match)
|
130
|
-
transformed_liquid_lines = current_block
|
131
|
-
|
132
|
+
def parse_template(document, current_block, block_match) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
133
|
+
transformed_liquid_lines = current_block.map do |x|
|
134
|
+
transform_line_liquid(x)
|
135
|
+
end
|
136
|
+
|
137
|
+
if block_match[1].include?("=")
|
138
|
+
return content_from_multiple_contexts(
|
139
|
+
document, block_match, transformed_liquid_lines
|
140
|
+
)
|
141
|
+
end
|
132
142
|
|
133
143
|
context_items = if block_match[1].start_with?("#")
|
134
144
|
content_from_anchor(document, block_match[1][1..-1])
|
@@ -136,18 +146,39 @@ module Metanorma
|
|
136
146
|
content_from_file(document, block_match[1])
|
137
147
|
end
|
138
148
|
|
149
|
+
return if context_items.nil?
|
150
|
+
|
151
|
+
contexts = { block_match[2].strip => context_items }
|
152
|
+
|
153
|
+
parse_context_block(document: document,
|
154
|
+
context_lines: transformed_liquid_lines,
|
155
|
+
contexts: contexts)
|
156
|
+
rescue StandardError => e
|
157
|
+
::Metanorma::Util.log("Failed to parse #{config[:block_name]} \
|
158
|
+
block: #{e.message}", :error)
|
159
|
+
[]
|
160
|
+
end
|
161
|
+
|
162
|
+
def content_from_multiple_contexts(document, block_match, # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
163
|
+
transformed_liquid_lines)
|
164
|
+
contexts = {}
|
165
|
+
(1..block_match.size - 1).each do |i|
|
166
|
+
context_and_path = block_match[i].strip
|
167
|
+
context_name, path = context_and_path.split("=")
|
168
|
+
context_items = content_from_file(document, path)
|
169
|
+
contexts[context_name] = context_items
|
170
|
+
end
|
171
|
+
|
139
172
|
parse_context_block(document: document,
|
140
173
|
context_lines: transformed_liquid_lines,
|
141
|
-
|
142
|
-
context_name: block_match[2].strip)
|
174
|
+
contexts: contexts)
|
143
175
|
rescue StandardError => e
|
144
|
-
|
145
|
-
|
146
|
-
block: #{e.message}")
|
176
|
+
::Metanorma::Util.log("Failed to parse #{config[:block_name]} \
|
177
|
+
block: #{e.message}", :error)
|
147
178
|
[]
|
148
179
|
end
|
149
180
|
|
150
|
-
def transform_line_liquid(line)
|
181
|
+
def transform_line_liquid(line) # rubocop:disable Metrics/MethodLength
|
151
182
|
if line.match?(BLOCK_START_REGEXP)
|
152
183
|
line.gsub!(BLOCK_START_REGEXP, '{% keyiterator \1, \2 %}')
|
153
184
|
end
|
@@ -164,28 +195,23 @@ module Metanorma
|
|
164
195
|
'{% assign custom_value = \1 | values %}{{custom_value\2}}')
|
165
196
|
end
|
166
197
|
|
167
|
-
def parse_context_block(context_lines:,
|
168
|
-
context_items:,
|
169
|
-
context_name:,
|
170
|
-
document:)
|
198
|
+
def parse_context_block(context_lines:, contexts:, document:)
|
171
199
|
render_result, errors = render_liquid_string(
|
172
200
|
template_string: context_lines.join("\n"),
|
173
|
-
|
174
|
-
context_name: context_name,
|
201
|
+
contexts: contexts,
|
175
202
|
document: document,
|
176
203
|
)
|
177
204
|
notify_render_errors(document, errors)
|
178
205
|
render_result.split("\n")
|
179
206
|
end
|
180
207
|
|
181
|
-
def render_liquid_string(template_string:,
|
182
|
-
context_name:, document:)
|
208
|
+
def render_liquid_string(template_string:, contexts:, document:)
|
183
209
|
liquid_template = Liquid::Template.parse(template_string)
|
184
210
|
# Allow includes for the template
|
185
211
|
liquid_template.registers[:file_system] =
|
186
212
|
::Liquid::LocalFileSystem.new(relative_file_path(document, ""))
|
187
213
|
rendered_string = liquid_template
|
188
|
-
.render(
|
214
|
+
.render(contexts,
|
189
215
|
strict_variables: true,
|
190
216
|
error_mode: :warn)
|
191
217
|
[rendered_string, liquid_template.errors]
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "yaml"
|
5
|
+
|
6
|
+
module Metanorma
|
7
|
+
module Plugin
|
8
|
+
module Datastruct
|
9
|
+
module Content
|
10
|
+
protected
|
11
|
+
|
12
|
+
# https://ruby-doc.org/stdlib-2.5.1/libdoc/psych/rdoc/Psych.html#method-c-safe_load
|
13
|
+
def yaml_content_from_file(document, file_path) # rubocop:disable Metrics/MethodLength
|
14
|
+
resolved_file_path = relative_file_path(document, file_path)
|
15
|
+
|
16
|
+
unless File.exist?(resolved_file_path)
|
17
|
+
::Metanorma::Util.log(
|
18
|
+
"YAML file referenced in [yaml2text] block not found: " \
|
19
|
+
"#{resolved_file_path}", :error
|
20
|
+
)
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
YAML.safe_load(
|
25
|
+
File.read(resolved_file_path, encoding: "UTF-8"),
|
26
|
+
permitted_classes: [Date, Time],
|
27
|
+
permitted_symbols: [],
|
28
|
+
aliases: true,
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def yaml_content_from_anchor(document, anchor)
|
33
|
+
YAML.safe_load(
|
34
|
+
document.attributes["source_blocks"][anchor],
|
35
|
+
permitted_classes: [Date, Time],
|
36
|
+
permitted_symbols: [],
|
37
|
+
aliases: true,
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def json_content_from_file(document, file_path)
|
42
|
+
JSON.parse(File.read(relative_file_path(document, file_path),
|
43
|
+
encoding: "UTF-8"))
|
44
|
+
end
|
45
|
+
|
46
|
+
def json_content_from_anchor(document, anchor)
|
47
|
+
JSON.parse(document.attributes["source_blocks"][anchor])
|
48
|
+
end
|
49
|
+
|
50
|
+
def content_from_file(document, file_path)
|
51
|
+
if json_file?(file_path)
|
52
|
+
json_content_from_file(document, file_path)
|
53
|
+
else
|
54
|
+
yaml_content_from_file(document, file_path)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def content_from_anchor(document, anchor)
|
59
|
+
if json_content?(document.attributes["source_blocks"][anchor])
|
60
|
+
json_content_from_anchor(document, anchor)
|
61
|
+
else
|
62
|
+
yaml_content_from_anchor(document, anchor)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def json_file?(file_path)
|
67
|
+
file_path.end_with?(".json")
|
68
|
+
end
|
69
|
+
|
70
|
+
def json_content?(content)
|
71
|
+
content.start_with?("{", "[")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "content"
|
4
|
+
require "metanorma/plugin/datastruct/base_structured_text_preprocessor"
|
5
|
+
|
6
|
+
module Metanorma
|
7
|
+
module Plugin
|
8
|
+
module Datastruct
|
9
|
+
class Data2TextPreprocessor < BaseStructuredTextPreprocessor
|
10
|
+
include Content
|
11
|
+
# search document for block `data2text`
|
12
|
+
# after that take template from block and read file into this template
|
13
|
+
# example:
|
14
|
+
# [data2text,my_yaml=foobar.yaml,my_json=foobar.json]
|
15
|
+
# ----
|
16
|
+
# === {foobar.name}
|
17
|
+
# {foobar.desc}
|
18
|
+
#
|
19
|
+
# {my_json.symbol}:: {my_json.symbol_def}
|
20
|
+
# ----
|
21
|
+
#
|
22
|
+
# with content of `foobar.yaml` file equal to:
|
23
|
+
# - name: spaghetti
|
24
|
+
# desc: wheat noodles of 9mm diameter
|
25
|
+
#
|
26
|
+
# and content of `foobar.json` file equal to:
|
27
|
+
# {
|
28
|
+
# "symbol": "SPAG",
|
29
|
+
# "symbol_def": "the situation is message like spaghetti",
|
30
|
+
# }
|
31
|
+
#
|
32
|
+
# will produce:
|
33
|
+
# === spaghetti
|
34
|
+
# wheat noodles of 9mm diameter
|
35
|
+
#
|
36
|
+
# SPAG:: the situation is message like spaghetti
|
37
|
+
|
38
|
+
def initialize(config = {})
|
39
|
+
super
|
40
|
+
@config[:block_name] = "data2text"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "content"
|
4
4
|
require "metanorma/plugin/datastruct/base_structured_text_preprocessor"
|
5
5
|
|
6
6
|
module Metanorma
|
7
7
|
module Plugin
|
8
8
|
module Datastruct
|
9
9
|
class Json2TextPreprocessor < BaseStructuredTextPreprocessor
|
10
|
-
|
10
|
+
include Content
|
11
|
+
# search document for block `json2text`
|
11
12
|
# after that take template from block and read file into this template
|
12
13
|
# example:
|
13
|
-
# [
|
14
|
+
# [json2text,foobar.json]
|
14
15
|
# ----
|
15
16
|
# === {item.name}
|
16
17
|
# {item.desc}
|
@@ -18,33 +19,24 @@ module Metanorma
|
|
18
19
|
# {item.symbol}:: {item.symbol_def}
|
19
20
|
# ----
|
20
21
|
#
|
21
|
-
# with content of `foobar.
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
22
|
+
# with content of `foobar.json` file equal to:
|
23
|
+
# {
|
24
|
+
# "name": "spaghetti",
|
25
|
+
# "desc": "wheat noodles of 9mm diameter".
|
26
|
+
# "symbol": "SPAG",
|
27
|
+
# "symbol_def": "the situation is message like spaghetti",
|
28
|
+
# }
|
26
29
|
#
|
27
30
|
# will produce:
|
28
31
|
# === spaghetti
|
29
32
|
# wheat noodles of 9mm diameter
|
30
33
|
#
|
31
|
-
# SPAG:: the situation is message like spaghetti
|
34
|
+
# SPAG:: the situation is message like spaghetti
|
32
35
|
|
33
36
|
def initialize(config = {})
|
34
37
|
super
|
35
38
|
@config[:block_name] = "json2text"
|
36
39
|
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
|
40
|
-
def content_from_file(document, file_path)
|
41
|
-
JSON.parse(File.read(relative_file_path(document, file_path),
|
42
|
-
encoding: "UTF-8"))
|
43
|
-
end
|
44
|
-
|
45
|
-
def content_from_anchor(document, anchor)
|
46
|
-
JSON.parse(document.attributes["source_blocks"][anchor])
|
47
|
-
end
|
48
40
|
end
|
49
41
|
end
|
50
42
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "content"
|
4
4
|
require "metanorma/plugin/datastruct/base_structured_text_preprocessor"
|
5
5
|
|
6
6
|
module Metanorma
|
7
7
|
module Plugin
|
8
8
|
module Datastruct
|
9
9
|
class Yaml2TextPreprocessor < BaseStructuredTextPreprocessor
|
10
|
+
include Content
|
10
11
|
# search document for block `yaml2text`
|
11
12
|
# after that take template from block and read file into this template
|
12
13
|
# example:
|
@@ -34,27 +35,6 @@ module Metanorma
|
|
34
35
|
super
|
35
36
|
@config[:block_name] = "yaml2text"
|
36
37
|
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
|
40
|
-
# https://ruby-doc.org/stdlib-2.5.1/libdoc/psych/rdoc/Psych.html#method-c-safe_load
|
41
|
-
def content_from_file(document, file_path)
|
42
|
-
YAML.safe_load(
|
43
|
-
File.read(relative_file_path(document, file_path), encoding: "UTF-8"),
|
44
|
-
permitted_classes: [Date, Time],
|
45
|
-
permitted_symbols: [],
|
46
|
-
aliases: true,
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
def content_from_anchor(document, anchor)
|
51
|
-
YAML.safe_load(
|
52
|
-
document.attributes["source_blocks"][anchor],
|
53
|
-
permitted_classes: [Date, Time],
|
54
|
-
permitted_symbols: [],
|
55
|
-
aliases: true,
|
56
|
-
)
|
57
|
-
end
|
58
38
|
end
|
59
39
|
end
|
60
40
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "metanorma/plugin/datastruct/version"
|
2
2
|
require "metanorma/plugin/datastruct/json2_text_preprocessor"
|
3
3
|
require "metanorma/plugin/datastruct/yaml2_text_preprocessor"
|
4
|
+
require "metanorma/plugin/datastruct/data2_text_preprocessor"
|
4
5
|
|
5
6
|
module Metanorma
|
6
7
|
module Plugin
|
@@ -15,7 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.license = "BSD-2-Clause"
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
18
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
19
|
+
# into git.
|
19
20
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
21
|
`git ls-files -z`.split("\x0").reject do |f|
|
21
22
|
f.match(%r{^(test|spec|features)/})
|
@@ -25,6 +26,8 @@ Gem::Specification.new do |spec|
|
|
25
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
27
|
spec.require_paths = ["lib"]
|
27
28
|
|
29
|
+
spec.required_ruby_version = ">= 2.7.0" # rubocop:disable Gemspec/RequiredRubyVersion
|
30
|
+
|
28
31
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
29
32
|
spec.add_dependency "isodoc"
|
30
33
|
spec.add_dependency "relaton-cli"
|
@@ -35,10 +38,12 @@ Gem::Specification.new do |spec|
|
|
35
38
|
spec.add_development_dependency "metanorma-standoc"
|
36
39
|
spec.add_development_dependency "rake", "~> 13"
|
37
40
|
spec.add_development_dependency "rspec", "~> 3.6"
|
38
|
-
spec.add_development_dependency "rubocop", "
|
41
|
+
spec.add_development_dependency "rubocop", "~> 1.58"
|
42
|
+
spec.add_development_dependency "rubocop-performance", "~> 1.19"
|
39
43
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
40
44
|
spec.add_development_dependency "timecop", "~> 0.9"
|
41
45
|
spec.add_development_dependency "vcr", "~> 6.1.0"
|
42
46
|
spec.add_development_dependency "webmock"
|
47
|
+
spec.add_development_dependency "xml-c14n"
|
43
48
|
spec.metadata["rubygems_mfa_required"] = "false"
|
44
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-plugin-datastruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -140,16 +140,30 @@ dependencies:
|
|
140
140
|
name: rubocop
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.58'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
144
151
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
152
|
+
version: '1.58'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-performance
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.19'
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- -
|
164
|
+
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
166
|
+
version: '1.19'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: simplecov
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +220,20 @@ dependencies:
|
|
206
220
|
- - ">="
|
207
221
|
- !ruby/object:Gem::Version
|
208
222
|
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: xml-c14n
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
209
237
|
description: Metanorma plugin for yaml2text and json2text
|
210
238
|
email:
|
211
239
|
- open.source@ribose.com
|
@@ -233,6 +261,8 @@ files:
|
|
233
261
|
- lib/liquid/custom_filters/values.rb
|
234
262
|
- lib/metanorma-plugin-datastruct.rb
|
235
263
|
- lib/metanorma/plugin/datastruct/base_structured_text_preprocessor.rb
|
264
|
+
- lib/metanorma/plugin/datastruct/content.rb
|
265
|
+
- lib/metanorma/plugin/datastruct/data2_text_preprocessor.rb
|
236
266
|
- lib/metanorma/plugin/datastruct/json2_text_preprocessor.rb
|
237
267
|
- lib/metanorma/plugin/datastruct/source_extractor.rb
|
238
268
|
- lib/metanorma/plugin/datastruct/version.rb
|
@@ -243,7 +273,7 @@ licenses:
|
|
243
273
|
- BSD-2-Clause
|
244
274
|
metadata:
|
245
275
|
rubygems_mfa_required: 'false'
|
246
|
-
post_install_message:
|
276
|
+
post_install_message:
|
247
277
|
rdoc_options: []
|
248
278
|
require_paths:
|
249
279
|
- lib
|
@@ -251,15 +281,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
281
|
requirements:
|
252
282
|
- - ">="
|
253
283
|
- !ruby/object:Gem::Version
|
254
|
-
version:
|
284
|
+
version: 2.7.0
|
255
285
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
286
|
requirements:
|
257
287
|
- - ">="
|
258
288
|
- !ruby/object:Gem::Version
|
259
289
|
version: '0'
|
260
290
|
requirements: []
|
261
|
-
rubygems_version: 3.
|
262
|
-
signing_key:
|
291
|
+
rubygems_version: 3.5.22
|
292
|
+
signing_key:
|
263
293
|
specification_version: 4
|
264
294
|
summary: Metanorma plugin for yaml2text and json2text
|
265
295
|
test_files: []
|