metanorma-iso 1.9.2 → 1.9.6

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.
@@ -2,7 +2,7 @@ require "isodoc"
2
2
 
3
3
  module IsoDoc
4
4
  module Iso
5
- class Metadata < IsoDoc::Metadata
5
+ class Metadata < IsoDoc::Metadata
6
6
  def initialize(lang, script, i18n)
7
7
  super
8
8
  set(:tc, "XXXX")
@@ -14,17 +14,17 @@ module IsoDoc
14
14
  set(:obsoletes_part, nil)
15
15
  end
16
16
 
17
- def status_abbrev(stage, substage, iter, draft, doctype)
17
+ def status_abbrev(stage, _substage, iter, draft, doctype)
18
18
  return "" unless stage
19
19
 
20
20
  if %w(technical-report technical-specification).include?(doctype)
21
21
  stage = "DTS" if stage == "DIS"
22
22
  stage = "FDTS" if stage == "FDIS"
23
23
  end
24
- if %w(PWI NWIP WD CD).include?(stage)
25
- stage += iter if iter
24
+ if %w(PWI NWIP WD CD).include?(stage) && iter
25
+ stage += iter
26
26
  end
27
- stage = "Pre" + stage if draft =~ /^0\./
27
+ stage = "Pre#{stage}" if /^0\./.match?(draft)
28
28
  stage
29
29
  end
30
30
 
@@ -48,14 +48,14 @@ module IsoDoc
48
48
  end
49
49
 
50
50
  def unpublished(status)
51
- status.to_i > 0 && status.to_i < 60
51
+ status.to_i.positive? && status.to_i < 60
52
52
  end
53
53
 
54
54
  def docid(isoxml, _out)
55
55
  dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ISO']"))
56
56
  set(:docnumber, dn&.text)
57
57
  tcdn = isoxml.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']"))
58
- set(:tc_docnumber, tcdn.map { |n| n.text })
58
+ set(:tc_docnumber, tcdn.map(&:text))
59
59
  dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-with-lang']"))
60
60
  set(:docnumber_lang, dn&.text)
61
61
  dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-reference']"))
@@ -87,6 +87,7 @@ module IsoDoc
87
87
 
88
88
  def part_title(part, partnum, subpartnum, lang)
89
89
  return "" unless part
90
+
90
91
  suffix = @c.encode(part.text, :hexadecimal)
91
92
  partnum = "#{partnum}&ndash;#{subpartnum}" if partnum && subpartnum
92
93
  suffix = "#{part_label(lang)}&nbsp;#{partnum}: " + suffix if partnum
@@ -125,10 +126,14 @@ module IsoDoc
125
126
  end
126
127
 
127
128
  def title_parts(isoxml, lang)
128
- [isoxml.at(ns("//bibdata//title[@type='title-intro' and @language='#{lang}']")),
129
- isoxml.at(ns("//bibdata//title[@type='title-main' and @language='#{lang}']")),
130
- isoxml.at(ns("//bibdata//title[@type='title-part' and @language='#{lang}']")),
131
- isoxml.at(ns("//bibdata//title[@type='title-amd' and @language='#{lang}']"))]
129
+ [isoxml.at(ns("//bibdata//title[@type='title-intro' and "\
130
+ "@language='#{lang}']")),
131
+ isoxml.at(ns("//bibdata//title[@type='title-main' and "\
132
+ "@language='#{lang}']")),
133
+ isoxml.at(ns("//bibdata//title[@type='title-part' and "\
134
+ "@language='#{lang}']")),
135
+ isoxml.at(ns("//bibdata//title[@type='title-amd' and "\
136
+ "@language='#{lang}']"))]
132
137
  end
133
138
 
134
139
  def title(isoxml, _out)
@@ -139,7 +144,10 @@ module IsoDoc
139
144
  set(:doctitlemain, @c.encode(main ? main.text : "", :hexadecimal))
140
145
  main = compose_title(main, intro, part, partnumber, subpartnumber, lang)
141
146
  set(:doctitle, main)
