metanorma 1.1.5 → 1.1.6

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: 42020b6888a6b5d4d11678cc5d3d217e93ced978e477d05fee31a6593722f78b
4
- data.tar.gz: 4379ba9bcf18655c119598b44ead30f223d843edb33ce53205d4ad6c16826904
3
+ metadata.gz: aecd92b31139e0a3f76ff7485f3bde8e5b6d89be735eafadc0215962b8b1aec1
4
+ data.tar.gz: 4c00ec06b3d9a632bbdbc810aa46635fef4c85f88382c6e014a8238261987f7e
5
5
  SHA512:
6
- metadata.gz: 67525ff08b409c36a90cc8725dc150a518b2c3888f0b3518cc83113b51dcc739ba89120681fe0c2e36c4c6b8771178afe1abe25c64887aee93b29fb055c82a4e
7
- data.tar.gz: c0f35a9f5f0e3b0397fb0f81eaf84b90be85f09af4cb99a25e9ac146e0b9658c0b0c26883015c0a8979d656f12d57f5dc0cb24f1af92fa1cb9c58ba7f5e13a90
6
+ metadata.gz: 570efb165e57540e107f6f29acd53a373d702c825eefd1c9ee3e04fac4644432fc9347400dea3a1b48f8aa03c28ac31634bd4a3545dc86622768d2285a9cb87f
7
+ data.tar.gz: 554df7349b548f35d6fbf3f04d453964c3aa7a9067c496f4815eed42de07ceeaca4b93a7278f41709343744569c7c45b096916b184050366369597b22281ed46
@@ -12,10 +12,10 @@ module Metanorma
12
12
 
13
13
  # @return [Array<String>] documents-inline to inject the XML into
14
14
  # the collection manifest; documents-external to keeps them outside
15
- attr_reader :directives
15
+ attr_accessor :directives
16
16
 
17
17
  # @return [Hash<String, Metanorma::Document>]
18
- attr_reader :documents
18
+ attr_accessor :documents
19
19
 
20
20
  # @param file [String] path to source file
21
21
  # @param directives [Array<String>] documents-inline to inject the XML into
@@ -49,9 +49,24 @@ module Metanorma
49
49
  folder = File.dirname col.file
50
50
  cr = new(col.to_xml, folder, options)
51
51
  cr.files
52
+ cr.concatenate(col, options)
52
53
  cr.coverpage if options[:format]&.include?(:html)
53
54
  end
54
55
 
56
+ def concatenate(col, options)
57
+ options[:format].each do |e|
58
+ next unless %i(presentation xml).include?(e)
59
+ ext = e == :presentation ? "presentation.xml" : e.to_s
60
+ out = col.clone
61
+ out.directives << "documents-inline"
62
+ out.documents.keys.each do |id|
63
+ filename = @files[id][:outputs][e]
64
+ out.documents[id] = Metanorma::Document.raw_file(filename)
65
+ end
66
+ File.open(File.join(@outdir, "collection.#{ext}"), "w:UTF-8") { |f| f.write(out.to_xml) }
67
+ end
68
+ end
69
+
55
70
  # Dummy class
56
71
  class Dummy
57
72
  def attr(_xyz); end
@@ -220,7 +235,7 @@ module Metanorma
220
235
  docid = bib&.at(ns("./docidentifier"))&.text
221
236
  unless @files[docid]
222
237
  warn "Cannot find crossreference to document #{docid} in document "\
223
- "#{identifier}!"
238
+ "#{identifier}!"
224
239
  abort
225
240
  end
226
241
  id = bib["id"]
@@ -288,9 +303,12 @@ module Metanorma
288
303
  # warn "metanorma compile -x html #{f.path}"
289
304
  c = Compile.new
290
305
  c.compile f.path, format: :asciidoc, extension_keys: @format
291
- @format.each do |ext|
306
+ @files[identifier][:outputs] = {}
307
+ @format.each do |e|
308
+ ext = c.processor.output_formats[e]
292
309
  fn = File.basename(filename).sub(/(?<=\.)[^\.]+$/, ext.to_s)
293
310
  FileUtils.mv f.path.sub(/\.xml$/, ".#{ext}"), File.join(@outdir, fn)
311
+ @files[identifier][:outputs][e] = File.join(@outdir, fn)
294
312
  end
295
313
  end
296
314
  end
@@ -5,7 +5,7 @@ require "htmlentities"
5
5
  module Metanorma
6
6
  class Compile
7
7
  # @return [Array<String>]
8
- attr_reader :errors
8
+ attr_reader :errors, :processor
9
9
 
