metanorma-plugin-lutaml 0.3.0 → 0.4.1
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/Makefile +2 -0
- data/lib/metanorma/plugin/lutaml/liquid/custom_filters.rb +15 -0
- data/lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb +21 -13
- data/lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb +2 -1
- data/lib/metanorma/plugin/lutaml/utils.rb +26 -20
- data/lib/metanorma/plugin/lutaml/version.rb +1 -1
- data/metanorma-plugin-lutaml.gemspec +3 -3
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d99e7b02bf3bfbddcf2d2f81d47e0a83e33abdc0617a9032a106e6930cb05f30
|
4
|
+
data.tar.gz: bfc083ccb6fbd3e7824805e90515340812a1a44ba9522485d5b7a9969c36de2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f4f9659c0cc4b62cfdd16e43d771eda047ff29c9731d9b397d186a6f0d214681c9c05f7a09f5ccfc70382fcfafae7df0ff833966d8454be2f947ca3ced9e376
|
7
|
+
data.tar.gz: dc4de40cee4c6ea453936fe4097f732bea18aa5c92ecedbf9789a9719a994edb4afd0088d9b13fffdfc811b960be391c4272282cb39c063685c46e8865fad2b6
|
data/Makefile
ADDED
@@ -21,8 +21,9 @@ module Metanorma
|
|
21
21
|
document,
|
22
22
|
input_lines
|
23
23
|
)
|
24
|
-
|
25
|
-
|
24
|
+
result_content = processed_lines(document, input_lines, express_indexes)
|
25
|
+
result_reader = Asciidoctor::PreprocessorReader.new(document, result_content)
|
26
|
+
result_reader
|
26
27
|
end
|
27
28
|
|
28
29
|
protected
|
@@ -82,11 +83,17 @@ module Metanorma
|
|
82
83
|
end
|
83
84
|
end
|
84
85
|
if !file_paths.empty?
|
85
|
-
from_files = content_from_files(document, file_paths)
|
86
|
-
|
87
|
-
|
86
|
+
from_files = content_from_files(document, file_paths)
|
87
|
+
# TODO: decide how to handle expressir multiply file parse as one object and lutaml
|
88
|
+
if from_files.is_a?(Array)
|
89
|
+
result.push(*from_files.map(&:to_liquid))
|
90
|
+
else
|
91
|
+
from_files = from_files.to_liquid
|
92
|
+
from_files["schemas"] = from_files["schemas"].map do |n|
|
93
|
+
n.merge("relative_path_prefix" => Utils.relative_file_path(document, File.dirname(n["file"])))
|
94
|
+
end
|
95
|
+
result.push(from_files)
|
88
96
|
end
|
89
|
-
result.push(from_files)
|
90
97
|
end
|
91
98
|
result
|
92
99
|
end
|
@@ -95,9 +102,9 @@ module Metanorma
|
|
95
102
|
options = parse_options(block_match[3])
|
96
103
|
contexts_items(block_match, document, express_indexes)
|
97
104
|
.map do |items|
|
98
|
-
if items[
|
99
|
-
items[
|
100
|
-
opts = options.merge(
|
105
|
+
if items["schemas"]
|
106
|
+
items["schemas"] = items["schemas"].map do |j|
|
107
|
+
opts = options.merge("relative_path_prefix" => j["relative_path_prefix"])
|
101
108
|
decorate_context_items(j, opts)
|
102
109
|
end
|
103
110
|
end
|
@@ -106,9 +113,9 @@ module Metanorma
|
|
106
113
|
context_items: items,
|
107
114
|
context_name: block_match[2].strip)
|
108
115
|
end.flatten
|
109
|
-
|
110
|
-
|
111
|
-
|
116
|
+
rescue StandardError => e
|
117
|
+
document.logger.warn("Failed to parse lutaml block: #{e.message}")
|
118
|
+
[]
|
112
119
|
end
|
113
120
|
|
114
121
|
def parse_options(options_string)
|
@@ -148,7 +155,8 @@ module Metanorma
|
|
148
155
|
render_result, errors = Utils.render_liquid_string(
|
149
156
|
template_string: context_lines.join("\n"),
|
150
157
|
context_items: context_items,
|
151
|
-
context_name: context_name
|
158
|
+
context_name: context_name,
|
159
|
+
document: document
|
152
160
|
)
|
153
161
|
Utils.notify_render_errors(document, errors)
|
154
162
|
render_result.split("\n")
|
@@ -60,7 +60,8 @@ module Metanorma
|
|
60
60
|
render_result, errors = Utils.render_liquid_string(
|
61
61
|
template_string: table_template,
|
62
62
|
context_items: entity_definition,
|
63
|
-
context_name: "definition"
|
63
|
+
context_name: "definition",
|
64
|
+
document: document
|
64
65
|
)
|
65
66
|
Utils.notify_render_errors(document, errors)
|
66
67
|
render_result.split("\n")
|
@@ -1,4 +1,7 @@
|
|
1
|
-
require "expressir/
|
1
|
+
require "expressir/express/cache"
|
2
|
+
require "metanorma/plugin/lutaml/liquid/custom_filters"
|
3
|
+
|
4
|
+
::Liquid::Template.register_filter(Metanorma::Plugin::Lutaml::Liquid::CustomFilters)
|
2
5
|
|
3
6
|
module Metanorma
|
4
7
|
module Plugin
|
@@ -19,8 +22,10 @@ module Metanorma
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def render_liquid_string(template_string:, context_items:,
|
22
|
-
context_name:)
|
23
|
-
liquid_template = Liquid::Template.parse(template_string)
|
25
|
+
context_name:, document:)
|
26
|
+
liquid_template = ::Liquid::Template.parse(template_string)
|
27
|
+
# Allow includes for the template
|
28
|
+
liquid_template.registers[:file_system] = ::Liquid::LocalFileSystem.new(Utils.relative_file_path(document, ""))
|
24
29
|
rendered_string = liquid_template
|
25
30
|
.render(context_name => context_items,
|
26
31
|
strict_variables: true,
|
@@ -48,11 +53,12 @@ module Metanorma
|
|
48
53
|
express_write_cache(cache_full_path, wrapper.original_document, document)
|
49
54
|
end
|
50
55
|
wrapper
|
56
|
+
rescue Expressir::Error
|
57
|
+
FileUtils.rm_rf(cache_full_path)
|
58
|
+
process_express_index(path, cache_path, document, true)
|
51
59
|
rescue StandardError => e
|
52
60
|
document.logger.warn("Failed to load #{full_path}: #{e.message}")
|
53
61
|
nil
|
54
|
-
rescue Expressir::ExpressExp::CacheLoadError
|
55
|
-
process_express_index(path, cache_path, document, true)
|
56
62
|
end
|
57
63
|
|
58
64
|
def express_from_cache(path)
|
@@ -61,11 +67,11 @@ module Metanorma
|
|
61
67
|
end
|
62
68
|
|
63
69
|
def express_write_cache(path, repository, document)
|
64
|
-
root_path = Pathname.new(relative_file_path(document,
|
65
|
-
Expressir::
|
70
|
+
root_path = Pathname.new(relative_file_path(document, ""))
|
71
|
+
Expressir::Express::Cache
|
66
72
|
.to_file(path,
|
67
|
-
|
68
|
-
|
73
|
+
repository,
|
74
|
+
root_path: root_path)
|
69
75
|
end
|
70
76
|
|
71
77
|
def express_from_path(document, path)
|
@@ -83,24 +89,24 @@ module Metanorma
|
|
83
89
|
|
84
90
|
def express_decorate_wrapper(wrapper, document)
|
85
91
|
serialized = wrapper.to_liquid
|
86
|
-
serialized[
|
87
|
-
j.merge(
|
92
|
+
serialized["schemas"] = serialized["schemas"].map do |j|
|
93
|
+
j.merge("relative_path_prefix" => Utils.relative_file_path(document, File.dirname(j["file"])))
|
88
94
|
end
|
89
95
|
serialized
|
90
96
|
end
|
91
97
|
|
92
98
|
def express_from_index(document, path)
|
93
99
|
yaml_content = YAML.safe_load(File.read(path))
|
94
|
-
root_path = yaml_content[
|
100
|
+
root_path = yaml_content["path"]
|
95
101
|
schemas_paths = yaml_content
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
102
|
+
.fetch("schemas")
|
103
|
+
.map do |(schema_name, schema_values)|
|
104
|
+
if schema_values["path"]
|
105
|
+
schema_values["path"]
|
106
|
+
else
|
107
|
+
File.join(root_path.to_s, "#{schema_name}.exp")
|
108
|
+
end
|
109
|
+
end
|
104
110
|
files_to_load = schemas_paths.map do |path|
|
105
111
|
File.new(Utils.relative_file_path(document, path), encoding: "UTF-8")
|
106
112
|
end
|
@@ -24,16 +24,16 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
26
|
spec.add_dependency "liquid"
|
27
|
-
spec.add_dependency "lutaml"
|
28
|
-
spec.add_dependency "lutaml-uml", "~> 0.2.0"
|
27
|
+
spec.add_dependency "lutaml"
|
29
28
|
spec.add_dependency "metanorma"
|
30
29
|
spec.add_dependency "relaton-cli"
|
30
|
+
spec.add_dependency "reverse_adoc"
|
31
31
|
|
32
32
|
spec.add_development_dependency "byebug"
|
33
33
|
spec.add_development_dependency "equivalent-xml"
|
34
34
|
spec.add_development_dependency "metanorma-standoc"
|
35
35
|
spec.add_development_dependency "pry", "~> 0.12.2"
|
36
|
-
spec.add_development_dependency "rake", "~>
|
36
|
+
spec.add_development_dependency "rake", "~> 13"
|
37
37
|
spec.add_development_dependency "rspec", "~> 3.6"
|
38
38
|
spec.add_development_dependency "rubocop", "= 0.54.0"
|
39
39
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
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.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -28,32 +28,32 @@ dependencies:
|
|
28
28
|
name: lutaml
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: metanorma
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: relaton-cli
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: reverse_adoc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '13'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '13'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rspec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,12 +247,14 @@ files:
|
|
247
247
|
- Dockerfile
|
248
248
|
- Gemfile
|
249
249
|
- LICENSE
|
250
|
+
- Makefile
|
250
251
|
- README.adoc
|
251
252
|
- Rakefile
|
252
253
|
- bin/console
|
253
254
|
- bin/setup
|
254
255
|
- lib/metanorma-plugin-lutaml.rb
|
255
256
|
- lib/metanorma/plugin/lutaml/express_remarks_decorator.rb
|
257
|
+
- lib/metanorma/plugin/lutaml/liquid/custom_filters.rb
|
256
258
|
- lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb
|
257
259
|
- lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
|
258
260
|
- lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb
|
@@ -279,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
281
|
- !ruby/object:Gem::Version
|
280
282
|
version: '0'
|
281
283
|
requirements: []
|
282
|
-
rubygems_version: 3.
|
284
|
+
rubygems_version: 3.1.6
|
283
285
|
signing_key:
|
284
286
|
specification_version: 4
|
285
287
|
summary: Metanorma plugin for LutaML
|