metanorma-itu 2.7.7 → 2.8.1

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.
@@ -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
- s.stage stage
12
+ add_noko_elem(s, "stage", stage)
13
+ # s.stage stage
13
14
  end
14
15
  end
15
16
 
@@ -65,8 +66,9 @@ module Metanorma
65
66
  end
66
67
  vals.each do |v|
67
68
  xml.question do |q|
68
- a = v[:id] and q.identifier a
69
- a = v[:value] and q.name a
69
+ add_noko_elem(q, "identifier", v[:id])
70
+ # q.identifier a
71
+ add_noko_elem(q, "name", v[:value]) # q.name a
70
72
  end
71
73
  end
72
74
  end
@@ -83,7 +85,7 @@ module Metanorma
83
85
  .each do |k, v|
84
86
  node.attr(k.to_s) and
85
87
  xml.series **{ type: v } do |s|
86
- s.title node.attr(k.to_s)
88
+ add_noko_elem(s, "title", node.attr(k.to_s))
87
89
  end
88
90
  end
89
91
  end
@@ -92,37 +94,46 @@ module Metanorma
92
94
  node.attr("recommendation-from") || node.attr("approval-process") or
93
95
  return
94
96
  xml.recommendationstatus do |s|
95
- a = node.attr("recommendation-from") and s.from a
96
- a = node.attr("recommendation-to") and s.to a
97
+ add_noko_elem(s, "from", node.attr("recommendation-from"))
98
+ add_noko_elem(s, "to", node.attr("recommendation-to"))
97
99
  node.attr("approval-process") and
98
- s.approvalstage **{ process: node.attr("approval-process") } do |x|
99
- x << node.attr("approval-status")
100
- end
100
+ add_noko_elem(s, "approvalstage", node.attr("approval-status"),
101
+ process: node.attr("approval-process"))
102
+ # s.approvalstage **{ process: node.attr("approval-process") } do |x|
103
+ # x << node.attr("approval-status")
104
+ # end
101
105
  end
102
106
  end
103
107
 
104
108
  def metadata_ip_notice(node, xml)
105
- xml.ip_notice_received (node.attr("ip-notice-received") || "false")
109
+ add_noko_elem(xml, "ip-notice-received",
110
+ node.attr("ip-notice-received") || "false")
111
+ # xml.ip_notice_received (node.attr("ip-notice-received") || "false")
106
112
  end
107
113
 
108
114
  def metadata_techreport(node, xml)
109
115
  a = node.attr("meeting") and
110
116
  metadata_meeting(a, node.attr("meeting-acronym"), xml)
111
- a = node.attr("meeting-place") and xml.meeting_place a
117
+ add_noko_elem(xml, "meeting_place", node.attr("meeting-place"))
118
+ # a = node.attr("meeting-place") and xml.meeting_place a
112
119
  a = node.attr("meeting-date") and metadata_meeting_date(a, xml)
113
- a = node.attr("intended-type") and xml.intended_type a
114
- a = node.attr("source") and xml.source a
120
+ add_noko_elem(xml, "intended_type", node.attr("intended-type"))
121
+ # a = node.attr("intended-type") and xml.intended_type a
122
+ add_noko_elem(xml, "source", node.attr("source"))
123
+ # a = node.attr("source") and xml.source a
115
124
  end
116
125
 
117
126
  def metadata_meeting(mtg, acronym, xml)
118
- xml.meeting **attr_code(acronym: acronym) do |m|
119
- m << mtg
120
- end
127
+ add_noko_elem(xml, "meeting", mtg, acronym: acronym)
128
+ # xml.meeting **attr_code(acronym: acronym) do |m|
129
+ # m << mtg
130
+ # end
121
131
  end
122
132
 
123
133
  def metadata_contribution(node, xml)
124
134
  %w(timing).each do |k|
125
- a = node.attr(k) and xml.send k, a
135
+ add_noko_elem(xml, k, node.attr(k))
136
+ # a = node.attr(k) and xml.send k, a
126
137
  end
127
138
  end
128
139
 
@@ -130,17 +141,21 @@ module Metanorma
130
141
  xml.meeting_date do |m|
