metanorma-bipm 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,8 @@ module IsoDoc
9
9
  end
10
10
 
11
11
  def clause_names(docxml, sect_num)
12
- if docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))&.value == "JCGM"
12
+ if docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))&.
13
+ value == "JCGM"
13
14
  clause_names_jcgm(docxml, sect_num)
14
15
  else
15
16
  clause_names_bipm(docxml, sect_num)
@@ -17,8 +18,8 @@ module IsoDoc
17
18
  end
18
19
 
19
20
  def clause_names_jcgm(docxml, sect_num)
20
- docxml.xpath(ns("//clause[parent::sections][not(@type = 'scope')][not(descendant::terms)]")).
21
- each_with_index do |c, i|
21
+ docxml.xpath(ns("//clause[parent::sections][not(@type = 'scope')]"\
22
+ "[not(descendant::terms)]")).each_with_index do |c, i|
22
23
  section_names(c, sect_num, 1)
23
24
  end
24
25
  end
@@ -50,8 +51,9 @@ module IsoDoc
50
51
  def section_names(clause, num, lvl)
51
52
  return num if clause.nil?
52
53
  num.increment(clause)
53
- @anchors[clause["id"]] = { label: num.print, xref: l10n("#{@labels["clause"]} #{num.print}"),
54
- level: lvl, type: "clause" }
54
+ @anchors[clause["id"]] =
55
+ { label: num.print, xref: l10n("#{@labels["clause"]} #{num.print}"),
56
+ level: lvl, type: "clause" }
55
57
  i = Counter.new
56
58
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
57
59
  i.increment(c)
@@ -66,7 +68,8 @@ module IsoDoc
66
68
  def unnumbered_section_names(clause, lvl)
67
69
  return if clause.nil?
68
70
  lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
69
- @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}), level: lvl, type: "clause" }
71
+ @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
72
+ level: lvl, type: "clause" }
70
73
  clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
71
74
  unnumbered_section_names1(c, lvl + 1)
72
75
  end
@@ -74,7 +77,8 @@ module IsoDoc
74
77
 
75
78
  def section_names1(clause, num, level)
76
79
  @anchors[clause["id"]] =
77
- { label: num, level: level, xref: l10n("#{@labels["subclause"]} #{num}"),
80
+ { label: num, level: level,
81
+ xref: l10n("#{@labels["subclause"]} #{num}"),
78
82
  type: "clause" }
79
83
  i = Counter.new
80
84
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
@@ -99,14 +103,17 @@ module IsoDoc
99
103
  super
100
104
  @annexlbl = docxml.at(ns("//bibdata/ext/structuredidentifier/appendix")) ?
101
105
  @labels["appendix"] : @labels["annex"]
102
- docxml.xpath(ns("//annex[not(@unnumbered = 'true')]")).each_with_index { |c, i| annex_names(c, (i+1).to_s) }
103
- docxml.xpath(ns("//annex[@unnumbered = 'true']")).each { |c| unnumbered_annex_names(c) }
106
+ docxml.xpath(ns("//annex[not(@unnumbered = 'true')]")).
107
+ each_with_index { |c, i| annex_names(c, (i+1).to_s) }
108
+ docxml.xpath(ns("//annex[@unnumbered = 'true']")).
109
+ each { |c| unnumbered_annex_names(c) }
104
110
  docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
105
111
  end
106
112
 
107
113
  def annex_names(clause, num)
108
- @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause", value: num.to_s,
109
- xref: l10n("#{@annexlbl} #{num}"), level: 1 }
114
+ @anchors[clause["id"]] =
115
+ { label: annex_name_lbl(clause, num), type: "clause", value: num.to_s,
116
+ xref: l10n("#{@annexlbl} #{num}"), level: 1 }
110
117
  if a = single_annex_special_section(clause)
111
118
  annex_names1(a, "#{num}", 1)
112
119
  else
@@ -115,43 +122,62 @@ module IsoDoc
115
122
  i.increment(c)
