metanorma-itu 2.8.8 → 2.8.9
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/lib/isodoc/itu/i18n-ar.yaml +1 -1
- data/lib/isodoc/itu/metadata.rb +20 -19
- data/lib/isodoc/itu/metadata_date.rb +26 -14
- data/lib/isodoc/itu/presentation_bibdata.rb +18 -13
- data/lib/isodoc/itu/word_cleanup.rb +33 -34
- data/lib/metanorma/itu/front.rb +9 -8
- data/lib/metanorma/itu/front_id.rb +83 -33
- data/lib/metanorma/itu/version.rb +1 -1
- data/metanorma-itu.gemspec +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c79cddef8a6aef9e8d667048e0dd426441c2dc129c0f21c69525239a48144ce1
|
|
4
|
+
data.tar.gz: 755506724bd48e5a84cfd1208bc942d4ba4dad8cae6d44f1a014338320e4bc4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34f34dce2494bce28d4849f8b2bacf5b1045834d9ea766cd34e9cf1dbf2e46ec09412e1c6170598652206e138ac6a771f54cc1c87e5689e961a8ba75cff3cbb1
|
|
7
|
+
data.tar.gz: 5a83fa8c083ce8c66ef29131d414c2b0d48edaa5ead51543cdcfae92686a4c14d365eeaeb9607449a7875ca5df4d0071420f72a212028cef86dc867703ca6538
|
data/.rubocop.yml
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Auto-generated by Cimas: Do not edit it manually!
|
|
2
2
|
# See https://github.com/metanorma/cimas
|
|
3
3
|
inherit_from:
|
|
4
|
-
- https://raw.githubusercontent.com/riboseinc/oss-guides/
|
|
4
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
|
|
5
5
|
|
|
6
6
|
# local repo-specific modifications
|
|
7
7
|
# ...
|
|
8
8
|
|
|
9
9
|
AllCops:
|
|
10
|
-
TargetRubyVersion:
|
|
10
|
+
TargetRubyVersion: 3.4
|
data/lib/isodoc/itu/i18n-ar.yaml
CHANGED
|
@@ -60,7 +60,7 @@ page: الصفحة
|
|
|
60
60
|
placedate: "جنيف، %"
|
|
61
61
|
annex_to_itu_ob: ملحق بالنشرة التشغيلية للاتحاد
|
|
62
62
|
number_abbrev: رقم
|
|
63
|
-
annex_to_itu_ob_abbrev: ملحق بالنشرة التشغيلية للاتحاد
|
|
63
|
+
annex_to_itu_ob_abbrev: "% ملحق بالنشرة التشغيلية للاتحاد "
|
|
64
64
|
international_telecommunication_union: الاتحاد الدولي للاتصالات
|
|
65
65
|
position_on: الوضع في
|
|
66
66
|
revision_abbreviation: المراجعة
|
data/lib/isodoc/itu/metadata.rb
CHANGED
|
@@ -9,7 +9,7 @@ module IsoDoc
|
|
|
9
9
|
@isodoc = IsoDoc::Itu::HtmlConvert.new({})
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def images(
|
|
12
|
+
def images(_isoxml, _xml)
|
|
13
13
|
n = "International_Telecommunication_Union_Logo.svg"
|
|
14
14
|
set(:logo_html, fileloc(n))
|
|
15
15
|
set(:logo_comb, fileloc("itu-document-comb.png"))
|
|
@@ -67,22 +67,13 @@ module IsoDoc
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
COMMITTEE_XPATH = "//bibdata/contributor[role/description = 'committee']/" \
|
|
70
|
-
|
|
70
|
+
"organization/subdivision".freeze
|
|
71
71
|
|
|
72
72
|
def author(xml, _out)
|
|
73
73
|
sector = xml.at(ns("#{COMMITTEE_XPATH}[@type='Sector']/name"))
|
|
74
74
|
set(:sector, sector.text) if sector
|
|
75
75
|
bureau(xml)
|
|
76
|
-
|
|
77
|
-
set(:group, tc.text) if tc
|
|
78
|
-
tc = xml.at(ns("#{COMMITTEE_XPATH}[@type='Group']/identifier"))
|
|
79
|
-
set(:group_acronym, tc.text) if tc
|
|
80
|
-
start1 = xml.at(ns("//bibdata/ext/studyperiod/start"))
|
|
81
|
-
end1 = xml.at(ns("//bibdata/ext/studyperiod/end"))
|
|
82
|
-
if start1
|
|
83
|
-
set(:study_group_period,
|
|
84
|
-
@i18n.l10n("#{start1.text}–#{end1.text}"))
|
|
85
|
-
end
|
|
76
|
+
study_group(xml)
|
|
86
77
|
tc = xml.at(ns("#{COMMITTEE_XPATH}[@type='Subgroup']/name"))
|
|
87
78
|
set(:subgroup, tc.text) if tc
|
|
88
79
|
tc = xml.at(ns("#{COMMITTEE_XPATH}[@type='Workgroup']/name"))
|
|
@@ -93,14 +84,24 @@ module IsoDoc
|
|
|
93
84
|
person_attributes(authors) unless authors.empty?
|
|
94
85
|
end
|
|
95
86
|
|
|
87
|
+
def study_group(xml)
|
|
88
|
+
tc = xml.at(ns("#{COMMITTEE_XPATH}[@type='Group']/name"))
|
|
89
|
+
set(:group, tc.text) if tc
|
|
90
|
+
tc = xml.at(ns("#{COMMITTEE_XPATH}[@type='Group']/identifier"))
|
|
91
|
+
set(:group_acronym, tc.text) if tc
|
|
92
|
+
start1 = xml.at(ns("//bibdata/ext/studyperiod/start")) or return
|
|
93
|
+
end1 = xml.at(ns("//bibdata/ext/studyperiod/end"))
|
|
94
|
+
set(:study_group_period,
|
|
95
|
+
@i18n.l10n("#{start1.text}–#{end1.text}"))
|
|
96
|
+
end
|
|
97
|
+
|
|
96
98
|
def bureau(xml)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
end
|
|
99
|
+
bureau = xml.at(ns("#{COMMITTEE_XPATH}[@type='Bureau']/name")) or return
|
|
100
|
+
set(:bureau, bureau.text)
|
|
101
|
+
case bureau.text
|
|
102
|
+
when "T" then set(:bureau_full, @i18n.tsb_full)
|
|
103
|
+
when "D" then set(:bureau_full, @i18n.bdt_full)
|
|
104
|
+
when "R" then set(:bureau_full, @i18n.br_full)
|
|
104
105
|
end
|
|
105
106
|
end
|
|
106
107
|
|
|
@@ -2,17 +2,21 @@ module IsoDoc
|
|
|
2
2
|
module Itu
|
|
3
3
|
class Metadata < IsoDoc::Metadata
|
|
4
4
|
def monthyr(isodate)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
IsoDoc::ExtendedDateFormatter.format_iso_date(
|
|
6
|
+
isodate,
|
|
7
|
+
lang: @lang,
|
|
8
|
+
year_month: "%m/%Y",
|
|
9
|
+
full: "%m/%Y",
|
|
10
|
+
)
|
|
8
11
|
end
|
|
9
12
|
|
|
10
13
|
def ddMMMYYYY(isodate)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
out = IsoDoc::ExtendedDateFormatter.format_iso_date(
|
|
15
|
+
isodate,
|
|
16
|
+
lang: @lang,
|
|
17
|
+
full: "%d %b %Y",
|
|
18
|
+
)
|
|
19
|
+
out == isodate ? out : @i18n.l10n(out)
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
def ddMMMMYYYY(date1, date2)
|
|
@@ -24,22 +28,30 @@ module IsoDoc
|
|
|
24
28
|
dd2 = m2[:dd].sub(/^0/, "")
|
|
25
29
|
if m1[:yr] == m2[:yr]
|
|
26
30
|
if m1[:mo] == m2[:mo]
|
|
27
|
-
@i18n.l10n("#{dd1}–#{dd2} #{
|
|
31
|
+
@i18n.l10n("#{dd1}–#{dd2} #{localized_month(m1[:mo])} #{m1[:yr]}")
|
|
28
32
|
else
|
|
29
|
-
@i18n.l10n("#{dd1} #{
|
|
30
|
-
"#{dd2} #{
|
|
33
|
+
@i18n.l10n("#{dd1} #{localized_month(m1[:mo])} – " \
|
|
34
|
+
"#{dd2} #{localized_month(m2[:mo])} #{m1[:yr]}")
|
|
31
35
|
end
|
|
32
36
|
else
|
|
33
|
-
@i18n.l10n("#{dd1} #{
|
|
34
|
-
"#{dd2} #{
|
|
37
|
+
@i18n.l10n("#{dd1} #{localized_month(m1[:mo])} #{m1[:yr]} – " \
|
|
38
|
+
"#{dd2} #{localized_month(m2[:mo])} #{m2[:yr]}")
|
|
35
39
|
end
|
|
36
40
|
else
|
|
37
|
-
date2.nil? ? @i18n.l10n("#{dd1} #{
|
|
41
|
+
date2.nil? ? @i18n.l10n("#{dd1} #{localized_month(m1[:mo])} #{m1[:yr]}") : "#{date1}/#{date2}"
|
|
38
42
|
end
|
|
39
43
|
else
|
|
40
44
|
date2.nil? ? date1 : "#{date1}/#{date2}"
|
|
41
45
|
end
|
|
42
46
|
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def localized_month(month)
|
|
51
|
+
IsoDoc::ExtendedDateFormatter.format(
|
|
52
|
+
"2000-#{month}-01", "%B", lang: @lang
|
|
53
|
+
)
|
|
54
|
+
end
|
|
43
55
|
end
|
|
44
56
|
end
|
|
45
57
|
end
|
|
@@ -52,28 +52,33 @@ module IsoDoc
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def ddMMMyyyy(date)
|
|
55
|
-
|
|
55
|
+
IsoDoc::ExtendedDateFormatter.format_iso_date(
|
|
56
|
+
date, lang: @lang, **roman_or_chinese_formats
|
|
57
|
+
)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def roman_or_chinese_formats
|
|
56
61
|
case @lang
|
|
57
62
|
when "zh"
|
|
58
|
-
|
|
59
|
-
d[1] += "月" if d[1]
|
|
60
|
-
d[2] += "日" if d[2]
|
|
61
|
-
d.join
|
|
63
|
+
{ year: "%Y年", year_month: "%Y年%-m月", full: "%Y年%-m月%-d日" }
|
|
62
64
|
when "ar"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
{ year: "%Y", year_month: "%Y.%Om[roman]",
|
|
66
|
+
full: "%Y.%Om[roman].%-d" }
|
|
65
67
|
else
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
{ year: "%Y", year_month: "%Om[roman].%Y",
|
|
69
|
+
full: "%-d.%Om[roman].%Y" }
|
|
68
70
|
end
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
def ddmmmmyyyy(date)
|
|
72
74
|
@lang == "zh" and return ddMMMyyyy(date)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
out = IsoDoc::ExtendedDateFormatter.format_iso_date(
|
|
76
|
+
date,
|
|
77
|
+
lang: @lang,
|
|
78
|
+
year_month: "%B %Y",
|
|
79
|
+
full: "%-d %B %Y",
|
|
80
|
+
)
|
|
81
|
+
out == date ? out : l10n(out)
|
|
77
82
|
end
|
|
78
83
|
|
|
79
84
|
def amendment_id(bib)
|
|
@@ -2,7 +2,7 @@ module IsoDoc
|
|
|
2
2
|
module Itu
|
|
3
3
|
class WordConvert < IsoDoc::WordConvert
|
|
4
4
|
def word_preface_cleanup(docxml)
|
|
5
|
-
docxml.xpath("//h1[@class = 'AbstractTitle'] | "\
|
|
5
|
+
docxml.xpath("//h1[@class = 'AbstractTitle'] | " \
|
|
6
6
|
"//h1[@class = 'IntroTitle']").each do |h2|
|
|
7
7
|
h2.name = "p"
|
|
8
8
|
h2["class"] = "h1Preface"
|
|
@@ -25,8 +25,8 @@ module IsoDoc
|
|
|
25
25
|
|
|
26
26
|
def word_footnote_cleanup(docxml)
|
|
27
27
|
docxml.xpath("//aside").each do |a|
|
|
28
|
-
a.first_element_child
|
|
29
|
-
add_first_child '<span style="mso-tab-count:1"/>'
|
|
28
|
+
a.first_element_child
|
|
29
|
+
.add_first_child '<span style="mso-tab-count:1"/>'
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -50,21 +50,13 @@ module IsoDoc
|
|
|
50
50
|
|
|
51
51
|
def word_preface(docxml)
|
|
52
52
|
super
|
|
53
|
-
abstractbox
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
source = docxml.at("//div[@class = 'source']")
|
|
61
|
-
keywords = docxml.at("//div[@class = 'Keyword']")
|
|
62
|
-
changelog = docxml.at("//div[@id = 'change_log']")
|
|
63
|
-
abstract.parent = abstractbox if abstract && abstractbox
|
|
64
|
-
history.parent = historybox if history && historybox
|
|
65
|
-
source.parent = sourcebox if source && sourcebox
|
|
66
|
-
keywords.parent = keywordsbox if keywords && keywordsbox
|
|
67
|
-
changelog.parent = changelogbox if changelog && changelogbox
|
|
53
|
+
{ abstractbox: "Abstract", historybox: "history",
|
|
54
|
+
sourcebox: "source", keywordsbox: "Keyword",
|
|
55
|
+
changelogbox: "change_log" }.each do |k, v|
|
|
56
|
+
box = docxml.at("//div[@id='#{k}']")
|
|
57
|
+
content = docxml.at("//div[@class = '#{v}']")
|
|
58
|
+
content.parent = box if content && box
|
|
59
|
+
end
|
|
68
60
|
end
|
|
69
61
|
|
|
70
62
|
def toWord(result, filename, dir, header)
|
|
@@ -82,8 +74,8 @@ module IsoDoc
|
|
|
82
74
|
def postprocess_cleanup(result)
|
|
83
75
|
result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
|
|
84
76
|
result = populate_template(result, :word)
|
|
85
|
-
|
|
86
|
-
.gsub(
|
|
77
|
+
from_xhtml(word_cleanup(to_xhtml(result)))
|
|
78
|
+
.gsub("-DOUBLE_HYPHEN_ESCAPE-", "--")
|
|
87
79
|
end
|
|
88
80
|
|
|
89
81
|
def wordstylesheet_update
|
|
@@ -128,24 +120,31 @@ module IsoDoc
|
|
|
128
120
|
auth = docxml.at("//div[@id = 'draft-warning']")
|
|
129
121
|
dest and auth and dest.replace(auth.remove)
|
|
130
122
|
%w(copyright license legal).each do |t|
|
|
131
|
-
|
|
132
|
-
auth = docxml.at("//div[@class = 'boilerplate-#{t}']")
|
|
133
|
-
auth.remove if auth && !dest
|
|
134
|
-
next unless auth && dest
|
|
135
|
-
|
|
136
|
-
t == "copyright" and para = auth&.at(".//p") and
|
|
137
|
-
para["class"] = "boilerplateHdr"
|
|
138
|
-
auth&.xpath(".//p[not(@class)]")&.each_with_index do |p, _i|
|
|
139
|
-
p["class"] = "boilerplate"
|
|
140
|
-
# i == 0 && t == "copyright" and p["style"] = "text-align:center;"
|
|
141
|
-
end
|
|
142
|
-
t == "copyright" or
|
|
143
|
-
auth << "<p> </p><p> </p><p> </p>"
|
|
144
|
-
dest.replace(auth.remove)
|
|
123
|
+
authority_cleanup1(docxml, t)
|
|
145
124
|
end
|
|
146
125
|
coverpage_note_cleanup(docxml)
|
|
147
126
|
end
|
|
148
127
|
|
|
128
|
+
def authority_cleanup1(docxml, type)
|
|
129
|
+
auth, dest = authority_cleanup1_prep(docxml, type)
|
|
130
|
+
(auth && dest) or return
|
|
131
|
+
type == "copyright" and para = auth.at(".//p") and
|
|
132
|
+
para["class"] = "boilerplateHdr"
|
|
133
|
+
auth.xpath(".//p[not(@class)]").each do |p|
|
|
134
|
+
p["class"] = "boilerplate"
|
|
135
|
+
end
|
|
136
|
+
type == "copyright" or
|
|
137
|
+
auth << "<p> </p><p> </p><p> </p>"
|
|
138
|
+
dest.replace(auth.remove)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def authority_cleanup1_prep(docxml, type)
|
|
142
|
+
dest = docxml.at("//div[@id = 'boilerplate-#{type}-destination']")
|
|
143
|
+
auth = docxml.at("//div[@class = 'boilerplate-#{type}']")
|
|
144
|
+
auth.remove if auth && !dest
|
|
145
|
+
[auth, dest]
|
|
146
|
+
end
|
|
147
|
+
|
|
149
148
|
TOPLIST = "[not(ancestor::ul) and not(ancestor::ol)]".freeze
|
|
150
149
|
|
|
151
150
|
def table_list_style(xml)
|
data/lib/metanorma/itu/front.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "fileutils"
|
|
2
|
-
require_relative "
|
|
3
|
-
require_relative "
|
|
2
|
+
require_relative "front_id"
|
|
3
|
+
require_relative "front_contrib"
|
|
4
4
|
|
|
5
5
|
module Metanorma
|
|
6
6
|
module Itu
|
|
@@ -9,7 +9,8 @@ module Metanorma
|
|
|
9
9
|
stage = node.attr("status") || node.attr("docstage") || "published"
|
|
10
10
|
stage = "draft" if node.attributes.has_key?("draft")
|
|
11
11
|
xml.status do |s|
|
|
12
|
-
add_noko_elem(s, "stage", stage,
|
|
12
|
+
add_noko_elem(s, "stage", stage,
|
|
13
|
+
abbreviation: node.attr("docstage-abbrev"))
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
|
|
@@ -49,14 +50,14 @@ module Metanorma
|
|
|
49
50
|
|
|
50
51
|
def other_title_defaultlang(node, xml, type)
|
|
51
52
|
a = node.attr(type) || node.attr("#{type}-#{@lang}")
|
|
52
|
-
add_title_xml(xml, a, @lang, type.sub(
|
|
53
|
+
add_title_xml(xml, a, @lang, type.sub("-title", ""))
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def other_title_otherlangs(node, xml, type)
|
|
56
57
|
node.attributes.each do |k, v|
|
|
57
58
|
m = /^#{type}-(?<lang>.+)$/.match(k) or next
|
|
58
59
|
m[:lang] == @lang and next
|
|
59
|
-
add_title_xml(xml, v, m[:lang], type.sub(
|
|
60
|
+
add_title_xml(xml, v, m[:lang], type.sub("-title", ""))
|
|
60
61
|
end
|
|
61
62
|
end
|
|
62
63
|
|
|
@@ -76,8 +77,8 @@ module Metanorma
|
|
|
76
77
|
|
|
77
78
|
def group_period(node, prefix, suffix)
|
|
78
79
|
s = node.attr("#{prefix}group-year-start#{suffix}") ||
|
|
79
|
-
Date.today.year - (Date.today.year % 2)
|
|
80
|
-
e = node.attr("#{prefix}group-year-end#{suffix}") || s.to_i + 2
|
|
80
|
+
(Date.today.year - (Date.today.year % 2))
|
|
81
|
+
e = node.attr("#{prefix}group-year-end#{suffix}") || (s.to_i + 2)
|
|
81
82
|
[s, e]
|
|
82
83
|
end
|
|
83
84
|
|
|
@@ -85,7 +86,7 @@ module Metanorma
|
|
|
85
86
|
{ series: "main", series1: "secondary", series2: "tertiary" }
|
|
86
87
|
.each do |k, v|
|
|
87
88
|
node.attr(k.to_s) and
|
|
88
|
-
xml.series
|
|
89
|
+
xml.series type: v do |s|
|
|
89
90
|
add_noko_elem(s, "title", node.attr(k.to_s))
|
|
90
91
|
end
|
|
91
92
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "pubid-itu"
|
|
2
|
+
|
|
1
3
|
module Metanorma
|
|
2
4
|
module Itu
|
|
3
5
|
class Converter < Standoc::Converter
|
|
@@ -25,55 +27,103 @@ module Metanorma
|
|
|
25
27
|
node.attr("common-text-docnumber"), type: "ISO")
|
|
26
28
|
end
|
|
27
29
|
|
|
30
|
+
# KILL
|
|
28
31
|
ITULANG = { "en" => "E", "fr" => "F", "ar" => "A", "es" => "S",
|
|
29
32
|
"zh" => "C", "ru" => "R" }.freeze
|
|
30
33
|
|
|
31
|
-
def
|
|
32
|
-
|
|
33
|
-
id = case doctype(node)
|
|
34
|
-
when "service-publication"
|
|
35
|
-
itu_service_pub_id(node)
|
|
36
|
-
when "contribution"
|
|
37
|
-
itu_contrib_id(node)
|
|
38
|
-
else
|
|
39
|
-
"ITU-#{bureau} #{node.attr('docnumber')}"
|
|
40
|
-
end
|
|
41
|
-
itu_lang(id, lang)
|
|
34
|
+
def metadata_id_primary_type(_node)
|
|
35
|
+
"ITU"
|
|
42
36
|
end
|
|
43
37
|
|
|
44
|
-
def
|
|
45
|
-
|
|
38
|
+
def metadata_id_primary(node, xml)
|
|
39
|
+
itu_id(node, xml)
|
|
46
40
|
end
|
|
47
41
|
|
|
48
|
-
def
|
|
49
|
-
|
|
42
|
+
def itu_id(node, xml)
|
|
43
|
+
node.attr("docnumber") or return
|
|
44
|
+
params = itu_id_params(node)
|
|
45
|
+
itu_id_out(node, xml, params)
|
|
50
46
|
end
|
|
51
47
|
|
|
52
|
-
def
|
|
53
|
-
|
|
54
|
-
node.attr("group")&.sub("Study Group ", "SG") || "XXX"
|
|
55
|
-
"#{group}-C#{node.attr('docnumber')}"
|
|
48
|
+
def compact_blank(hash)
|
|
49
|
+
hash.compact.reject { |_, v| v.is_a?(String) && v.empty? }
|
|
56
50
|
end
|
|
57
51
|
|
|
58
|
-
def
|
|
59
|
-
node.attr("
|
|
60
|
-
|
|
61
|
-
itu_id1(node, false),
|
|
62
|
-
type: "ITU", primary: "true")
|
|
63
|
-
add_noko_elem(xml, "docidentifier",
|
|
64
|
-
itu_id1(node, true), type: "ITU-lang")
|
|
52
|
+
def itu_id_pub(node)
|
|
53
|
+
(node.attr("publisher") || "ITU").split(/[;,]/)
|
|
54
|
+
.map(&:strip).map { |x| org_abbrev[x] || x }
|
|
65
55
|
end
|
|
66
56
|
|
|
67
|
-
def
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
def itu_id_params(node)
|
|
58
|
+
itu_id_resolve(node, itu_id_params_core(node), itu_id_params_add(node))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def itu_id_resolve(_node, core, add)
|
|
62
|
+
ret = core.merge(add)
|
|
63
|
+
case @doctype
|
|
64
|
+
when "service-publication"
|
|
65
|
+
base = ret.merge(series: "OB")
|
|
66
|
+
ret = { type: :annex, base: base }
|
|
67
|
+
when "contribution"
|
|
68
|
+
ret[:type] = :contribution
|
|
69
|
+
end
|
|
70
|
+
ret
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def itu_id_params_core(node)
|
|
74
|
+
pub = itu_id_pub(node)
|
|
75
|
+
num = node.attr("docnumber")
|
|
76
|
+
ret = { sector: itu_id_params_sector(node),
|
|
77
|
+
publisher: pub[0],
|
|
78
|
+
copublisher: pub[1..-1] }.compact
|
|
79
|
+
ret.merge!(itu_id_params_num(num))
|
|
80
|
+
ret[:copublisher].empty? and ret.delete(:copublisher)
|
|
81
|
+
ret
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def itu_id_params_sector(node)
|
|
85
|
+
node.attr("doctype") == "service-publication" and return nil
|
|
86
|
+
node.attr("bureau") || "T"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def itu_id_params_num(num)
|
|
90
|
+
if m = /^(?:(?<series>[A-Z])\.)?(?<number>\d+)$/.match(num)
|
|
91
|
+
{ series: m[:series], number: m[:number] }
|
|
92
|
+
else { number: num }
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def itu_id_params_add(node)
|
|
97
|
+
ret = { part: node.attr("partnumber") }
|
|
98
|
+
@doctype == "contribution" and
|
|
99
|
+
ret[:series] = node.attr("group-acronym") ||
|
|
100
|
+
node.attr("group")&.sub("Study Group ", "SG")
|
|
101
|
+
compact_blank(ret)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def itu_id_out(node, xml, params)
|
|
105
|
+
add_noko_elem(xml, "docidentifier", itu_id_default(node, params)
|
|
106
|
+
.to_s(i18n_lang: @lang),
|
|
107
|
+
type: "ITU", primary: "true")
|
|
108
|
+
id_lang = itu_id_lang(node, params)
|
|
109
|
+
add_noko_elem(xml, "docidentifier", id_lang.to_s(language: @lang,
|
|
110
|
+
i18n_lang: @lang),
|
|
72
111
|
type: "ITU-lang")
|
|
112
|
+
add_noko_elem(xml, "docidentifier", id_lang
|
|
113
|
+
.to_s(language: @lang, i18n_lang: @lang, format: :long),
|
|
114
|
+
type: "ITU-lang-long")
|
|
73
115
|
end
|
|
74
116
|
|
|
75
|
-
def
|
|
76
|
-
|
|
117
|
+
def itu_id_default(node, params)
|
|
118
|
+
p = params.dup
|
|
119
|
+
p[:base] &&= itu_id_default(node, p[:base])
|
|
120
|
+
Pubid::Itu::Identifier.create(**p)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def itu_id_lang(node, params)
|
|
124
|
+
params[:base] &&= itu_id_lang(node, params[:base])
|
|
125
|
+
params[:language] = @lang
|
|
126
|
+
Pubid::Itu::Identifier.create(**params)
|
|
77
127
|
end
|
|
78
128
|
|
|
79
129
|
def recommendation_id(node, xml)
|
data/metanorma-itu.gemspec
CHANGED
|
@@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.require_paths = ["lib"]
|
|
26
26
|
spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
|
|
27
27
|
|
|
28
|
-
spec.add_dependency "metanorma-standoc", "~> 3.4.
|
|
28
|
+
spec.add_dependency "metanorma-standoc", "~> 3.4.2"
|
|
29
29
|
spec.add_dependency "pubid"
|
|
30
30
|
spec.add_dependency "twitter_cldr", ">= 3.0.0"
|
|
31
31
|
spec.add_dependency "tzinfo-data" # we need this for windows only
|
|
32
32
|
|
|
33
|
-
spec.add_development_dependency "canon"
|
|
33
|
+
spec.add_development_dependency "canon" #, "= 0.2.3"
|
|
34
34
|
spec.add_development_dependency "debug"
|
|
35
35
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
|
36
36
|
spec.add_development_dependency "guard", "~> 2.14"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-itu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.8.
|
|
4
|
+
version: 2.8.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: metanorma-standoc
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 3.4.
|
|
19
|
+
version: 3.4.2
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 3.4.
|
|
26
|
+
version: 3.4.2
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: pubid
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -70,16 +70,16 @@ dependencies:
|
|
|
70
70
|
name: canon
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
73
|
+
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0
|
|
75
|
+
version: '0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- -
|
|
80
|
+
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0
|
|
82
|
+
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: debug
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|