metanorma-generic 1.8.0 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,11 +25,11 @@ module IsoDoc
25
25
  def default_fonts(options)
26
26
  {
27
27
  bodyfont: (
28
- options[:script] == "Hans" ? '"SimSun",serif' :
28
+ options[:script] == "Hans" ? '"Source Han Sans",serif' :
29
29
  configuration.html_bodyfont || '"Overpass",sans-serif'
30
30
  ),
31
31
  headerfont: (
32
- options[:script] == "Hans" ? '"SimHei",sans-serif' :
32
+ options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
33
33
  configuration.html_headerfont || '"Overpass",sans-serif'
34
34
  ),
35
35
  monospacefont: configuration.html_monospacefont || '"Space Mono",monospace',
@@ -48,8 +48,7 @@ module IsoDoc
48
48
  html_doc_path("html_generic_titlepage.html"),
49
49
  htmlintropage: baselocation(configuration.htmlintropage) ||
50
50
  html_doc_path("html_generic_intro.html"),
51
- scripts: baselocation(configuration.scripts) ||
52
- html_doc_path("scripts.html"),
51
+ scripts: baselocation(configuration.scripts),
53
52
  i18nyaml: (configuration.i18nyaml.is_a?(String) ?
54
53
  baselocation(configuration.i18nyaml) : nil)
55
54
  }.transform_values { |v| v&.empty? ? nil : v }
@@ -4,20 +4,20 @@ require_relative "init"
4
4
  require_relative "utils"
5
5
 
6
6
  class Nokogiri::XML::Node
7
- TYPENAMES = {1=>'element',2=>'attribute',3=>'text',4=>'cdata',8=>'comment'}
7
+ TYPENAMES = { 1 => "element", 2 => "attribute", 3 => "text",
8
+ 4 => "cdata", 8 => "comment" }.freeze
8
9
  def to_hash
9
- ret = {kind:TYPENAMES[node_type],name:name}.tap do |h|
10
- h.merge! text:text&.strip
10
+ { kind: TYPENAMES[node_type], name: name }.tap do |h|
11
+ h[:text] = text&.strip
11
12
  a = attribute_nodes.map(&:to_hash)
12
13
  if element? && !a.empty?
13
- h.merge! attr: a.inject({}) { |m, v| m[v[:name]] = v[:text]; m }
14
+ h[:attr] = a.inject({}) { |m, v| m[v[:name]] = v[:text]; m }
14
15
  end
15
16
  c = children.map(&:to_hash)
16
17
  if element? && !(c&.size == 1 && c[0][:kind] == "text")
17
18
  h.merge! kids: c.delete_if { |n| n[:kind] == "text" && n[:text].empty? }
18
19
  end
19
20
  end
20
- ret
21
21
  end
22
22
  end
23
23
 
@@ -27,15 +27,16 @@ end
27
27
 
28
28
  module IsoDoc
29
29
  module Generic
30
-
31
30
  class Metadata < IsoDoc::Metadata
32
31
  def initialize(lang, script, labels)
33
32
  super
34
33
  here = File.dirname(__FILE__)
35
- default_logo_path = File.expand_path(File.join(here, "html", "logo.jpg"))
34
+ default_logo_path =
35
+ File.expand_path(File.join(here, "html", "logo.jpg"))
36
36
  set(:logo, baselocation(configuration.logo_path) || default_logo_path)
37
37
  unless configuration.logo_paths.nil?
38
- set(:logo_paths, Array(configuration.logo_paths).map { |p| baselocation(p) })
38
+ set(:logo_paths,
39
+ Array(configuration.logo_paths).map { |p| baselocation(p) })
39
40
  end
40
41
  end
41
42
 
@@ -43,8 +44,8 @@ module IsoDoc
43
44
  attr_accessor :_file
44
45
  end
45
46
 
46
- def self.inherited( k )
47
- k._file = caller_locations.first.absolute_path
47
+ def self.inherited(klass) # rubocop:disable Lint/MissingSuper
48
+ klass._file = caller_locations(1..1).first.absolute_path
48
49
  end
49
50
 
50
51
  def author(isoxml, _out)
@@ -55,6 +56,7 @@ module IsoDoc
55
56
 
56
57
  def stage_abbr(status)
57
58
  return super unless configuration.stage_abbreviations
59
+
58
60
  Hash(configuration.stage_abbreviations).dig(status)