116
123
  annex_names1(c, "#{num}.#{i.print}", 2)
117
124
  end
118
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each { |c| unnumbered_annex_names1(c, 2) }
125
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).
126
+ each { |c| unnumbered_annex_names1(c, 2) }
119
127
  end
120
128
  hierarchical_asset_names(clause, num)
121
129
  end
122
130
 
123
131
  def unnumbered_annex_names(clause)
124
132
  lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
125
- @anchors[clause["id"]] = { label: lbl, type: "clause", value: "", xref: l10n(%{"#{lbl}"}), level: 1 }
133
+ @anchors[clause["id"]] =
134
+ { label: lbl, type: "clause", value: "",
135
+ xref: l10n(%{"#{lbl}"}), level: 1 }
126
136
  if a = single_annex_special_section(clause)
127
137
  annex_names1(a, "#{num}", 1)
128
138
  else
129
- clause.xpath(ns(SUBCLAUSES)).each { |c| unnumbered_annex_names1(c, 2) }
139
+ clause.xpath(ns(SUBCLAUSES)).
140
+ each { |c| unnumbered_annex_names1(c, 2) }
130
141
  end
131
142
  hierarchical_asset_names(clause, lbl)
132
143
  end
133
144
 
134
145
  def annex_names1(clause, num, level)
135
- @anchors[clause["id"]] = { label: num, xref: l10n("#{@annexlbl} #{num}"),
136
- level: level, type: "clause" }
146
+ @anchors[clause["id"]] =
147
+ { label: num, xref: l10n("#{@annexlbl} #{num}"),
148
+ level: level, type: "clause" }
137
149
  i = Counter.new
138
150
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
139
151
  i.increment(c)
140
152
  annex_names1(c, "#{num}.#{i.print}", level + 1)
141
153
  end
142
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each { |c| unnumbered_annex_names1(c, level + 1) }
154
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).
155
+ each { |c| unnumbered_annex_names1(c, level + 1) }
143
156
  end
144
157
 
145
158
  def unnumbered_annex_names1(clause, level)
146
159
  lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
147
160
  @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
148
161
  level: level, type: "clause" }
149
- clause.xpath(ns(SUBCLAUSES)).each { |c| unnumbered_annex_names1(c, level + 1) }
162
+ clause.xpath(ns(SUBCLAUSES)).
163
+ each { |c| unnumbered_annex_names1(c, level + 1) }
150
164
  end
151
165
 
152
166
  def annex_name_lbl(clause, num)
153
167
  l10n("<strong>#{@annexlbl} #{num}</strong>")
154
168
  end
169
+
170
+ def sequential_formula_names(clause)
171
+ c = Counter.new
172
+ clause.xpath(ns(".//formula")).each do |t|
173
+ next if t["id"].nil? || t["id"].empty?
174
+ @anchors[t["id"]] =
175
+ anchor_struct(c.increment(t).print, nil,
176
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
177
+ "formula", t["unnumbered"])
178
+ end
179
+ end
180
+
155
181
  end
156
182
  end
157
183
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "1.0.6"
3
+ VERSION = "1.0.7"
4
4
  end
5
5
  end
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "guard-rspec", "~> 4.7"
36
36
  spec.add_development_dependency "rake", "~> 13.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.6"
38
- spec.add_development_dependency "rubocop", "~> 0.50"
38
+ spec.add_development_dependency "rubocop", "~> 1.5.2"
39
39
  spec.add_development_dependency "simplecov", "~> 0.15"
40
40
  spec.add_development_dependency "timecop", "~> 0.9"
41
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-16 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0.50'
131
+ version: 1.5.2
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0.50'
138
+ version: 1.5.2
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -175,6 +175,8 @@ extensions: []
175
175
  extra_rdoc_files: []
176
176
  files:
177
177
  - ".github/workflows/rake.yml"
178
+ - ".gitignore"
179
+ - ".rubocop.yml"
178
180
  - CODE_OF_CONDUCT.md
179
181
  - Gemfile
180
182
  - LICENSE