metanorma-generic 2.7.0 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,8 @@ require "asciidoctor"
2
2
  require "metanorma/standoc/converter"
3
3
  require "fileutils"
4
4
  require_relative "front"
5
+ require "metanorma"
6
+ require "pathname"
5
7
 
6
8
  module Metanorma
7
9
  module Generic
@@ -20,20 +22,17 @@ module Metanorma
20
22
  end
21
23
 
22
24
  def baselocation(loc)
23
- return nil if loc.nil?
24
-
25
+ loc.nil? and return nil
25
26
  return loc
26
- File.expand_path(File.join(File.dirname(
27
- self.class::_file || __FILE__,
28
- ), "..", "..", "..", loc))
29
27
  end
30
28
 
31
29
  def docidentifier_cleanup(xmldoc)
30
+ b = boilerplate_isodoc(xmldoc) or return
32
31
  template = configuration.docid_template ||
33
32
  "{{ organization_name_short }} {{ docnumeric }}"
34
33
  docid = xmldoc.at("//bibdata/docidentifier")
35
34
  docid&.text&.empty? or return
36
- id = boilerplate_isodoc(xmldoc).populate_template(template, nil)
35
+ id = b.populate_template(template, nil)
37
36
  (id.empty? and docid.remove) or docid.children = id
38
37
  end
39
38
 
@@ -58,6 +57,10 @@ module Metanorma
58
57
  def read_config_file(path_to_config_file)
59
58
  Metanorma::Generic.configuration
60
59
  .set_default_values_from_yaml_file(path_to_config_file)
60
+ # reregister Processor to Metanorma with updated values
61
+ if defined? Metanorma::Registry
62
+ Metanorma::Registry.instance.register(Metanorma::Generic::Processor)
63
+ end
61
64
  end
62
65
 
63
66
  def sectiontype_streamline(ret)
@@ -75,7 +78,12 @@ module Metanorma
75
78
  end
76
79
 
77
80
  def document(node)
78
- read_config_file(node.attr("customize")) if node.attr("customize")
81
+ if node.attr("customize")
82
+ p = node.attr("customize")
83
+ (Pathname.new p).absolute? or
84
+ p = File.expand_path(File.join(Metanorma::Utils::localdir(node), p))
85
+ read_config_file(p)
86
+ end
79
87
  super
80
88
  end
81
89
 
@@ -158,7 +166,7 @@ module Metanorma
158
166
  end
159
167
 
160
168
  def boilerplate_isodoc(xmldoc)
161
- conv = super
169
+ conv = super or return nil
162
170
  Metanorma::Generic::Configuration::CONFIG_ATTRS.each do |a|
163
171
  conv.meta.set(a, configuration.send(a))
164
172
  end