59
61
  end
60
62
 
@@ -65,32 +67,35 @@ module IsoDoc
65
67
 
66
68
  def doctype(isoxml, _out)
67
69
  super
68
- b = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}")) ||
70
+ b = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}")) ||
69
71
  isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}")) || return
70
72
  a = b["abbreviation"] and set(:doctype_abbr, a)
71
73
  end
72
74
 
73
- def xmlhash2hash(h)
75
+ def xmlhash2hash(hash)
74
76
  ret = {}
75
- return ret if h.nil? || h[:kind] != "element"
76
- h[:attr].nil? or h[:attr].each { |k, v| ret["#{h[:name]}_#{k}"] = v }
77
- ret[h[:name]] = h[:kids] ? xmlhash2hash_kids(h) : h[:text]
77
+ return ret if hash.nil? || hash[:kind] != "element"
78
+
79
+ hash[:attr].nil? or
80
+ hash[:attr].each { |k, v| ret["#{hash[:name]}_#{k}"] = v }
81
+ ret[hash[:name]] = hash[:kids] ? xmlhash2hash_kids(hash) : hash[:text]
78
82
  ret
79
83
  end
80
84
 
81
- def xmlhash2hash_kids(h)
85
+ def xmlhash2hash_kids(hash)
82
86
  c = {}
83
- h[:kids].each do |n|
87
+ hash[:kids].each do |n|
84
88
  xmlhash2hash(n).each do |k1, v1|
85
- c[k1] = c[k1].nil? ? v1 :
86
- c[k1].is_a?(Array) ? c[k1] << v1 :
87
- [c[k1], v1]
89
+ c[k1] = if c[k1].nil? then v1
90
+ elsif c[k1].is_a?(Array) then c[k1] << v1
91
+ else [c[k1], v1]
92
+ end
88
93
  end
89
94
  end
90
95
  c
91
96
  end
92
97
 
93
- def ext(isoxml, out)
98
+ def ext(isoxml, _out)
94
99
  b = isoxml&.at(ns("//bibdata/ext")) or return
95
100
  set(:metadata_extensions, xmlhash2hash(b.to_hash)["ext"])
96
101
  end
@@ -22,9 +22,9 @@ module IsoDoc
22
22
 
23
23
  def default_fonts(options)
24
24
  {
25
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif'
25
+ bodyfont: (options[:script] == "Hans" ? '"Source Han Sans",serif'
26
26
  : configuration.html_bodyfont || '"Overpass",sans-serif'),
27
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
27
+ headerfont: (options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
28
28
  configuration.html_headerfont || '"Overpass",sans-serif'),
29
29
  monospacefont: configuration.html_monospacefont || '"Space Mono",monospace'
30
30
  }.transform_values { |v| v&.empty? ? nil : v }
@@ -24,11 +24,11 @@ module IsoDoc
24
24
  def default_fonts(options)