131
142
  d = val.split("/")
132
143
  if d.size > 1
133
- m.from d[0]
134
- m.to d[1]
144
+ add_noko_elem(m, "from", d[0])
145
+ # m.from d[0]
146
+ add_noko_elem(m, "to", d[1])
147
+ # m.to d[1]
135
148
  else
136
- m.on d[0]
149
+ add_noko_elem(m, "on", d[0])
150
+ # m.on d[0]
137
151
  end
138
152
  end
139
153
  end
140
154
 
141
155
  def personal_role(node, contrib, suffix)
142
156
  if node.attr("role#{suffix}")&.downcase == "rapporteur"
143
- contrib.role "raporteur", **{ type: "editor" }
157
+ add_noko_elem(contrib, "role", "raporteur", type: "editor")
158
+ # contrib.role "raporteur", **{ type: "editor" }
144
159
  else
145
160
  super
146
161
  end
@@ -149,8 +164,8 @@ module Metanorma
149
164
  def metadata_studyperiod(node, xml)
150
165
  s, e = group_period(node, "", "")
151
166
  xml.studyperiod do |p|
152
- p.start s
153
- p.end e
167
+ add_noko_elem(p, "start", s.to_s)
168
+ add_noko_elem(p, "end", e.to_s)
154
169
  end
155
170
  end
156
171
 
@@ -11,21 +11,27 @@ module Metanorma
11
11
 
12
12
  def provisional_id(node, xml)
13
13
  node.attr("provisional-name") or return
14
- xml.docidentifier type: "ITU-provisional" do |i|
15
- i << node.attr("provisional-name")
16
- end
14
+ add_noko_elem(xml, "docidentifier",
15
+ node.attr("provisional-name"), type: "ITU-provisional")
16
+ # xml.docidentifier type: "ITU-provisional" do |i|
17
+ # i << node.attr("provisional-name")
18
+ # end
17
19
  end
18
20
 
19
21
  def td_id(node, xml)
20
22
  node.attr("td-number") or return
21
- xml.docidentifier type: "ITU-TemporaryDocument" do |i|
22
- i << node.attr("td-number")
23
- end
23
+ add_noko_elem(xml, "docidentifier",
24
+ node.attr("td-number"), type: "ITU-TemporaryDocument")
25
+ # xml.docidentifier type: "ITU-TemporaryDocument" do |i|
26
+ # i << node.attr("td-number")
27
+ # end
24
28
  end
25
29
 
26
30
  def iso_id(node, xml)
27
- a = node.attr("common-text-docnumber") and
28
- xml.docidentifier a, type: "ISO"
31
+ add_noko_elem(xml, "docidentifier",
32
+ node.attr("common-text-docnumber"), type: "ISO")
33
+ # a = node.attr("common-text-docnumber") and
34
+ # xml.docidentifier a, type: "ISO"
29
35
  end
30
36
 
