metanorma 1.0.6 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b51503237da3dfd54719591c47f599bca877d414528c4cf9a69abdb19aec9e9
4
- data.tar.gz: 1588206551663889040f94194789cee7f2fb9b095775591a08f7b613ce59fbfe
3
+ metadata.gz: 315077d28cfe3e052808e9890d2f3c3f571b7350788e6d6423be1746e5559ef4
4
+ data.tar.gz: f8a9c7d3055af8a687fe8df52b725b1fadbceb8920bef8ea449af5cde0aafb6a
5
5
  SHA512:
6
- metadata.gz: 6f7dd77c9a6bf129594e3bfdabc1626bcb4c58a9b68454b09e1d216f7c9e43d4ebce62ce980ed762e0ad3e9f5c3c3456b9473fe7b1670e13bdc7c2d286edc1ec
7
- data.tar.gz: 9c4125021226bdd561436e37e2fbacd4bd3c3bfa48845607282dd7ce3b4789e218e2aaa835364de7268c684bbf667e5267a6224db5a4c268fce180136b835391
6
+ metadata.gz: ab023b366ca20c7d4fe3785e00698d2ccd868c0d119b0df74a5ba52e11f4bd69b884b18fea2b820838708c3bae5516be911c9e82de8302b6ade8cf52c99c36b4
7
+ data.tar.gz: 3f3520b67f58296be755b0e8b2b9cfb0e98611e214f73e131e1eccde7b74dfd611db1f476cee84d5071f6ef0c1b7b801ed9874e7261697b52fb7bf288282c57d
data/.gitignore CHANGED
@@ -16,3 +16,6 @@
16
16
 
17
17
  # rspec failure tracking
18
18
  .rspec_status
19
+ .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
20
+ Gemfile.lock
21
+ relaton/
@@ -4,8 +4,12 @@ require "htmlentities"
4
4
 
5
5
  module Metanorma
6
6
  class Compile
7
+ # @return [Array<String>]
8
+ attr_reader :errors
9
+
7
10
  def initialize
8
11
  @registry = Metanorma::Registry.instance
12
+ @errors = []
9
13
  end
10
14
 
11
15
  def compile(filename, options = {})
@@ -89,14 +93,22 @@ module Metanorma
89
93
  end
90
94
 
91
95
  def get_extensions(options)
92
- options[:extension_keys] ||= @processor.output_formats.inject([]) do |memo, (k, _)|
93
- memo << k; memo
96
+ options[:extension_keys] ||= @processor.output_formats.reduce([]) do |memo, (k, _)|
97
+ memo << k
94
98
  end
95
- extensions = options[:extension_keys].inject([]) do |memo, e|
96
- @processor.output_formats[e] and memo << e or
97
- Util.log("[metanorma] Error: #{e} format is not supported for this standard.", :error)
98
- memo
99
+ extensions = options[:extension_keys].reduce([]) do |memo, e|
100
+ if @processor.output_formats[e]
101
+ memo << e
102
+ else
103
+ message = "[metanorma] Error: #{e} format is not supported for this standard."
104
+ @errors << message
105
+ Util.log(message, :error)
106
+ memo
107
+ end
99
108
  end
109
+ if !extensions.include?(:presentation) and extensions.any? { |e| @processor.use_presentation_xml(e) }
110
+ extensions << :presentation
111
+ end
100
112
  extensions
101
113
  end
102
114
 
@@ -195,10 +207,35 @@ module Metanorma
195
207
  end
196
208
  end
197
209
 
210
+ # dependency ordering
211
+ def sort_extensions_execution(ext)
212
+ case ext
213
+ when :xml then 0
214
+ when :rxl then 1
215
+ when :presentation then 2
216
+ else
217
+ 99
218
+ end
219
+ end
220
+
221
+ def wrap_html(options, file_extension, outfilename)
222
+ if options[:wrapper] and /html$/.match file_extension
223
+ outfilename = outfilename.sub(/\.html$/, "")
224
+ FileUtils.mkdir_p outfilename
225
+ FileUtils.mv "#{outfilename}.html", outfilename
226
+ FileUtils.mv "#{outfilename}_images", outfilename, force: true
227
+ end
228
+ end
229
+
230
+ # isodoc is Raw Metanorma XML
198
231
  def process_extensions(extensions, file, isodoc, options)