10
10
  def initialize
11
11
  @registry = Metanorma::Registry.instance
@@ -4,9 +4,10 @@ module Metanorma
4
4
  attr_reader :file
5
5
 
6
6
  # @param bibitem [RelatonBib::BibliographicItem]
7
- def initialize(bibitem, file)
7
+ def initialize(bibitem, file, options = {})
8
8
  @bibitem = bibitem
9
9
  @file = file
10
+ @raw = options[:raw]
10
11
  end
11
12
 
12
13
  class << self
@@ -22,6 +23,12 @@ module Metanorma
22
23
  new from_xml(xml)
23
24
  end
24
25
 
26
+ # raw XML file, can be used to put in entire file instead of just bibitem
27
+ def raw_file(filename)
28
+ doc = Nokogiri::XML(File.read(filename, encoding: "UTF-8"))
29
+ new(doc, filename, raw: true)
30
+ end
31
+
25
32
  private
26
33
 
27
34
  # #param xml [Nokogiri::XML::Document, Nokogiri::XML::Element]
@@ -47,7 +54,7 @@ module Metanorma
47
54
  when :xml
48
55
  from_xml Nokogiri::XML(File.read(file, encoding: "UTF-8"))
49
56
  when :yaml
50
- yaml = File.read(file, ecoding: "UTF-8")
57
+ yaml = File.read(file, encoding: "UTF-8")
51
58
  Relaton::Cli::YAMLConvertor.convert_single_file(yaml)
52
59
  end
53
60
  end
@@ -68,15 +75,19 @@ module Metanorma
68
75
 
69
76
  # @return [String]
70
77
  def type
71
- @type ||= (@bibitem.docidentifier.first&.type ||
72
- @bibitem.docidentifier.first&.id&.match(/^[^\s]+/)&.to_s)&.downcase ||
73
- "standoc"
78
+ @type ||= (@bibitem.docidentifier.first&.type&.downcase ||
79
+ @bibitem.docidentifier.first&.id&.match(/^[^\s]+/)&.to_s)&.downcase ||
80
+ "standoc"
74
81
  end
75
82
 
76
83
  private
77
84
 
78
85
  def render_xml(builder)
79
- builder.send(type + "-standard") { |b| @bibitem.to_xml b, bibdata: true }
86
+ if @raw
87
+ builder << @bibitem.root.to_xml
88
+ else
89
+ builder.send(type + "-standard") { |b| @bibitem.to_xml b, bibdata: true }
90
+ end
80
91
  end
81
92
  end
82
93
  end
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
@@ -27,13 +27,15 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency 'htmlentities'
28
28
  spec.add_runtime_dependency 'nokogiri'
29
29
  spec.add_runtime_dependency 'mn2pdf', "~> 1"
30
- spec.add_dependency "relaton-cli", "~> 1.3.0"
30
+ # get relaton-cli to avoic circular reference with metanorma-standoc
31
+ #spec.add_dependency "relaton-cli"
32
+ #spec.add_dependency "metanorma-standoc", "~> 1.5.3"
31
33
 
32
34
  spec.add_development_dependency "rake", "~> 12.0"
33
35
  spec.add_development_dependency "rspec", "~> 3.0"
34
36
  spec.add_development_dependency "byebug", "~> 10.0"
35
37
  spec.add_development_dependency "rspec-command", "~> 1.0"
36
38
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
37
- spec.add_development_dependency "metanorma-iso", "~> 1.5"
38
- spec.add_development_dependency "isodoc", "~> 1.2.1"
39
+ spec.add_development_dependency "metanorma-iso", "~> 1.5.8"
40
+ #spec.add_development_dependency "isodoc", "~> 1.2.1"
39
41
  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.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-11 00:00:00.000000000 Z
11
+ date: 2020-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1'
69
- - !ruby/object:Gem::Dependency
70
- name: relaton-cli
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.3.0
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.3.0
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rake
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -156,28 +142,14 @@ dependencies:
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: '1.5'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '1.5'
167
- - !ruby/object:Gem::Dependency
168
- name: isodoc
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: 1.2.1
145
+ version: 1.5.8
174
146
  type: :development
175
147
  prerelease: false
176
148
  version_requirements: !ruby/object:Gem::Requirement
177
149
  requirements:
178
150
  - - "~>"
179
151
  - !ruby/object:Gem::Version
180
- version: 1.2.1
152
+ version: 1.5.8
181
153
  description: Library to process any Metanorma standard.
182
154
  email:
183
155
  - open.source@ribose.com