25
25
  {
26
26
  bodyfont: (
27
- options[:script] == "Hans" ? '"SimSun",serif' :
27
+ options[:script] == "Hans" ? '"Source Han Sans",serif' :
28
28
  configuration.word_bodyfont || '"Arial",sans-serif'
29
29
  ),
30
30
  headerfont: (
31
- options[:script] == "Hans" ? '"SimHei",sans-serif' :
31
+ options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
32
32
  configuration.word_headerfont || '"Arial",sans-serif'
33
33
  ),
34
34
  monospacefont: configuration.word_monospacefont || '"Courier New",monospace',
@@ -27,31 +27,15 @@ module Metanorma
27
27
 
28
28
  def extract_options(file)
29
29
  head = file.sub(/\n\n.*$/m, "\n")
30
- /\n:htmlstylesheet: (?<htmlstylesheet>[^\n]+)\n/ =~ head
31
- /\n:htmlcoverpage: (?<htmlcoverpage>[^\n]+)\n/ =~ head
32
- /\n:htmlintropage: (?<htmlintropage>[^\n]+)\n/ =~ head
33
- /\n:scripts: (?<scripts>[^\n]+)\n/ =~ head
34
- /\n:wordstylesheet: (?<wordstylesheet>[^\n]+)\n/ =~ head
35
- /\n:standardstylesheet: (?<standardstylesheet>[^\n]+)\n/ =~ head
36
- /\n:header: (?<header>[^\n]+)\n/ =~ head
37
- /\n:wordcoverpage: (?<wordcoverpage>[^\n]+)\n/ =~ head
38
- /\n:wordintropage: (?<wordintropage>[^\n]+)\n/ =~ head
39
- /\n:ulstyle: (?<ulstyle>[^\n]+)\n/ =~ head
40
- /\n:olstyle: (?<olstyle>[^\n]+)\n/ =~ head
41
- new_options = {
42
- htmlstylesheet: defined?(htmlstylesheet) ? htmlstylesheet : nil,
43
- htmlcoverpage: defined?(htmlcoverpage) ? htmlcoverpage : nil,
44
- htmlintropage: defined?(htmlintropage) ? htmlintropage : nil,
45
- scripts: defined?(scripts) ? scripts : nil,
46
- wordstylesheet: defined?(wordstylesheet) ? wordstylesheet : nil,
47
- standardstylesheet: defined?(standardstylesheet) ? standardstylesheet : nil,
48
- header: defined?(header) ? header : nil,
49
- wordcoverpage: defined?(wordcoverpage) ? wordcoverpage : nil,
50
- wordintropage: defined?(wordintropage) ? wordintropage : nil,
51
- ulstyle: defined?(ulstyle) ? ulstyle : nil,
52
- olstyle: defined?(olstyle) ? olstyle : nil,
53
- }.reject { |_, val| val.nil? }
54
- super.merge(new_options)
30
+ ret = %w(htmlstylesheet htmlcoverpage htmlintropage scripts scripts-pdf
31
+ wordstylesheet standardstylesheet header wordcoverpage
32
+ wordintropage datauriimage htmltoclevels doctoclevels
33
+ ulstyle olstyle htmlstylesheet-override sectionsplit
34
+ wordstylesheet-override).each_with_object({}) do |w, acc|
35
+ m = /\n:#{w}: ([^\n]+)\n/.match(head) or next
36
+ acc[w.sub(/-/, "_").to_sym] = m[1]
37
+ end
38
+ super.merge(ret)
55
39
  end
56
40
 
57
41
  def output(isodoc_node, inname, outname, format, options={})
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "1.8.0"
3
+ VERSION = "1.10.1".freeze
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "metanorma/generic/version"
4
4
 
@@ -10,9 +10,9 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "Metanorma template gem for customisation."
12
12
  spec.description = <<~DESCRIPTION
13
- Metanorma template gem for customisation. This gem is meant to be customised for any downstream use.
14
-
15
- Formerly known as metanorma-acme
13
+ Metanorma template gem for customisation. This gem is meant to be customised for any downstream use.
14
+ #{' '}
15
+ Formerly known as metanorma-acme
16
16
  DESCRIPTION
17
17
 
18
18
  spec.homepage = "https://github.com/metanorma/metanorma-generic"
@@ -24,21 +24,21 @@ Gem::Specification.new do |spec|
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
27
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
28
 
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
+ spec.add_dependency "isodoc", "~> 1.6.0"
31
+ spec.add_dependency "metanorma-standoc", "~> 1.9.0"
30
32
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "metanorma-standoc", "~> 1.6.0"
32
- spec.add_dependency "isodoc", "~> 1.3.0"
33
33
 
34
34
  spec.add_development_dependency "byebug", "~> 9.1"
35
- spec.add_development_dependency "sassc", "2.4.0"
36
35
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
37
36
  spec.add_development_dependency "guard", "~> 2.14"
38
37
  spec.add_development_dependency "guard-rspec", "~> 4.7"
39
- spec.add_development_dependency "rake", "~> 12.0"
38
+ spec.add_development_dependency "rake", "~> 13.0"
40
39
  spec.add_development_dependency "rspec", "~> 3.6"
41
- spec.add_development_dependency "rubocop", "= 0.54.0"
40
+ spec.add_development_dependency "rubocop", "~> 1.5.2"
41
+ spec.add_development_dependency "sassc", "2.4.0"
42
42
  spec.add_development_dependency "simplecov", "~> 0.15"
43
43
  spec.add_development_dependency "timecop", "~> 0.9"
44
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-generic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-30 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -25,47 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.3.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby-jing
28
+ name: isodoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.6.0
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'
40
+ version: 1.6.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: metanorma-standoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.6.0
47
+ version: 1.9.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.6.0
54
+ version: 1.9.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: isodoc
56
+ name: ruby-jing
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.3.0
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3.0
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: byebug
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '9.1'
83
- - !ruby/object:Gem::Dependency
84
- name: sassc
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 2.4.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 2.4.0
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: equivalent-xml
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +128,14 @@ dependencies:
142
128
  requirements:
143
129
  - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: '12.0'
131
+ version: '13.0'
146
132
  type: :development
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - "~>"
151
137
  - !ruby/object:Gem::Version
152
- version: '12.0'
138
+ version: '13.0'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rspec
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -166,18 +152,32 @@ dependencies:
166
152
  version: '3.6'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.5.2
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.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: sassc
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 0.54.0
173
+ version: 2.4.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 0.54.0
180
+ version: 2.4.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: simplecov
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -206,10 +206,8 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0.9'
209
- description: |
210
- Metanorma template gem for customisation. This gem is meant to be customised for any downstream use.
211
-
212
- Formerly known as metanorma-acme
209
+ description: " Metanorma template gem for customisation. This gem is meant to be
210
+ customised for any downstream use.\n \n Formerly known as metanorma-acme\n"
213
211
  email:
214
212
  - open.source@ribose.com
215
213
  executables: []
@@ -219,8 +217,6 @@ files:
219
217
  - ".github/workflows/rake.yml"
220
218
  - ".gitignore"
221
219
  - ".hound.yml"
222
- - ".rubocop.ribose.yml"
223
- - ".rubocop.tb.yml"
224
220
  - ".rubocop.yml"
225
221
  - CODE_OF_CONDUCT.md
226
222
  - Gemfile
@@ -279,14 +275,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
279
275
  requirements:
280
276
  - - ">="
281
277
  - !ruby/object:Gem::Version
282
- version: 2.4.0
278
+ version: 2.5.0
283
279
  required_rubygems_version: !ruby/object:Gem::Requirement
284
280
  requirements:
285
281
  - - ">="
286
282
  - !ruby/object:Gem::Version
287
283
  version: '0'
288
284
  requirements: []
289
- rubygems_version: 3.0.3
285
+ rubygems_version: 3.1.4
290
286
  signing_key:
291
287
  specification_version: 4
292
288
  summary: Metanorma template gem for customisation.
data/.rubocop.ribose.yml DELETED
@@ -1,66 +0,0 @@
1
- AllCops:
2
- Include:
3
- - "**/*.rake"
4
- - "**/Gemfile"
5
- - "**/*.gemfile"
6
- - "**/Rakefile"
7
- - "**/*.rb"
8
- Exclude:
9
- - "vendor/**/*"
10
- - "db/**/*"
11
- - "tmp/**/*"
12
- DisplayCopNames: false
13
- StyleGuideCopsOnly: false
14
- Rails:
15
- Enabled: true
16
- Metrics/AbcSize:
17
- Description: A calculated magnitude based on number of assignments, branches, and
18
- conditions.
19
- Enabled: true
20
- Max: 15
21
- Metrics/BlockLength:
22
- Exclude:
23
- - "spec/**/*"
24
- Metrics/BlockNesting:
25
- Description: Avoid excessive block nesting
26
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count
27
- Enabled: true
28
- Max: 3
29
- Metrics/ClassLength:
30
- Description: Avoid classes longer than 100 lines of code.
31
- Enabled: false
32
- CountComments: false
33
- Max: 100
34
- Metrics/CyclomaticComplexity:
35
- Description: A complexity metric that is strongly correlated to the number of test
36
- cases needed to validate a method.
37
- Enabled: true
38
- Max: 6
39
- Metrics/LineLength:
40
- Description: Limit lines to 80 characters.
41
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
42
- Enabled: true
43
- Max: 80
44
- AllowURI: true
45
- URISchemes:
46
- - http
47
- - https
48
- Metrics/MethodLength:
49
- Description: Avoid methods longer than 10 lines of code.
50
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
51
- Enabled: true
52
- CountComments: true
53
- Max: 10
54
- Exclude:
55
- - "spec/**/*"
56
- Metrics/ParameterLists:
57
- Description: Avoid long parameter lists.
58
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
59
- Enabled: true
60
- Max: 5
61
- CountKeywordArgs: true
62
- Metrics/PerceivedComplexity:
63
- Description: A complexity metric geared towards measuring complexity for a human
64
- reader.
65
- Enabled: true
66
- Max: 7