199
- extensions.each do |ext|
200
- isodoc_options = @processor.extract_options(file)
201
- isodoc_options[:datauriimage] = true if options[:datauriimage]
232
+ xml_name = options[:filename].sub(/\.[^.]+$/, ".xml")
233
+ presentationxml_name = options[:filename].sub(/\.[^.]+$/, ".presentation.xml")
234
+ isodoc_options = @processor.extract_options(file)
235
+ isodoc_options[:datauriimage] = true if options[:datauriimage]
236
+ extensions.sort do |a, b|
237
+ sort_extensions_execution(a) <=> sort_extensions_execution(b)
238
+ end.each do |ext|
202
239
  file_extension = @processor.output_formats[ext]
203
240
  outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
204
241
  if ext == :rxl
@@ -206,17 +243,15 @@ module Metanorma
206
243
  relaton_export(isodoc, options)
207
244
  else
208
245
  begin
209
- @processor.output(isodoc, outfilename, ext, isodoc_options)
246
+ #require "byebug"; byebug
247
+ @processor.use_presentation_xml(ext) ?
248
+ @processor.output(nil, presentationxml_name, outfilename, ext, isodoc_options) :
249
+ @processor.output(isodoc, xml_name, outfilename, ext, isodoc_options)
210
250
  rescue StandardError => e
211
251
  puts e.message
212
252
  end
213
253
  end
214
- if options[:wrapper] and /html$/.match file_extension
215
- outfilename = outfilename.sub(/\.html$/, "")
216
- FileUtils.mkdir_p outfilename
217
- FileUtils.mv "#{outfilename}.html", outfilename
218
- FileUtils.mv "#{outfilename}_images", outfilename, force: true
219
- end
254
+ wrap_html(options, file_extension, outfilename)
220
255
  end
221
256
  end
222
257
  end
@@ -15,6 +15,7 @@ module Metanorma
15
15
  def output_formats
16
16
  {
17
17
  xml: "xml",
18
+ presentation: "presentation.xml",
18
19
  rxl: "rxl"
19
20
  }
20
21
  end
@@ -23,7 +24,15 @@ module Metanorma
23
24
  raise "This is an abstract class!"
24
25
  end
25
26
 
26
- def output(isodoc_node, outname, format, options={})
27
+ def use_presentation_xml(ext)
28
+ case ext
29
+ when :html, :doc, :pdf then true
30
+ else
31
+ false
32
+ end
33
+ end
34
+
35
+ def output(isodoc_node, inname, outname, format, options={})
27
36
  File.open(outname, "w:UTF-8") { |f| f.write(isodoc_node) }
28
37
  end
29
38
 
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.0.6"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "byebug", "~> 10.0"
34
34
  spec.add_development_dependency "rspec-command", "~> 1.0"
35
35
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
36
- spec.add_development_dependency "metanorma-iso", "~> 1.3"
36
+ spec.add_development_dependency "metanorma-iso", "~> 1.4"
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.3'
145
+ version: '1.4'
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: '1.3'
152
+ version: '1.4'
153
153
  description: Library to process any Metanorma standard.
154
154
  email:
155
155
  - open.source@ribose.com
@@ -202,7 +202,7 @@ homepage: https://github.com/metanorma/metanorma
202
202
  licenses:
203
203
  - BSD-2-Clause
204
204
  metadata: {}
205
- post_install_message:
205
+ post_install_message:
206
206
  rdoc_options: []
207
207
  require_paths:
208
208
  - lib
@@ -217,9 +217,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  - !ruby/object:Gem::Version
218
218
  version: '0'
219
219
  requirements: []
220
- rubyforge_project:
221
- rubygems_version: 2.7.6
222
- signing_key:
220
+ rubygems_version: 3.0.3
221
+ signing_key:
223
222
  specification_version: 4
224
223
  summary: Metanorma is the standard of standards; the metanorma gem allows you to create
225
224
  any standard document type supported by Metanorma.