142
- set(:doctitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro
147
+ if intro
148
+ set(:doctitleintro,
149
+ @c.encode(intro ? intro.text : "", :hexadecimal))
150
+ end
143
151
  set(:doctitlepartlabel, part_prefix(partnumber, subpartnumber, lang))
144
152
  set(:doctitlepart, @c.encode(part.text, :hexadecimal)) if part
145
153
  set(:doctitleamdlabel, amd_prefix(amdnumber, lang)) if amdnumber
@@ -155,7 +163,10 @@ module IsoDoc
155
163
  set(:docsubtitlemain, @c.encode(main ? main.text : "", :hexadecimal))
156
164
  main = compose_title(main, intro, part, partnumber, subpartnumber, lang)
157
165
  set(:docsubtitle, main)
158
- set(:docsubtitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro
166
+ if intro
167
+ set(:docsubtitleintro,
168
+ @c.encode(intro ? intro.text : "", :hexadecimal))
169
+ end
159
170
  set(:docsubtitlepartlabel, part_prefix(partnumber, subpartnumber, lang))
160
171
  set(:docsubtitlepart, @c.encode(part.text, :hexadecimal)) if part
161
172
  set(:docsubtitleamdlabel, amd_prefix(amdnumber, lang)) if amdnumber
@@ -173,8 +184,8 @@ module IsoDoc
173
184
 
174
185
  def tc(xml)
175
186
  tc_num = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@number"))
176
- tc_type = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@type"))&.
177
- text || "TC"
187
+ tc_type = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@type"))
188
+ &.text || "TC"
178
189
  if tc_num
179
190
  tcid = "#{tc_type} #{tc_num.text}"
180
191
  set(:tc, tcid)
@@ -212,7 +223,8 @@ module IsoDoc
212
223
  ics = []
213
224
  isoxml.xpath(ns("//bibdata/ext/ics/code")).each { |i| ics << i.text }
214
225
  set(:ics, ics.empty? ? nil : ics.join(", "))
215
- a = isoxml.at(ns("//bibdata/ext/horizontal")) and set(:horizontal, a.text)
226
+ a = isoxml.at(ns("//bibdata/ext/horizontal")) and set(:horizontal,
227
+ a.text)
216
228
  end
217
229
  end
218
230
  end
@@ -45,13 +45,15 @@ module IsoDoc
45
45
  prefix_name(node, "&nbsp;&mdash; ", lbl, "name")
46
46
  end
47
47
 
48
+ def eref_delim(delim, type)
49
+ if delim == ";" then ";"
50
+ else type == "list" ? "" : delim
51
+ end
52
+ end
53
+
48
54
  def eref_localities1_zh(target, type, from, upto, node, delim)
49
55
  subsection = from&.text&.match(/\./)
50
- ret = if delim == ";"
51
- ";"
52
- else
53
- type == "list" ? "" : delim
54
- end
56
+ ret = eref_delim(delim, type)
55
57
  ret += " 第#{from.text}" if from
56
58
  ret += "&ndash;#{upto.text}" if upto
57
59
  loc = (@i18n.locality[type] || type.sub(/^locality:/, "").capitalize)
@@ -68,11 +70,9 @@ module IsoDoc
68
70
  subsection = from&.text&.match(/\./)
69
71
  type = type.downcase
70
72
  lang == "zh" and
71
- return l10n(eref_localities1_zh(target, type, from, upto, node, delim))
72
- ret = if delim == ";" then ";"
73
- else
74
- type == "list" ? "" : delim
75
- end
73
+ return l10n(eref_localities1_zh(target, type, from, upto, node,
74
+ delim))
75
+ ret = eref_delim(delim, type)
76
76
  ret += eref_locality_populate(type, node) unless subsection &&
77
77
  type == "clause" || type == "list" ||
78
78
  target.match(/^IEV$|^IEC 60050-/)
@@ -113,31 +113,39 @@ module IsoDoc
113
113
  end
114
114
 
115
115
  def concept(docxml)
116
- docxml.xpath(ns("//terms//concept")).each_with_object({}) do |f, m|
116
+ docxml.xpath(ns("//term//concept")).each_with_object({}) do |f, m|
117
117
  concept_term(f, m)
118
118
  end
119
119
  docxml.xpath(ns("//concept")).each do |node|
120
- concept_render(node, node["ital"] || "false", node["ref"] || "false")
120
+ concept_render(node, ital: node["ital"] || "false",
121
+ ref: node["ref"] || "false",
122
+ linkref: node["linkref"] || "true",
123
+ linkmention: node["linkmention"] || "false")
121
124
  end
122
125
  end
123
126
 
124
127
  def concept_term(node, seen)
125
128
  term = node&.at(ns("./refterm"))&.to_xml
126
129
  if term && seen[term]
127
- concept_render(node, node["ital"] || "false", node["ref"] || "false")
128
- else concept_render(node, node["ital"] || "true", node["ref"] || "true")
130
+ concept_render(node, ital: node["ital"] || "false",
131
+ ref: node["ref"] || "false",
132
+ linkref: node["linkref"] || "true",
133
+ linkmention: node["linkmention"] || "false")
134
+ else concept_render(node, ital: node["ital"] || "true",
135
+ ref: node["ref"] || "true",
136
+ linkref: node["linkref"] || "true",
137
+ linkmention: node["linkmention"] || "false")
129
138
  end
130
139
  seen[term] = true if term
131
140
  seen
132
141
  end
133
142
 
134
- def concept1_ref(node, ref)
135
- if r = node.at(ns("./xref | ./eref | ./termref"))
136
- return r.remove if ref == "false"
137
-
138
- r.name == "termref" and
139
- r.replace(@i18n.term_defined_in.sub(/%/, r.to_xml)) or
140
- r.replace("(#{r.to_xml})")
143
+ def concept1_ref_content(ref)
144
+ if ref.name == "termref"
145
+ ref.replace(@i18n.term_defined_in.sub(/%/,
146
+ ref.to_xml))
147
+ else
148
+ ref.replace("(#{ref.to_xml})")
141
149
  end
142
150
  end
143
151
 
@@ -160,7 +168,7 @@ module IsoDoc
160
168
  # i = display_order_at(docxml, "//sections/definitions", i)
161
169
  # i = display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml), i)
162
170
  i = display_order_xpath(docxml, "//sections/clause[not(@type = 'scope')] | "\
163
- "//sections/terms | //sections/definitions", i)
171
+ "//sections/terms | //sections/definitions", i)
164
172
  i = display_order_xpath(docxml, "//annex", i)
165
173
  i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
166
174
  display_order_xpath(docxml, "//indexsect", i)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.9.2".freeze
3
+ VERSION = "1.9.6".freeze
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ["open.source@ribose.com"]
12
12
 
13
13
  spec.summary = "metanorma-iso lets you write ISO standards "\
14
- "in AsciiDoc."
14
+ "in AsciiDoc."
15
15
  spec.description = <<~DESCRIPTION
16
16
  metanorma-iso lets you write ISO standards in AsciiDoc syntax.
17
17
 
@@ -47,4 +47,6 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency "sassc", "2.4.0"
48
48
  spec.add_development_dependency "simplecov", "~> 0.15"
49
49
  spec.add_development_dependency "timecop", "~> 0.9"
50
+ spec.add_development_dependency "vcr", "~> 5.0.0"
51
+ spec.add_development_dependency "webmock"
50
52
  end