31
37
  ITULANG = { "en" => "E", "fr" => "F", "ar" => "A", "es" => "S",
@@ -56,31 +62,42 @@ module Metanorma
56
62
 
57
63
  def itu_id(node, xml)
58
64
  node.attr("docnumber") || node.attr("docidentifier") or return
59
- xml.docidentifier type: "ITU", primary: "true" do |i|
60
- i << (node.attr("docidentifier") || itu_id1(node, false))
61
- end
62
- xml.docidentifier type: "ITU-lang" do |i|
63
- i << itu_id1(node, true)
64
- end
65
+ add_noko_elem(xml, "docidentifier",
66
+ node.attr("docidentifier") || itu_id1(node, false), type: "ITU", primary: "true")
67
+ # xml.docidentifier type: "ITU", primary: "true" do |i|
68
+ # i << (node.attr("docidentifier") || itu_id1(node, false))
69
+ # end
70
+ add_noko_elem(xml, "docidentifier",
71
+ itu_id1(node, true), type: "ITU-lang")
72
+ # xml.docidentifier type: "ITU-lang" do |i|
73
+ # i << itu_id1(node, true)
74
+ # end
65
75
  end
66
76
 
67
77
  def recommendation_id(node, xml)
68
78
  node.attr("recommendationnumber") or return
69
79
  node.attr("recommendationnumber").split("/").each do |s|
70
- xml.docidentifier type: "ITU-Recommendation" do |i|
71
- i << s
72
- end
80
+ add_noko_elem(xml, "docidentifier", s, type: "ITU-Recommendation")
81
+
82
+ # xml.docidentifier type: "ITU-Recommendation" do |i|
83
+ # i << s
84
+ # end
73
85
  end
74
86
  end
75
87
 
76
88
  def structured_id(node, xml)
77
89
  node.attr("docnumber") or return
78
90
  xml.structuredidentifier do |i|
79
- i.bureau node.attr("bureau") || "T"
80
- i.docnumber node.attr("docnumber")
81
- a = node.attr("annexid") and i.annexid a
82
- a = node.attr("amendment-number") and i.amendment a
83
- a = node.attr("corrigendum-number") and i.corrigendum a
91
+ add_noko_elem(i, "bureau", node.attr("bureau") || "T")
92
+ # i.bureau node.attr("bureau") || "T"
93
+ add_noko_elem(i, "docnumber", node.attr("docnumber"))
94
+ # i.docnumber node.attr("docnumber")
95
+ add_noko_elem(i, "annexid", node.attr("annexid"))
96
+ # a = node.attr("annexid") and i.annexid a
97
+ add_noko_elem(i, "amendment", node.attr("amendment-number"))
98
+ # a = node.attr("amendment-number") and i.amendment a
99
+ add_noko_elem(i, "corrigendum", node.attr("corrigendum-number"))
100
+ # a = node.attr("corrigendum-number") and i.corrigendum a
84
101
  end
85
102
  end
86
103
  end
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- VERSION v2.1.3 -->
3
+ <!-- VERSION v2.1.4 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -905,15 +905,32 @@ titlecase, or lowercase</a:documentation>
905
905
  </element>
906
906
  </define>
907
907
  <define name="image" combine="choice">
908
- <element name="svg">
909
- <a:documentation>Add svg mark up to image</a:documentation>
910
- <oneOrMore>
911
- <choice>
912
- <text/>
913
- <ref name="AnyElement"/>
914
- </choice>
915
- </oneOrMore>
916
- </element>
908
+ <choice>
909
+ <element name="image">
910
+ <ref name="RequiredId"/>
911
+ <ref name="ImageAttributes"/>
912
+ <optional>
913
+ <element name="svg">
914
+ <a:documentation>Allow svg in image/svg, for consistency</a:documentation>
915
+ <oneOrMore>
916
+ <choice>
917
+ <text/>
918
+ <ref name="AnyElement"/>
919
+ </choice>
920
+ </oneOrMore>
921
+ </element>
922
+ </optional>
923
+ </element>
924
+ <element name="svg">
925
+ <a:documentation>Add svg mark up to image</a:documentation>
926
+ <oneOrMore>
927
+ <choice>
928
+ <text/>
929
+ <ref name="AnyElement"/>
930
+ </choice>
931
+ </oneOrMore>
932
+ </element>
933
+ </choice>
917
934
  </define>
918
935
  <define name="ParagraphFnBody" combine="interleave">
919
936
  <ref name="BlockSource">
@@ -0,0 +1,47 @@
1
+ module Metanorma
2
+ module Itu
3
+ class Converter
4
+ ITU_LOG_MESSAGES = {
5
+ # rubocop:disable Naming/VariableNumber
6
+ "ITU_1": { category: "Document Attributes",
7
+ error: "%s is not a recognised document type",
8
+ severity: 2 },
9
+ "ITU_2": { category: "Document Attributes",
10
+ error: "%s is not a recognised status",
11
+ severity: 2 },
12
+ "ITU_3": { category: "Document Attributes",
13
+ error: "Title includes series name %s",
14
+ severity: 2 },
15
+ "ITU_4": { category: "Style",
16
+ error: "Requirement possibly in preface: %s",
17
+ severity: 2 },
18
+ "ITU_6": { category: "Document Attributes",
19
+ error: "Recommendation Status %s inconsistent with AAP",
20
+ severity: 2 },
21
+ "ITU_7": { category: "Document Attributes",
22
+ error: "Recommendation Status %s inconsistent with TAP",
23
+ severity: 2 },
24
+ "ITU_8": { category: "Style",
25
+ error: "%s does not match ITU document identifier conventions",
26
+ severity: 2 },
27
+ "ITU_9": { category: "Style",
28
+ error: "Unnumbered clause out of place",
29
+ severity: 2 },
30
+ "ITU_10": { category: "Style",
31
+ error: "No Summary has been provided",
32
+ severity: 2 },
33
+ "ITU_11": { category: "Style",
34
+ error: "No Keywords have been provided",
35
+ severity: 2 },
36
+ "ITU_12": { category: "Style",
37
+ error: "(terms) %s: %s",
38
+ severity: 2 },
39
+ }.freeze
40
+ # rubocop:enable Naming/VariableNumber
41
+
42
+ def log_messages
43
+ super.merge(ITU_LOG_MESSAGES)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -12,16 +12,14 @@ module Metanorma
12
12
  focus-group implementers-guide technical-paper technical-report
13
13
  joint-itu-iso-iec service-publication
14
14
  contribution).include? @doctype or
