metanorma-plugin-lutaml 0.2.4.pre.alpha.2 → 0.2.4.pre.alpha.3

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: d72d3bfa8e8dd1e0a8321f97d9f32b46652e7961036d623d293ed07a0a19c6b1
4
- data.tar.gz: 18a4eec7fba09c7f1466ae46fdf33d07e70855a9f00b1e4490252c22a7529ed7
3
+ metadata.gz: 15b69c1b6c78145b90da125ebc64ef043c4ebc88912708ef3183581548e12a1d
4
+ data.tar.gz: e8c607b6654b776d8363d439265db8c8efafce0453d0992e81699ba1273d7fd8
5
5
  SHA512:
6
- metadata.gz: 5440d8e90b6184ab41d1969e6520d3745013aa987314b9f50a524066d810497f0be86481bdcd6195bfe2982e1c8de4562226f373746e18bbd4f173796d043f5d
7
- data.tar.gz: ee100c14d0bf8a945732da8ed86f8816ca67ce02dbe7fea80f14a04ac74fcd4efda65cedff89e5262725f044b3a69de85461d6fb5c724392cf01642b6afdf317
6
+ metadata.gz: 2e2b41a80e0058e29ab19bc4cc5957fc821f50d49d3408d27593f4abb62638eb5799dbd4190bbb6f56cdd226ecd96bb95ca2e334907a575850e01f1889e7382b
7
+ data.tar.gz: e2da2ed10903ce9561135f006a0e5cab90c18c3683b5fd24c71e0bb0b85a6f2f07a5890c6b9ab790d1cdc7b23e27e57c5b35f83158592de32abb72789b4bf608
@@ -27,10 +27,11 @@ module Metanorma
27
27
 
28
28
  protected
29
29
 
30
- def content_from_file(document, file_path)
31
- ::Lutaml::Parser
32
- .parse(File.new(Utils.relative_file_path(document, file_path),
33
- encoding: "UTF-8"))
30
+ def content_from_files(document, file_paths)
31
+ file_list = file_paths.map do |file_path|
32
+ File.new(Utils.relative_file_path(document, file_path), encoding: "UTF-8")
33
+ end
34
+ ::Lutaml::Parser.parse(file_list)
34
35
  end
35
36
 
36
37
  private
@@ -72,30 +73,38 @@ module Metanorma
72
73
 
73
74
  def contexts_items(block_match, document, express_indexes)
74
75
  contexts_names = block_match[1].split(";").map(&:strip)
75
- contexts_names.each_with_object([]) do |path, res|
76
+ file_paths = []
77
+ result = contexts_names.each_with_object([]) do |path, res|
76
78
  if express_indexes[path]
77
79
  res.push(*express_indexes[path])
78
80
  else
79
- res.push(content_from_file(document, path)
80
- .to_liquid
81
- .merge('relative_path_prefix' => Utils.relative_file_path(document, File.dirname(path))))
81
+ file_paths.push(path)
82
82
  end
83
83
  end
84
+ if !file_paths.empty?
85
+ from_files = content_from_files(document, file_paths)
86
+ .map do |n|
87
+ n.to_liquid.map { |j| j.merge('relative_path_prefix' => Utils.relative_file_path(document, File.dirname(j['file']))) }
88
+ end
89
+ .flatten
90
+ result += from_files
91
+ end
92
+ result
84
93
  end
85
94
 
86
95
  def parse_template(document, current_block, block_match, express_indexes)
87
96
  options = parse_options(block_match[3])
88
97
  contexts_items(block_match, document, express_indexes)
89
- .map do |context_items|
98
+ .map do |items|
99
+ opts = options.merge('relative_path_prefix' => items['relative_path_prefix'])
90
100
  parse_context_block(document: document,
91
101
  context_lines: current_block,
92
- context_items: decorate_context_items(context_items,
93
- options.merge('relative_path_prefix' => context_items['relative_path_prefix'])),
102
+ context_items: decorate_context_items(items, opts),
94
103
  context_name: block_match[2].strip)
95
104
  end.flatten
96
- rescue StandardError => e
97
- document.logger.warn("Failed to parse lutaml block: #{e.message}")
98
- []
105
+ # rescue StandardError => e
106
+ # document.logger.warn("Failed to parse lutaml block: #{e.message}")
107
+ # []
99
108
  end
100
109
 
101
110
  def parse_options(options_string)
@@ -29,6 +29,7 @@ module Metanorma
29
29
  ::Lutaml::Parser
30
30
  .parse(File.new(Utils.relative_file_path(document, file_path),
31
31
  encoding: "UTF-8"))
32
+ .first
32
33
  end
33
34
 
34
35
  def processed_lines(document, input_lines)
@@ -38,9 +38,10 @@ module Metanorma
38
38
  next if [".", ".."].include?(path)
39
39
 
40
40
  begin
41
+ parsed = ::Lutaml::Parser.parse(File.new(path, encoding: "UTF-8"))
42
+ parsed = parsed.map { |n| n.to_liquid.map { |j| j.merge('relative_path_prefix' => Utils.relative_file_path(document, File.dirname(j['file']))) } }.flatten
41
43
  idxs[name]
42
- .push(::Lutaml::Parser.parse(File.new(path, encoding: "UTF-8")).to_liquid)
43
- .merge("relative_path_prefix" => folder)
44
+ .push(*parsed)
44
45
  rescue StandardError => e
45
46
  document.logger.warn("Failed to load #{path}: #{e.message}")
46
47
  end
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.2.4-alpha.2".freeze
4
+ VERSION = "0.2.4-alpha.3".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_dependency "liquid"
27
- spec.add_dependency "lutaml", "0.4.1.pre.alpha.1"
27
+ spec.add_dependency "lutaml", "0.4.1.pre.alpha.2"
28
28
  spec.add_dependency "lutaml-uml", "~> 0.2.0"
29
29
  spec.add_dependency "metanorma"
30
30
  spec.add_dependency "relaton-cli"
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.2.4.pre.alpha.2
4
+ version: 0.2.4.pre.alpha.3
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-02-12 00:00:00.000000000 Z
11
+ date: 2021-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.1.pre.alpha.1
33
+ version: 0.4.1.pre.alpha.2
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.4.1.pre.alpha.1
40
+ version: 0.4.1.pre.alpha.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: lutaml-uml
43
43
  requirement: !ruby/object:Gem::Requirement