metanorma-iso 2.3.3 → 2.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/iso/base_convert.rb +1 -0
- data/lib/isodoc/iso/html/html_iso_titlepage.html +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage-prf.html +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage.html +1 -1
- data/lib/isodoc/iso/metadata.rb +22 -25
- data/lib/isodoc/iso/presentation_bibdata.rb +9 -3
- data/lib/isodoc/iso/presentation_xml_convert.rb +14 -17
- data/lib/metanorma/iso/basicdoc.rng +0 -1
- data/lib/metanorma/iso/cleanup.rb +4 -0
- data/lib/metanorma/iso/front.rb +21 -5
- data/lib/metanorma/iso/front_id.rb +114 -186
- data/lib/metanorma/iso/isodoc.rng +1 -0
- data/lib/metanorma/iso/processor.rb +1 -1
- data/lib/metanorma/iso/section.rb +6 -2
- data/lib/metanorma/iso/version.rb +1 -1
- data/lib/relaton/render/general.rb +1 -0
- data/metanorma-iso.gemspec +1 -1
- metadata +6 -7
- data/Gemfile.devel +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6252955e2d89211f2f4a54d9d1b3ef9ac843ef27d9501675b231bc71a7d7c293
|
4
|
+
data.tar.gz: ac49bec2ab4bf06ec7ce6d17210f08e028eb87268fa5f0d01b4f241d0e4259f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb52dff522bc328a0c1f6741f7b989124f5f8a2db7d3284f00144c201a1e683a567cca9caf023da7eee525a97ec239007fb472735efb9a62bfff1a8bda5e85d6
|
7
|
+
data.tar.gz: 04ff426186796810778862c44ee7d2e55097379356a5d3e826017d4bb5a13ba5febada40a224b7ce067a3a867a8a54b9b44c9a0d545461fad66c990dacefea68
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<p class="coverpage_docnumber">{{ docnumber_undated }} {{ draftinfo }}</p>
|
20
20
|
{% endif %}
|
21
21
|
|
22
|
-
<p class="coverpage_techcommittee">{{
|
22
|
+
<p class="coverpage_techcommittee">{{ editorialgroup }}</p>
|
23
23
|
|
24
24
|
{% if secretariat %}
|
25
25
|
<p class="coverpage_techcommittee"><a
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
<p class="zzCover" style='font-weight:normal;'><span lang="EN-GB">Reference number of project: {{ docnumber_undated }}{% if draftinfo %} {{ draftinfo }}{% endif %}</span></p>
|
22
22
|
|
23
|
-
<p class="zzCover" style='font-weight:normal;'><span lang="EN-GB">Committee identification: {{
|
23
|
+
<p class="zzCover" style='font-weight:normal;'><span lang="EN-GB">Committee identification: {{ approvalgroup }}</span></p>
|
24
24
|
|
25
25
|
<!--
|
26
26
|
{% if doctitleamdlabel %}
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<p class="zzCover" align="right" style='text-align:right'><span lang="EN-GB">Date: <span style='mso-no-proof:yes'><b>{{ doc_date }}</b></span></span></p>
|
15
15
|
{% endif %}
|
16
16
|
|
17
|
-
<p class="zzCover" style='font-weight:normal;'><span lang="EN-GB">{{
|
17
|
+
<p class="zzCover" style='font-weight:normal;'><span lang="EN-GB">{{ editorialgroup}}</span></p>
|
18
18
|
|
19
19
|
<!--
|
20
20
|
{% if doctitleamdlabel %}
|
@@ -23,7 +23,7 @@ style='mso-bidi-font-weight:normal'><span lang="EN-GB" style='font-size:14.0pt'>
|
|
23
23
|
{% endif %}
|
24
24
|
|
25
25
|
<p class="MsoNormal" align="right" style='text-align:right'><span lang="EN-GB"
|
26
|
-
style='mso-no-proof:yes'>{{
|
26
|
+
style='mso-no-proof:yes'>{{ editorialgroup }}</span></p>
|
27
27
|
|
28
28
|
{% if secretariat %}
|
29
29
|
<p class="MsoNormal" align="right" style='text-align:right'><span lang="EN-GB">{{ labels["secretariat"] }}: <span style='mso-no-proof:yes'>{{ secretariat }}</span></span></p>
|
data/lib/isodoc/iso/metadata.rb
CHANGED
@@ -6,7 +6,6 @@ module IsoDoc
|
|
6
6
|
def initialize(lang, script, locale, i18n)
|
7
7
|
super
|
8
8
|
DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = nil }
|
9
|
-
set(:editorialgroup, [])
|
10
9
|
set(:obsoletes, nil)
|
11
10
|
set(:obsoletes_part, nil)
|
12
11
|
end
|
@@ -100,7 +99,7 @@ module IsoDoc
|
|
100
99
|
main = ""
|
101
100
|
tparts[:main].nil? or
|
102
101
|
main = @c.encode(tparts[:main].text, :hexadecimal)
|
103
|
-
tparts[:intro]
|
102
|
+
tparts[:intro] and
|
104
103
|
main = "#{@c.encode(tparts[:intro].text,
|
105
104
|
:hexadecimal)} — #{main}"
|
106
105
|
if tparts[:part]
|
@@ -119,20 +118,19 @@ module IsoDoc
|
|
119
118
|
end
|
120
119
|
|
121
120
|
def title_parts(isoxml, lang)
|
122
|
-
{ intro: isoxml.at(ns("//bibdata/title[@type='title-intro' and "\
|
121
|
+
{ intro: isoxml.at(ns("//bibdata/title[@type='title-intro' and " \
|
123
122
|
"@language='#{lang}']")),
|
124
|
-
main: isoxml.at(ns("//bibdata/title[@type='title-main' and "\
|
123
|
+
main: isoxml.at(ns("//bibdata/title[@type='title-main' and " \
|
125
124
|
"@language='#{lang}']")),
|
126
|
-
part: isoxml.at(ns("//bibdata/title[@type='title-part' and "\
|
125
|
+
part: isoxml.at(ns("//bibdata/title[@type='title-part' and " \
|
127
126
|
"@language='#{lang}']")),
|
128
|
-
amd: isoxml.at(ns("//bibdata/title[@type='title-amd' and "\
|
127
|
+
amd: isoxml.at(ns("//bibdata/title[@type='title-amd' and " \
|
129
128
|
"@language='#{lang}']")) }
|
130
129
|
end
|
131
130
|
|
132
131
|
def title(isoxml, _out)
|
133
132
|
lang = case @lang
|
134
|
-
when "fr" then
|
135
|
-
when "ru" then "ru"
|
133
|
+
when "fr", "ru" then @lang
|
136
134
|
else "en"
|
137
135
|
end
|
138
136
|
# intro, main, part, amd = title_parts(isoxml, lang)
|
@@ -179,58 +177,57 @@ module IsoDoc
|
|
179
177
|
tc(xml)
|
180
178
|
sc(xml)
|
181
179
|
wg(xml)
|
182
|
-
|
180
|
+
editorialgroup(xml)
|
183
181
|
secretariat(xml)
|
184
182
|
end
|
185
183
|
|
186
184
|
def tc(xml)
|
187
185
|
tcid = tc_base(xml, "editorialgroup") or return
|
188
186
|
set(:tc, tcid)
|
189
|
-
set(:editorialgroup, get[:editorialgroup] << tcid)
|
190
187
|
end
|
191
188
|
|
192
189
|
def tc_base(xml, grouptype)
|
193
|
-
tc_num = xml.at(ns("//bibdata/ext/#{grouptype}/"\
|
190
|
+
tc_num = xml.at(ns("//bibdata/ext/#{grouptype}/" \
|
194
191
|
"technical-committee/@number")) or return nil
|
195
|
-
tc_type = xml.at(ns("//bibdata/ext/#{grouptype}/technical-committee/"\
|
192
|
+
tc_type = xml.at(ns("//bibdata/ext/#{grouptype}/technical-committee/" \
|
196
193
|
"@type"))&.text || "TC"
|
197
|
-
"
|
194
|
+
tc_type == "Other" and tc_type = ""
|
195
|
+
"#{tc_type} #{tc_num.text}".strip
|
198
196
|
end
|
199
197
|
|
200
198
|
def sc(xml)
|
201
199
|
scid = sc_base(xml, "editorialgroup") or return
|
202
200
|
set(:sc, scid)
|
203
|
-
set(:editorialgroup, get[:editorialgroup] << scid)
|
204
201
|
end
|
205
202
|
|
206
203
|
def sc_base(xml, grouptype)
|
207
|
-
sc_num = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/"\
|
204
|
+
sc_num = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/" \
|
208
205
|
"@number")) or return nil
|
209
|
-
sc_type = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/"\
|
206
|
+
sc_type = xml.at(ns("//bibdata/ext/#{grouptype}/subcommittee/" \
|
210
207
|
"@type"))&.text || "SC"
|
208
|
+
sc_type == "Other" and sc_type = ""
|
211
209
|
"#{sc_type} #{sc_num.text}"
|
212
210
|
end
|
213
211
|
|
214
212
|
def wg(xml)
|
215
213
|
wgid = wg_base(xml, "editorialgroup") or return
|
216
214
|
set(:wg, wgid)
|
217
|
-
set(:editorialgroup, get[:editorialgroup] << wgid)
|
218
215
|
end
|
219
216
|
|
220
217
|
def wg_base(xml, grouptype)
|
221
|
-
wg_num = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/"\
|
218
|
+
wg_num = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/" \
|
222
219
|
"@number")) or return
|
223
|
-
wg_type = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/"\
|
220
|
+
wg_type = xml.at(ns("//bibdata/ext/#{grouptype}/workgroup/" \
|
224
221
|
"@type"))&.text || "WG"
|
222
|
+
wg_type == "Other" and wg_type = ""
|
225
223
|
"#{wg_type} #{wg_num.text}"
|
226
224
|
end
|
227
225
|
|
228
|
-
def
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
set(:approvalgroup, ret.compact)
|
226
|
+
def editorialgroup(xml)
|
227
|
+
a = xml.at(ns("//bibdata/ext/editorialgroup/@identifier")) and
|
228
|
+
set(:editorialgroup, a.text)
|
229
|
+
a = xml.at(ns("//bibdata/ext/approvalgroup/@identifier")) and
|
230
|
+
set(:approvalgroup, a.text)
|
234
231
|
end
|
235
232
|
|
236
233
|
def secretariat(xml)
|
@@ -49,10 +49,16 @@ module IsoDoc
|
|
49
49
|
agency = group.xpath(ns("./agency"))&.map(&:text)
|
50
50
|
ret = %w(technical-committee subcommittee workgroup)
|
51
51
|
.each_with_object([]) do |v, m|
|
52
|
-
|
53
|
-
m << "#{a['type']} #{a['number']}"
|
52
|
+
m << editorialgroup_identifier2(group, v)
|
54
53
|
end
|
55
|
-
group["identifier"] = (agency + ret).join("/")
|
54
|
+
group["identifier"] = (agency + ret.compact).join("/")
|
55
|
+
end
|
56
|
+
|
57
|
+
def editorialgroup_identifier2(group, level)
|
58
|
+
a = group.at(ns("./#{level}")) or return nil
|
59
|
+
type = a["type"]
|
60
|
+
type.casecmp("other").zero? and type = ""
|
61
|
+
"#{type} #{a['number']}".strip
|
56
62
|
end
|
57
63
|
|
58
64
|
def bibdata_i18n(bib)
|
@@ -96,7 +96,8 @@ module IsoDoc
|
|
96
96
|
def concept_term(docxml)
|
97
97
|
docxml.xpath(ns("//term")).each do |f|
|
98
98
|
m = {}
|
99
|
-
f.xpath(ns(".//concept"))
|
99
|
+
(f.xpath(ns(".//concept")) - f.xpath(ns(".//term//concept")))
|
100
|
+
.each { |c| concept_term1(c, m) }
|
100
101
|
end
|
101
102
|
end
|
102
103
|
|
@@ -113,11 +114,13 @@ module IsoDoc
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def concept1_ref_content(ref)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
117
|
+
prev = "("
|
118
|
+
foll = ")"
|
119
|
+
if ref.name == "termref"
|
120
|
+
prev, foll = @i18n.term_defined_in.split("%")
|
121
|
+
end
|
122
|
+
ref.previous = prev
|
123
|
+
ref.next = foll
|
121
124
|
end
|
122
125
|
|
123
126
|
def concept1(node)
|
@@ -128,7 +131,6 @@ module IsoDoc
|
|
128
131
|
|
129
132
|
# we're assuming terms and clauses in the right place for display,
|
130
133
|
# to cope with multiple terms sections
|
131
|
-
|
132
134
|
def display_order(docxml)
|
133
135
|
i = 0
|
134
136
|
i = display_order_xpath(docxml, "//preface/*", i)
|
@@ -157,8 +159,7 @@ module IsoDoc
|
|
157
159
|
|
158
160
|
def insertall_after_here(node, insert, name)
|
159
161
|
node.children.each do |n|
|
160
|
-
|
161
|
-
|
162
|
+
n.name == name or next
|
162
163
|
insert.next = n.remove
|
163
164
|
insert = n
|
164
165
|
end
|
@@ -166,8 +167,7 @@ module IsoDoc
|
|
166
167
|
end
|
167
168
|
|
168
169
|
def termexamples_before_termnotes(node)
|
169
|
-
|
170
|
-
|
170
|
+
insert = node.at(ns("./definition")) or return
|
171
171
|
insert = insertall_after_here(node, insert, "termexample")
|
172
172
|
insertall_after_here(node, insert, "termnote")
|
173
173
|
end
|
@@ -181,11 +181,9 @@ module IsoDoc
|
|
181
181
|
|
182
182
|
def admonition1(elem)
|
183
183
|
super
|
184
|
-
|
185
|
-
|
184
|
+
n = elem.at(ns("./name")) or return
|
186
185
|
p = n.next_element
|
187
|
-
|
188
|
-
|
186
|
+
p.name == "p" or return
|
189
187
|
p.children.first.previous = admonition_name(to_xml(n.remove.children))
|
190
188
|
end
|
191
189
|
|
@@ -199,8 +197,7 @@ module IsoDoc
|
|
199
197
|
end
|
200
198
|
|
201
199
|
def bibrender_formattedref(formattedref, xml)
|
202
|
-
|
203
|
-
|
200
|
+
%w(techreport standard).include? xml["type"] and return
|
204
201
|
super
|
205
202
|
end
|
206
203
|
|
@@ -44,14 +44,18 @@ module Metanorma
|
|
44
44
|
# ISO as a prefix goes first
|
45
45
|
def docidentifier_cleanup(xmldoc)
|
46
46
|
prefix = get_id_prefix(xmldoc)
|
47
|
+
=begin
|
47
48
|
id = xmldoc.at("//bibdata/docidentifier[@type = 'ISO']") or return
|
48
49
|
id.content = id_prefix(prefix, id)
|
50
|
+
=end
|
49
51
|
id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and
|
50
52
|
id.content = id_prefix(prefix, id)
|
53
|
+
=begin
|
51
54
|
%w(iso-with-lang iso-reference iso-undated).each do |t|
|
52
55
|
id = xmldoc.at("//bibdata/docidentifier[@type = '#{t}']") and
|
53
56
|
id.content = id_prefix(prefix, id)
|
54
57
|
end
|
58
|
+
=end
|
55
59
|
end
|
56
60
|
|
57
61
|
def format_ref(ref, type)
|
data/lib/metanorma/iso/front.rb
CHANGED
@@ -12,12 +12,27 @@ module Metanorma
|
|
12
12
|
def metadata_ext(node, xml)
|
13
13
|
super
|
14
14
|
structured_id(node, xml)
|
15
|
-
|
16
|
-
|
15
|
+
id = iso_id_default(iso_id_params(node))
|
16
|
+
id.stage and
|
17
|
+
xml.stagename metadata_stagename(id)&.strip,
|
18
|
+
**attr_code(abbreviation: id.typed_stage_abbrev&.strip)
|
17
19
|
@amd && a = node.attr("updates-document-type") and
|
18
20
|
xml.updates_document_type a
|
19
21
|
end
|
20
22
|
|
23
|
+
def metadata_stagename(id)
|
24
|
+
if @amd
|
25
|
+
id.amendments&.first&.stage&.name ||
|
26
|
+
id.corrigendums&.first&.stage&.name
|
27
|
+
else
|
28
|
+
begin
|
29
|
+
id.typed_stage_name
|
30
|
+
rescue StandardError
|
31
|
+
id.stage&.name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
21
36
|
def metadata_subdoctype(node, xml)
|
22
37
|
super
|
23
38
|
a = node.attr("horizontal") and xml.horizontal a
|
@@ -32,7 +47,7 @@ module Metanorma
|
|
32
47
|
publishers = node.attr("publisher") || "ISO"
|
33
48
|
csv_split(publishers).each do |p|
|
34
49
|
xml.contributor do |c|
|
35
|
-
c.role
|
50
|
+
c.role type: "author"
|
36
51
|
c.organization do |a|
|
37
52
|
organization(a, p, false, node, !node.attr("publisher"))
|
38
53
|
end
|
@@ -44,7 +59,7 @@ module Metanorma
|
|
44
59
|
publishers = node.attr("publisher") || "ISO"
|
45
60
|
csv_split(publishers).each do |p|
|
46
61
|
xml.contributor do |c|
|
47
|
-
c.role
|
62
|
+
c.role type: "publisher"
|
48
63
|
c.organization do |a|
|
49
64
|
organization(a, p, true, node, !node.attr("publisher"))
|
50
65
|
end
|
@@ -73,8 +88,9 @@ module Metanorma
|
|
73
88
|
def metadata_status(node, xml)
|
74
89
|
stage = get_stage(node)
|
75
90
|
substage = get_substage(node)
|
91
|
+
abbrev = iso_id_default(iso_id_params(node)).stage&.abbr
|
76
92
|
xml.status do |s|
|
77
|
-
s.stage stage, **attr_code(abbreviation:
|
93
|
+
s.stage stage, **attr_code(abbreviation: abbrev)
|
78
94
|
s.substage substage
|
79
95
|
node.attr("iteration") && (s.iteration node.attr("iteration"))
|
80
96
|
end
|
@@ -34,153 +34,158 @@ module Metanorma
|
|
34
34
|
"95": "Withdrawal",
|
35
35
|
}.freeze
|
36
36
|
|
37
|
-
def stage_abbr(stage, substage,
|
37
|
+
def stage_abbr(stage, substage, _doctype)
|
38
38
|
return nil if stage.to_i > 60
|
39
39
|
|
40
40
|
ret = STAGE_ABBRS[stage.to_sym]
|
41
41
|
ret = "PRF" if stage == "60" && substage == "00"
|
42
|
+
ret = nil if stage == "60" && substage != "00"
|
42
43
|
ret = "AWI" if stage == "10" && substage == "99"
|
43
44
|
ret = "AWI" if stage == "20" && substage == "00"
|
44
|
-
if %w(amendment technical-corrigendum technical-report
|
45
|
-
technical-specification).include?(doctype)
|
46
|
-
ret = "D" if stage == "40" && doctype == "amendment"
|
47
|
-
ret = "FD" if stage == "50" && %w(amendment technical-corrigendum)
|
48
|
-
.include?(doctype)
|
49
|
-
end
|
50
|
-
ret
|
51
|
-
end
|
52
|
-
|
53
|
-
def stage_name(stage, substage, _doctype, iteration = nil)
|
54
|
-
return "Proof" if stage == "60" && substage == "00"
|
55
|
-
|
56
|
-
ret = STAGE_NAMES[stage.to_sym]
|
57
|
-
if iteration && %w(20 30).include?(stage)
|
58
|
-
prefix = iteration.to_i.localize(@lang.to_sym)
|
59
|
-
.to_rbnf_s("SpelloutRules", "spellout-ordinal")
|
60
|
-
ret = "#{prefix.capitalize} #{ret.downcase}"
|
61
|
-
end
|
62
45
|
ret
|
63
46
|
end
|
64
47
|
|
65
48
|
def metadata_id(node, xml)
|
66
49
|
iso_id(node, xml)
|
67
|
-
node
|
50
|
+
node.attr("tc-docnumber")&.split(/,\s*/)&.each do |n|
|
68
51
|
xml.docidentifier(n, **attr_code(type: "iso-tc"))
|
69
52
|
end
|
70
53
|
xml.docnumber node&.attr("docnumber")
|
71
54
|
end
|
72
55
|
|
56
|
+
# @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type]
|
57
|
+
# document's type, eg. :tr, :ts, :amd, :cor, Type.new(:tr)
|
58
|
+
def get_typeabbr(node, amd: false)
|
59
|
+
node.attr("amendment-number") and return :amd
|
60
|
+
node.attr("corrigendum-number") and return :cor
|
61
|
+
case doctype(node)
|
62
|
+
when "directive" then :dir
|
63
|
+
when "technical-report" then :tr
|
64
|
+
when "technical-specification" then :ts
|
65
|
+
when "guide" then :guide
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
73
69
|
def iso_id(node, xml)
|
74
70
|
(!@amd && node.attr("docnumber")) || (@amd && node.attr("updates")) or
|
75
71
|
return
|
76
|
-
|
77
|
-
|
78
|
-
id_year(dn, node, mode: :force),
|
79
|
-
id_year(dn, node, mode: :strip)]
|
80
|
-
iso_id_out(node, xml, dns)
|
72
|
+
params = iso_id_params(node)
|
73
|
+
iso_id_out(xml, params, true)
|
81
74
|
end
|
82
75
|
|
83
|
-
def
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
76
|
+
def iso_id_params(node)
|
77
|
+
params = iso_id_params_core(node)
|
78
|
+
params2 = iso_id_params_add(node)
|
79
|
+
if node.attr("updates")
|
80
|
+
orig_id = Pubid::Iso::Identifier::Base.parse(node.attr("updates"))
|
81
|
+
orig_id.edition ||= 1
|
82
|
+
end
|
83
|
+
iso_id_params_resolve(params, params2, node, orig_id)
|
84
|
+
end
|
85
|
+
|
86
|
+
# unpublished is for internal use
|
87
|
+
def iso_id_params_core(node)
|
88
|
+
pub = (node.attr("publisher") || "ISO").split(/[;,]/)
|
89
|
+
ret = { number: node.attr("docnumber"),
|
90
|
+
part: node.attr("partnumber"),
|
91
|
+
language: node.attr("language") || "en",
|
92
|
+
type: get_typeabbr(node),
|
93
|
+
publisher: pub[0],
|
94
|
+
unpublished: /^[0-5]/.match?(get_stage(node)),
|
95
|
+
copublisher: pub[1..-1] }.compact
|
96
|
+
ret[:copublisher].empty? and ret.delete(:copublisher)
|
97
|
+
ret
|
90
98
|
end
|
91
99
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
+
def iso_id_params_add(node)
|
101
|
+
stage = iso_id_stage(node)
|
102
|
+
|
103
|
+
ret = { number: node.attr("amendment-number") ||
|
104
|
+
node.attr("corrigendum-number"),
|
105
|
+
year: iso_id_year(node),
|
106
|
+
iteration: node.attr("iteration") }.compact
|
107
|
+
stage and ret[:stage] = stage
|
108
|
+
ret[:stage] == "60.00" and ret[:stage] = :PRF
|
109
|
+
ret
|
100
110
|
end
|
101
111
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
112
|
+
def iso_id_stage(node)
|
113
|
+
stage = stage_abbr(get_stage(node), get_substage(node),
|
114
|
+
doctype(node))
|
115
|
+
harmonised = "#{get_stage(node)}.#{get_substage(node)}"
|
116
|
+
harmonised = nil unless /^\d\d\.\d\d/.match?(harmonised)
|
117
|
+
{ abbr: stage&.to_sym, harmonized_code: harmonised }
|
118
|
+
harmonised || stage&.to_sym
|
119
|
+
end
|
120
|
+
|
121
|
+
def iso_id_year(node)
|
122
|
+
node.attr("copyright-year") || node.attr("updated-date")
|
123
|
+
&.sub(/-.*$/, "") || Date.today.year
|
124
|
+
end
|
125
|
+
|
126
|
+
def iso_id_params_resolve(params, params2, node, orig_id)
|
127
|
+
if orig_id && (node.attr("amendment-number") ||
|
128
|
+
node.attr("corrigendum-number"))
|
129
|
+
params.delete(:unpublished)
|
130
|
+
params.delete(:part)
|
131
|
+
params2[:base] = orig_id
|
109
132
|
end
|
133
|
+
params.merge!(params2)
|
134
|
+
params
|
110
135
|
end
|
111
136
|
|
112
|
-
def
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
}
|
128
|
-
if a = node.attr("amendment-number")
|
129
|
-
params[:amendments] = { number: a, stage: stage }
|
130
|
-
elsif a = node.attr("corrigendum-number")
|
131
|
-
params[:corrigendums] = { number: a, stage: stage }
|
132
|
-
else
|
133
|
-
params.merge!( { stage: stage, urn_stage: urn_stage }.compact )
|
134
|
-
end
|
135
|
-
iso_id_out(xml, params)
|
137
|
+
def iso_id_out(xml, params, with_prf)
|
138
|
+
xml.docidentifier iso_id_default(params).to_s(with_prf: with_prf),
|
139
|
+
**attr_code(type: "ISO")
|
140
|
+
xml.docidentifier iso_id_reference(params)
|
141
|
+
.to_s(format: :ref_num_long, with_prf: with_prf),
|
142
|
+
**attr_code(type: "iso-reference")
|
143
|
+
xml.docidentifier iso_id_reference(params).urn, **attr_code(type: "URN")
|
144
|
+
return if @amd
|
145
|
+
|
146
|
+
xml.docidentifier iso_id_undated(params).to_s(with_prf: with_prf),
|
147
|
+
**attr_code(type: "iso-undated")
|
148
|
+
xml.docidentifier iso_id_with_lang(params)
|
149
|
+
.to_s(format: :ref_num_short, with_prf: with_prf),
|
150
|
+
**attr_code(type: "iso-with-lang")
|
151
|
+
rescue StandardError => e
|
152
|
+
clean_abort("Document identifier: #{e}", xml)
|
136
153
|
end
|
137
154
|
|
138
|
-
def
|
155
|
+
def iso_id_default(params)
|
139
156
|
params_nolang = params.dup.tap { |hs| hs.delete(:language) }
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
warn params
|
149
|
-
warn "Generated: #{Pubid::Iso::Identifier.new(**params).to_s}"
|
150
|
-
xml.docidentifier(Pubid::Iso::Identifier.new(**params),
|
151
|
-
**attr_code(type: "iso-reference"))
|
157
|
+
params1 = if params[:unpublished]
|
158
|
+
params_nolang.dup.tap do |hs|
|
159
|
+
hs.delete(:year)
|
160
|
+
end
|
161
|
+
else params_nolang
|
162
|
+
end
|
163
|
+
params1.delete(:unpublished)
|
164
|
+
Pubid::Iso::Identifier.create(**params1)
|
152
165
|
end
|
153
|
-
=end
|
154
166
|
|
155
|
-
def
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
part, subpart = node&.attr("partnumber")&.split(/-/)
|
161
|
-
add_id_parts(node.attr("docnumber"), part, subpart)
|
167
|
+
def iso_id_undated(params)
|
168
|
+
params_nolang = params.dup.tap { |hs| hs.delete(:language) }
|
169
|
+
params2 = params_nolang.dup.tap do |hs|
|
170
|
+
hs.delete(:year)
|
171
|
+
hs.delete(:unpublished)
|
162
172
|
end
|
173
|
+
Pubid::Iso::Identifier.create(**params2)
|
163
174
|
end
|
164
175
|
|
165
|
-
def
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
176
|
+
def iso_id_with_lang(params)
|
177
|
+
params1 = if params[:unpublished]
|
178
|
+
params.dup.tap do |hs|
|
179
|
+
hs.delete(:year)
|
180
|
+
end
|
181
|
+
else params end
|
182
|
+
params1.delete(:unpublished)
|
183
|
+
Pubid::Iso::Identifier.create(**params1)
|
172
184
|
end
|
173
185
|
|
174
|
-
def
|
175
|
-
|
176
|
-
|
177
|
-
when "en" then "(E)"
|
178
|
-
when "fr" then "(F)"
|
179
|
-
when "ru" then "(R)"
|
180
|
-
else
|
181
|
-
"(X)"
|
182
|
-
end
|
183
|
-
"#{docnum}#{suffix}"
|
186
|
+
def iso_id_reference(params)
|
187
|
+
params1 = params.dup.tap { |hs| hs.delete(:unpublished) }
|
188
|
+
Pubid::Iso::Identifier.create(**params1)
|
184
189
|
end
|
185
190
|
|
186
191
|
def structured_id(node, xml)
|
@@ -197,83 +202,6 @@ pub = (node.attr("publisher") || "ISO").split(/[;,]/)
|
|
197
202
|
end
|
198
203
|
end
|
199
204
|
|
200
|
-
def add_id_parts(docnum, part, subpart)
|
201
|
-
docnum += "-#{part}" if part
|
202
|
-
docnum += "-#{subpart}" if subpart
|
203
|
-
docnum
|
204
|
-
end
|
205
|
-
|
206
|
-
def id_stage_abbr(stage, substage, node, bare = false)
|
207
|
-
ret = id_stage_abbr1(stage, substage, node, bare)
|
208
|
-
if %w(amendment technical-corrigendum technical-report
|
209
|
-
technical-specification).include?(doctype(node)) &&
|
210
|
-
!%w(D FD).include?(ret)
|
211
|
-
ret = "#{ret} "
|
212
|
-
end
|
213
|
-
ret
|
214
|
-
end
|
215
|
-
|
216
|
-
def id_stage_abbr1(stage, substage, node, bare)
|
217
|
-
if bare
|
218
|
-
IsoDoc::Iso::Metadata.new("en", "Latn", nil, @i18n)
|
219
|
-
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
220
|
-
substage, nil, nil, doctype(node))
|
221
|
-
else
|
222
|
-
IsoDoc::Iso::Metadata.new("en", "Latn", nil, @i18n)
|
223
|
-
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
224
|
-
substage, node.attr("iteration"),
|
225
|
-
node.attr("draft"), doctype(node))
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
def cover_stage_abbr(node)
|
230
|
-
stage = get_stage(node)
|
231
|
-
abbr = id_stage_abbr(get_stage(node), get_substage(node), node, true)
|
232
|
-
typeabbr = get_typeabbr(node, amd: true)
|
233
|
-
if stage.to_i > 50 || (stage.to_i == 60 && get_substage(node).to_i < 60)
|
234
|
-
typeabbr = ""
|
235
|
-
end
|
236
|
-
"#{abbr}#{typeabbr}".strip
|
237
|
-
end
|
238
|
-
|
239
|
-
def id_stage_prefix(docnum, node)
|
240
|
-
stage = get_stage(node)
|
241
|
-
typeabbr = get_typeabbr(node)
|
242
|
-
if stage && (stage.to_i < 60)
|
243
|
-
docnum = unpub_stage_prefix(docnum, stage, typeabbr, node)
|
244
|
-
elsif typeabbr == "DIR " then docnum = "#{typeabbr}#{docnum}"
|
245
|
-
elsif typeabbr && !@amd then docnum = "/#{typeabbr}#{docnum}"
|
246
|
-
end
|
247
|
-
docnum
|
248
|
-
end
|
249
|
-
|
250
|
-
def id_year(docnum, node, mode: :default)
|
251
|
-
case mode
|
252
|
-
when :strip then docnum.sub(/:(19|20)\d\d(?!\d)/, "")
|
253
|
-
when :force then id_add_year(docnum, node)
|
254
|
-
else
|
255
|
-
stage = get_stage(node)
|
256
|
-
if stage && (stage.to_i < 60)
|
257
|
-
docnum
|
258
|
-
else id_add_year(docnum, node)
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
def unpub_stage_prefix(docnum, stage, typeabbr, node)
|
264
|
-
abbr = id_stage_abbr(stage, get_substage(node), node)
|
265
|
-
%w(40 50).include?(stage) && i = node.attr("iteration") and
|
266
|
-
itersuffix = ".#{i}"
|
267
|
-
return docnum if abbr.nil? || abbr.empty? # prefixes added in cleanup
|
268
|
-
|
269
|
-
typeabbr = "" if %w(DTS FDTS).include?(abbr.sub(/\s+$/, ""))
|
270
|
-
return "/#{abbr}#{typeabbr} #{docnum}#{itersuffix}" unless @amd
|
271
|
-
|
272
|
-
a = docnum.split(%r{/})
|
273
|
-
a[-1] = "#{abbr}#{a[-1]}#{itersuffix}"
|
274
|
-
a.join("/")
|
275
|
-
end
|
276
|
-
|
277
205
|
def id_add_year(docnum, node)
|
278
206
|
year = node.attr("copyright-year")
|
279
207
|
@amd and year ||= node.attr("updated-date")&.sub(/-.*$/, "")
|
@@ -45,9 +45,13 @@ module Metanorma
|
|
45
45
|
super
|
46
46
|
end
|
47
47
|
|
48
|
+
# in ISO, term has subterm, unless
|
49
|
+
# there is no definition to the term (subclauses start immediately),
|
50
|
+
# or it is labelled as "grouping"
|
48
51
|
def term_contains_subclauses(node)
|
49
|
-
|
50
|
-
|
52
|
+
!node.sections? and return false
|
53
|
+
node.level != node.blocks[0].level ||
|
54
|
+
node.role == "grouping"
|
51
55
|
end
|
52
56
|
end
|
53
57
|
end
|
data/metanorma-iso.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
|
35
35
|
spec.add_dependency "metanorma-standoc", "~> 2.3.0"
|
36
36
|
spec.add_dependency "mnconvert", "~> 1.14"
|
37
|
-
spec.add_dependency "pubid-iso"
|
37
|
+
spec.add_dependency "pubid-iso", "~> 0.4.0"
|
38
38
|
spec.add_dependency "ruby-jing"
|
39
39
|
spec.add_dependency "tokenizer", "~> 0.3.0"
|
40
40
|
spec.add_dependency "twitter_cldr"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-standoc
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: pubid-iso
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.4.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:
|
54
|
+
version: 0.4.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: ruby-jing
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -296,7 +296,6 @@ files:
|
|
296
296
|
- ".rubocop.yml"
|
297
297
|
- CODE_OF_CONDUCT.md
|
298
298
|
- Gemfile
|
299
|
-
- Gemfile.devel
|
300
299
|
- LICENSE
|
301
300
|
- Makefile
|
302
301
|
- README.adoc
|
data/Gemfile.devel
DELETED