15
- @log.add("Document Attributes", nil,
16
- "#{@doctype} is not a recognised document type")
15
+ @log.add("ITU_1", nil, params: [@doctype])
17
16
  end
18
17
 
19
18
  def stage_validate(xmldoc)
20
19
  stage = xmldoc&.at("//bibdata/status/stage")&.text
21
20
  %w(in-force superseded in-force-prepublished withdrawn
22
21
  draft).include? stage or
23
- @log.add("Document Attributes", nil,
24
- "#{stage} is not a recognised status")
22
+ @log.add("ITU_2", nil, params: [stage])
25
23
  end
26
24
 
27
25
  def content_validate(doc)
@@ -41,8 +39,7 @@ module Metanorma
41
39
  xmldoc.xpath("//bibdata/series/title").each do |s|
42
40
  series = s.text.sub(/^[A-Z]: /, "")
43
41
  t.downcase.include?(series.downcase) and
44
- @log.add("Document Attributes", nil,
45
- "Title includes series name #{series}")
42
+ @log.add("ITU_3", nil, params: [series])
46
43
  end
47
44
  end
48
45
 
@@ -61,8 +58,7 @@ module Metanorma
61
58
  xmldoc.xpath("//preface/*").each do |c|
62
59
  extract_text(c).split(/\.\s+/).each do |t|
63
60
  /\b(shall|must)\b/i.match(t) and
64
- @log.add("Style", c,
65
- "Requirement possibly in preface: #{t.strip}")
61
+ @log.add("ITU_4", c, params: [t.strip])
66
62
  end
67
63
  end
68
64
  end
@@ -71,35 +67,33 @@ module Metanorma
71
67
  # Supplanted by rendering
72
68
  def numbers_validate(xmldoc); end
73
69
 
74
- def style_two_regex_not_prev(node, text, regex, regex_prev, warning)
75
- text.nil? and return
76
- arr = text.split(/\W+/)
77
- arr.each_index do |i|
78
- m_prev = i.zero? ? nil : regex_prev.match(arr[i - 1])
79
- if !regex.match?(arr[i]) && m_prev.nil?
80
- @log.add("Style", node, "#{warning}: #{m[:num]}")
81
- end
82
- end
83
- end
70
+ # def style_two_regex_not_prev(node, text, regex, regex_prev, warning)
71
+ # text.nil? and return
72
+ # arr = text.split(/\W+/)
73
+ # arr.each_index do |i|
74
+ # m_prev = i.zero? ? nil : regex_prev.match(arr[i - 1])
75
+ # if !regex.match?(arr[i]) && m_prev.nil?
76
+ # @log.add("Style", node, "#{warning}: #{m[:num]}")
77
+ # # ID = ITU_5
78
+ # end
79
+ # end
80
+ # end
84
81
 
85
82
  def approval_validate(xmldoc)
86
83
  s = xmldoc.at("//bibdata/ext/recommendationstatus/approvalstage") or
87
84
  return
88
85
  process = s["process"]
