metanorma-plugin-lutaml 0.3.1 → 0.3.2

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: 9fb3bd82b6d23d6684bd1ca4793eb9d423dbe8132bf9e303bf5be17369fbd9e3
4
- data.tar.gz: 9112fcf75f2cf32ac4f18e4e6dc0b7ef5385b247ca7293fafb9dd0d9185a4c0c
3
+ metadata.gz: a24226ddaa6e87bf2622c963e3a95d9abb9527e4067dc78836a605c35baa2e10
4
+ data.tar.gz: c0e3cc93d034f8b66219feb004aba88ae685fe1e1cbc4c0e78698cf51da3c3b5
5
5
  SHA512:
6
- metadata.gz: e71b2f2667ad1f77bedcdd7459ff3b4ef19889a625cd14573741e855f6b97a1910f2a35198190f397f0158a23f9a49f24daaadb2ecc86bc59e948245c5e515f9
7
- data.tar.gz: 253186ae00898321c291cdca4f5c5f118fff2072845977540cefaeb1b55a7bc326cba50649a1481e8b90e8565ce76df129d280ccbdf045c5336b5a9a921c9254
6
+ metadata.gz: 3a61f3035a98479f58c01d84b55f262ca300876d72952d90d1fc10fbd5d3faaaa75eaa73b91c369c4c4108a765067eab3b81b5c0cbc3b8f2f6bd763306a537f8
7
+ data.tar.gz: 8ac5a2a497f0223b828ae6409b56bdc97e03750efbf1513f477774e1d13f749757372fabfca1c5a54cd665105acc00c23ce1c439d2c5dbb3cf420765e9379bdb
data/Makefile ADDED
@@ -0,0 +1,2 @@
1
+ fix-lint-staged:
2
+ git status --short | egrep '^(A|M)' | awk '{ print $$2}' | grep -v db/schema.rb | xargs bundle exec rubocop -a
@@ -0,0 +1,15 @@
1
+ require "reverse_adoc"
2
+
3
+ module Metanorma
4
+ module Plugin
5
+ module Lutaml
6
+ module Liquid
7
+ module CustomFilters
8
+ def html2adoc(input)
9
+ ReverseAdoc.convert(input)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -88,8 +88,8 @@ module Metanorma
88
88
  result.push(*from_files.map(&:to_liquid))
89
89
  else
90
90
  from_files = from_files.to_liquid
91
- from_files['schemas'] = from_files['schemas'].map do |n|
92
- n.merge('relative_path_prefix' => Utils.relative_file_path(document, File.dirname(n['file'])))
91
+ from_files["schemas"] = from_files["schemas"].map do |n|
92
+ n.merge("relative_path_prefix" => Utils.relative_file_path(document, File.dirname(n["file"])))
93
93
  end
94
94
  result.push(from_files)
95
95
  end
@@ -101,9 +101,9 @@ module Metanorma
101
101
  options = parse_options(block_match[3])
102
102
  contexts_items(block_match, document, express_indexes)
103
103
  .map do |items|
104
- if items['schemas']
105
- items['schemas'] = items['schemas'].map do |j|
106
- opts = options.merge('relative_path_prefix' => j['relative_path_prefix'])
104
+ if items["schemas"]
105
+ items["schemas"] = items["schemas"].map do |j|
106
+ opts = options.merge("relative_path_prefix" => j["relative_path_prefix"])
107
107
  decorate_context_items(j, opts)
108
108
  end
109
109
  end
@@ -112,9 +112,9 @@ module Metanorma
112
112
  context_items: items,
113
113
  context_name: block_match[2].strip)
114
114
  end.flatten
115
- rescue StandardError => e
116
- document.logger.warn("Failed to parse lutaml block: #{e.message}")
117
- []
115
+ rescue StandardError => e
116
+ document.logger.warn("Failed to parse lutaml block: #{e.message}")
117
+ []
118
118
  end
119
119
 
120
120
  def parse_options(options_string)
@@ -154,7 +154,8 @@ module Metanorma
154
154
  render_result, errors = Utils.render_liquid_string(
155
155
  template_string: context_lines.join("\n"),
156
156
  context_items: context_items,
157
- context_name: context_name
157
+ context_name: context_name,
158
+ document: document
158
159
  )
159
160
  Utils.notify_render_errors(document, errors)
160
161
  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
1
  require "expressir/express_exp/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,
@@ -62,11 +67,11 @@ module Metanorma
62
67
  end
63
68
 
64
69
  def express_write_cache(path, repository, document)
65
- root_path = Pathname.new(relative_file_path(document, ''))
70
+ root_path = Pathname.new(relative_file_path(document, ""))
66
71
  Expressir::ExpressExp::Cache
67
72
  .to_file(path,
68
- repository,
69
- root_path: root_path)
73
+ repository,
74
+ root_path: root_path)
70
75
  end
71
76
 
72
77
  def express_from_path(document, path)
@@ -84,24 +89,24 @@ module Metanorma
84
89
 
85
90
  def express_decorate_wrapper(wrapper, document)
86
91
  serialized = wrapper.to_liquid
87
- serialized['schemas'] = serialized['schemas'].map do |j|
88
- j.merge('relative_path_prefix' => Utils.relative_file_path(document, File.dirname(j['file'])))
92
+ serialized["schemas"] = serialized["schemas"].map do |j|
93
+ j.merge("relative_path_prefix" => Utils.relative_file_path(document, File.dirname(j["file"])))
89
94
  end
90
95
  serialized
91
96
  end
92
97
 
93
98
  def express_from_index(document, path)
94
99
  yaml_content = YAML.safe_load(File.read(path))
95
- root_path = yaml_content['path']
100
+ root_path = yaml_content["path"]
96
101
  schemas_paths = yaml_content
97
- .fetch('schemas')
98
- .map do |(schema_name, schema_values)|
99
- if schema_values['path']
100
- schema_values['path']
101
- else
102
- File.join(root_path.to_s, "#{schema_name}.exp")
103
- end
104
- end
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
105
110
  files_to_load = schemas_paths.map do |path|
106
111
  File.new(Utils.relative_file_path(document, path), encoding: "UTF-8")
107
112
  end
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.3.1".freeze
4
+ VERSION = "0.3.2".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "lutaml"
28
28
  spec.add_dependency "metanorma"
29
29
  spec.add_dependency "relaton-cli"
30
+ spec.add_dependency "reverse_adoc"
30
31
 
31
32
  spec.add_development_dependency "byebug"
32
33
  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.3.1
4
+ version: 0.3.2
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-03-30 00:00:00.000000000 Z
11
+ date: 2021-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: reverse_adoc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: byebug
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -233,12 +247,14 @@ files:
233
247
  - Dockerfile
234
248
  - Gemfile
235
249
  - LICENSE
250
+ - Makefile
236
251
  - README.adoc
237
252
  - Rakefile
238
253
  - bin/console
239
254
  - bin/setup
240
255
  - lib/metanorma-plugin-lutaml.rb
241
256
  - lib/metanorma/plugin/lutaml/express_remarks_decorator.rb
257
+ - lib/metanorma/plugin/lutaml/liquid/custom_filters.rb
242
258
  - lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb
243
259
  - lib/metanorma/plugin/lutaml/lutaml_preprocessor.rb
244
260
  - lib/metanorma/plugin/lutaml/lutaml_uml_attributes_table_preprocessor.rb