metanorma-plugin-lutaml 0.4.19 → 0.4.20

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: 630f5c9adbb662d5f2aea46dd1deb40cd4e6a935133214e10e1cf298dedd9f3b
4
- data.tar.gz: 733f2e388c638d3ca3081a220b47624abc505bbef3ad6e414b9d1b12adc508ee
3
+ metadata.gz: e771e99cf0ac118f04aa3b40610b0e071ff98d78ebaa34b7ac4516636a2e1808
4
+ data.tar.gz: 17ae5e488c425071a80aaa0799736b1f336611ef0caa68e2eebaa0788df86383
5
5
  SHA512:
6
- metadata.gz: f6dd4a103fff25ec175bd07da453eabfe7e767f0ef6663e22116dc98a85d62549432ad7348c05828cb51ae111293cc308269bfb07465a5d60ed874dc6a8407ae
7
- data.tar.gz: cf196784ea5a546c82e560b4dae9234a74a877aa64155f6d7e8a55d6b80acae00f125b6968d90eb18bf9bf3ed977a7bdecd4e2beb92f3de4f7f591fc9860a2fa
6
+ metadata.gz: 8260ba15824b2e1838e34e3ba3f5d954ee3dfaf6b697821ce55972aa8b428ea12a932b6eafb71275e5958b971f65a30481431c86a34f1de9e6b1a28d7c68010c
7
+ data.tar.gz: '008027e782ef69b19b6132a6fd139b8f04cd7dd5cc6e7ada361ef4c70c36923023213d3eccc4b30118c64421574700d1cf83677969047d99bceaf440e08bd8e4'
@@ -12,24 +12,38 @@ module Metanorma
12
12
  module Lutaml
13
13
  # Class for processing Lutaml files
14
14
  class LutamlPreprocessor < Asciidoctor::Extensions::Preprocessor
15
- REMARKS_ATTRIBUTE = "remarks".freeze
15
+ REMARKS_ATTRIBUTE = "remarks"
16
16
 
17
17
  def process(document, reader)
18
18
  input_lines = reader.readlines.to_enum
19
+ has_lutaml = !input_lines.select { |x| lutaml?(x) }.empty?
19
20
  express_indexes = Utils.parse_document_express_indexes(
20
21
  document,
21
- input_lines
22
+ input_lines,
22
23
  )
23
- result_content = processed_lines(document, input_lines, express_indexes)
24
- result_reader = Asciidoctor::PreprocessorReader.new(document, result_content)
25
- result_reader
24
+ result_content = processed_lines(document, input_lines,
25
+ express_indexes)
26
+ has_lutaml and log(document, result_content)
27
+ Asciidoctor::PreprocessorReader.new(document, result_content)
26
28
  end
27
29
 
28
30
  protected
29
31
 
32
+ def log(document, result)
33
+ File.open("#{document.attr('docfile')}.lutaml.log.txt",
34
+ "w:UTF-8") do |f|
35
+ f.write(result.join("\n"))
36
+ end
37
+ end
38
+
39
+ def lutaml?(line)
40
+ line.match(/^\[(?:\blutaml\b|\blutaml_express\b),([^,]+)?,?([^,]+)?,?([^,]+)?\]/)
41
+ end
42
+
30
43
  def content_from_files(document, file_paths)
31
44
  file_list = file_paths.map do |file_path|
32
- File.new(Utils.relative_file_path(document, file_path), encoding: "UTF-8")
45
+ File.new(Utils.relative_file_path(document, file_path),
46
+ encoding: "UTF-8")
33
47
  end
34
48
  ::Lutaml::Parser.parse(file_list)
35
49
  end
@@ -43,7 +57,7 @@ module Metanorma
43
57
  .push(*process_text_blocks(
44
58
  document,
45
59
  input_lines,
46
- express_indexes
60
+ express_indexes,
47
61
  ))
48
62
  end
49
63
  result
@@ -51,7 +65,7 @@ module Metanorma
51
65
 
52
66
  def process_text_blocks(document, input_lines, express_indexes)
53
67
  line = input_lines.next
54
- block_match = line.match(/^\[(?:\blutaml\b|\blutaml_express\b),([^,]+)?,?([^,]+)?,?([^,]+)?\]/)
68
+ block_match = lutaml?(line)
55
69
  return [line] if block_match.nil?
56
70
 
57
71
  end_mark = input_lines.next
@@ -97,7 +111,8 @@ module Metanorma
97
111
  result
98
112
  end
99
113
 
100
- def parse_template(document, current_block, block_match, express_indexes)
114
+ def parse_template(document, current_block, block_match,
115
+ express_indexes)
101
116
  options = parse_options(block_match[3])
102
117
  contexts_items(block_match, document, express_indexes)
103
118
  .map do |items|
@@ -112,9 +127,9 @@ module Metanorma
112
127
  context_items: items,
113
128
  context_name: block_match[2].strip)
114
129
  end.flatten
115
- rescue StandardError => e
116
- document.logger.warn("Failed to parse lutaml block: #{e.message}")
117
- []
130
+ rescue StandardError => e
131
+ document.logger.warn("Failed to parse lutaml block: #{e.message}")
132
+ []
118
133
  end
119
134
 
120
135
  def parse_options(options_string)
@@ -155,7 +170,7 @@ module Metanorma
155
170
  template_string: context_lines.join("\n"),
156
171
  context_items: context_items,
157
172
  context_name: context_name,
158
- document: document
173
+ document: document,
159
174
  )
160
175
  Utils.notify_render_errors(document, errors)
161
176
  render_result.split("\n")
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.4.19".freeze
4
+ VERSION = "0.4.20".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -17,7 +17,9 @@ Gem::Specification.new do |spec|
17
17
  # Specify which files should be added to the gem when it is released.
18
18
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
19
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
21
23
  end
22
24
  spec.bindir = "exe"
23
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -30,10 +32,9 @@ Gem::Specification.new do |spec|
30
32
  spec.add_dependency "relaton-cli"
31
33
  spec.add_dependency "reverse_adoc"
32
34
 
33
- spec.add_development_dependency "byebug"
35
+ spec.add_development_dependency "debug"
34
36
  spec.add_development_dependency "equivalent-xml"
35
37
  spec.add_development_dependency "metanorma-standoc"
36
- spec.add_development_dependency "pry", "~> 0.12.2"
37
38
  spec.add_development_dependency "rake", "~> 13"
38
39
  spec.add_development_dependency "rspec", "~> 3.6"
39
40
  spec.add_development_dependency "rubocop", "= 0.54.0"
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.19
4
+ version: 0.4.20
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: 2023-03-27 00:00:00.000000000 Z
11
+ date: 2023-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: byebug
98
+ name: debug
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: pry
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 0.12.2
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 0.12.2
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rake
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -301,7 +287,7 @@ homepage: https://github.com/metanorma/metanorma-plugin-lutaml
301
287
  licenses:
302
288
  - BSD-2-Clause
303
289
  metadata: {}
304
- post_install_message:
290
+ post_install_message:
305
291
  rdoc_options: []
306
292
  require_paths:
307
293
  - lib
@@ -316,8 +302,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
302
  - !ruby/object:Gem::Version
317
303
  version: '0'
318
304
  requirements: []
319
- rubygems_version: 3.3.7
320
- signing_key:
305
+ rubygems_version: 3.3.26
306
+ signing_key:
321
307
  specification_version: 4
322
308
  summary: Metanorma plugin for LutaML
323
309
  test_files: []