89
86
  (process == "aap") && %w(determined in-force).include?(s.text) and
90
- @log.add("Document Attributes", nil,
91
- "Recommendation Status #{s.text} inconsistent with AAP")
87
+ @log.add("ITU_6", nil, params: [s.text])
92
88
  (process == "tap") && !%w(determined in-force).include?(s.text) and
93
- @log.add("Document Attributes", nil,
94
- "Recommendation Status #{s.text} inconsistent with TAP")
89
+ @log.add("ITU_7", nil, params: [s.text])
95
90
  end
96
91
 
97
92
  def itu_identifier_validate(xmldoc)
98
93
  xmldoc.xpath("//bibdata/docidentifier[@type = 'ITU']").each do |x|
99
94
  /^SG \d+/.match?(x.text) ||
100
95
  /^ITU-[RTD] [AD-VX-Z]\.\d+(\.\d+)?$/.match?(x.text) or
101
- @log.add("Style", nil, "#{x.text} does not match ITU document " \
102
- "identifier conventions")
96
+ @log.add("ITU_8", nil, params: [x.text])
103
97
  end
104
98
  end
105
99
 
@@ -114,16 +108,16 @@ module Metanorma
114
108
  next if (@doctype == "resolution") && (c.parent.name == "sections") &&
115
109
  !c.at("./preceding-sibling::clause")
116
110
 
117
- @log.add("Style", c, "Unnumbered clause out of place")
111
+ @log.add("ITU_9", c)
118
112
  end
119
113
  end
120
114
 
121
115
  # Editing Guidelines 7.2, 7.3
122
116
  def section_check(xmldoc)
123
117
  xmldoc.at("//bibdata/abstract") or
124
- @log.add("Style", nil, "No Summary has been provided")
118
+ @log.add("ITU_10", nil)
125
119
  xmldoc.at("//bibdata/keyword") or
126
- @log.add("Style", nil, "No Keywords have been provided")
120
+ @log.add("ITU_11", nil)
127
121
  end
128
122
 
129
123
  def termdef_style(xmldoc)
@@ -139,7 +133,7 @@ module Metanorma
139
133
  end
140
134
 
141
135
  def termdef_warn(text, regex, node, term, msg)
142
- regex.match(text) && @log.add("Style", node, "#{term}: #{msg}")
136
+ regex.match(text) && @log.add("ITU_12", node, params: [term, msg])
143
137
  end
144
138
  end
145
139
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Itu
3
- VERSION = "2.7.7".freeze
3
+ VERSION = "2.8.1".freeze
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  template:
2
2
  # skip authoritative identifier, it is inserted in front of formattedref within metanorma
3
- standard: "<em>{{ title }}</em> ,_{{ edition | capitalize_first }} . {{ extent }}."
3
+ standard: "<em>{{ title }}</em> ,_{{ edition | capitalize_first }} $$$ {{ extent }}"
@@ -25,7 +25,7 @@ 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.1.0"
28
+ spec.add_dependency "metanorma-standoc", "~> 3.2.0"
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
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
35
35
  spec.add_development_dependency "guard", "~> 2.14"
36
36
  spec.add_development_dependency "guard-rspec", "~> 4.7"
37
+ spec.add_development_dependency "openssl"
37
38
  spec.add_development_dependency "rake", "~> 13.0"
38
39
  spec.add_development_dependency "rspec", "~> 3.6"
39
40
  spec.add_development_dependency "rubocop", "~> 1"
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.7.7
4
+ version: 2.8.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: 2025-10-13 00:00:00.000000000 Z
11
+ date: 2025-11-17 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.1.0
19
+ version: 3.2.0
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.1.0
26
+ version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pubid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: openssl
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rake
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -336,6 +350,7 @@ files:
336
350
  - lib/metanorma/itu/front_id.rb
337
351
  - lib/metanorma/itu/isodoc.rng
338
352
  - lib/metanorma/itu/itu.rng
353
+ - lib/metanorma/itu/log.rb
339
354
  - lib/metanorma/itu/processor.rb
340
355
  - lib/metanorma/itu/relaton-itu.rng
341
356
  - lib/metanorma/itu/reqt.rng