metanorma-bipm 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -169,6 +169,23 @@ module IsoDoc
169
169
  super || @xrefs.klass.standard?(bibitem)
170
170
  end
171
171
 
172
+ def expand_citeas(text)
173
+ ret = super
174
+ if @lang == "fr" && /^(CGPM|CIPM) /.match?(ret)
175
+ ret.sub!(/^(CGPM|CIPM) (\S+)/) do |_m|
176
+ "#{$1} – #{FR_OUTCOME_TYPE[$2.to_sym] || $2}"
177
+ end
178
+ end
179
+ ret
180
+ end
181
+
182
+ FR_OUTCOME_TYPE = {
183
+ Resolution: "Résolution",
184
+ Decision: "Décision",
185
+ Recommendation: "Recommandation",
186
+ Declaration: "Déclaration",
187
+ }.freeze
188
+
172
189
  include Init
173
190
  end
174
191
  end
@@ -1,5 +1,6 @@
1
1
  require "metanorma/standoc/converter"
2
2
  require "metanorma/generic/converter"
3
+ require_relative "front"
3
4
 
4
5
  module Metanorma
5
6
  module BIPM
@@ -22,114 +23,6 @@ module Metanorma
22
23
  { org_name_long => configuration.organization_name_short }
23
24
  end
24
25
 
25
- def metadata_committee(node, xml)
26
- return unless node.attr("committee-en") || node.attr("committee-fr")
27
-
28
- xml.editorialgroup do |a|
29
- metadata_committee1(node, a)
30
- i = 2
31
- while node.attr("committee-en_#{i}") || node.attr("committee-fr_#{i}")
32
- metadata_committee2(node, a, i)
33
- i += 1
34
- end
35
- metadata_workgroup(node, a)
36
- end
37
- end
38
-
39
- def metadata_committee1(node, xml)
40
- xml.committee **attr_code(acronym:
41
- node.attr("committee-acronym")) do |c|
42
- e = node.attr("committee-en") and
43
- c.variant e, language: "en", script: "Latn"
44
- e = node.attr("committee-fr") and
45
- c.variant e, language: "fr", script: "Latn"
46
- end
47
- end
48
-
49
- def metadata_committee2(node, xml, num)
50
- xml.committee **attr_code(acronym:
51
- node.attr("committee-acronym_#{num}")) do |c|
52
- %w(en fr).each do |lg|
53
- e = node.attr("committee-#{lg}_#{num}") and
54
- c.variant e, language: lg, script: "Latn"
55
- end
56
- end
57
- end
58
-
59
- def metadata_workgroup(node, xml)
60
- xml.workgroup(node.attr("workgroup"),
61
- **attr_code(acronym: node.attr("workgroup-acronym")))
62
- i = 2
63
- while node.attr("workgroup_#{i}")
64
- xml.workgroup(
65
- node.attr("workgroup_#{i}"),
66
- **attr_code(acronym: node.attr("workgroup-acronym_#{i}"))
67
- )
68
- i += 1
69
- end
70
- end
71
-
72
- def metadata_relations(node, xml)
73
- super
74
- relation_supersedes_self(node, xml, "")
75
- i = 2
76
- while relation_supersedes_self(node, xml, "_#{i}")
77
- i += 1
78
- end
79
- end
80
-
81
- def relation_supersedes_self(node, xml, suffix)
82
- d = node.attr("supersedes-date#{suffix}")
83
- draft = node.attr("supersedes-draft#{suffix}")
84
- edition = node.attr("supersedes-edition#{suffix}")
85
- return false unless d || draft || edition
86
-
87
- relation_supersedes_self1(xml, d, edition, draft)
88
- end
89
-
90
- def relation_supersedes_self1(xml, date, edition, draft)
91
- xml.relation **{ type: "supersedes" } do |r|
92
- r.bibitem do |b|
93
- date and b.date(date,
94
- **{ type: edition ? "published" : "circulated" })
95
- edition and b.edition edition
96
- draft and b.version do |v|
97
- v.draft draft
98
- end
99
- end
100
- end
101
- end
102
-
103
- def personal_role(node, xml, suffix)
104
- role = node.attr("role#{suffix}") || "author"
105
- unless %w(author editor).include?(role.downcase)
106
- desc = role
107
- role = "editor"
108
- end
109
- xml.role desc, **{ type: role.downcase }
110
- end
111
-
112
- def title(node, xml)
113
- ["en", "fr"].each do |lang|
114
- at = { language: lang, format: "text/plain" }
115
- xml.title **attr_code(at.merge(type: "main")) do |t1|
116
- t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-#{lang}"))
117
- end
118
- %w(cover appendix annex part subpart provenance).each do |w|
119
- typed_title(node, xml, lang, w)
120
- end
121
- end
122
- end
123
-
124
- def typed_title(node, xml, lang, type)
125
- at = { language: lang, format: "text/plain" }
126
- return unless title = node.attr("title-#{type}-#{lang}")
127
-
128
- xml.title **attr_code(at.merge(type: type)) do |t1|
129
- t1 << Metanorma::Utils::asciidoc_sub(title)
130
- end
131
- end
132
-
133
26
  def sectiontype_streamline(ret)
134
27
  case ret
135
28
  when "introduction" then @jcgm ? "introduction" : "clause"
@@ -157,6 +50,43 @@ module Metanorma
157
50
  ret
158
51
  end
159
52
 
53
+ def reference_names(xmldoc)
54
+ xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
55
+ docid = ref.at("./docidentifier[@type = 'metanorma']") ||
56
+ ref.at("./docidentifier[not(@type = 'DOI')]") or next
57
+ date = ref.at("./date[@type = 'published']")
58
+ reference = format_ref(reference_names1(docid, date, docid["type"]),
59
+ docid["type"])
60
+ @anchors[ref["id"]] = { xref: reference }
61
+ end
62
+ end
63
+
64
+ def reference_names1(docid, date, type)
65
+ ret = docid.children.to_xml
66
+ if type == "BIPM" && date &&
67
+ /(CIPM|CGPM) (Decision|Resolution)/.match?(docid)
68
+ ret += " (#{date_range(date)})"
69
+ end
70
+ ret
71
+ end
72
+
73
+ def date_range(date)
74
+ from = date.at(("./from"))
75
+ to = date.at(("./to"))
76
+ on = date.at(("./on"))
77
+ return date.text unless from || on || to
78
+ return on.text.sub(/-.*$/, "") if on
79
+
80
+ ret = "#{from.text.sub(/-.*$/, '')}&#x2013;"
81
+ ret += to.text.sub(/-.*$/, "") if to
82
+ ret
83
+ end
84
+
85
+ def format_ref(ref, type)
86
+ ref = ref.sub(/^BIPM /, "") if type == "BIPM"
87
+ super
88
+ end
89
+
160
90
  def clause_parse(attrs, xml, node)
161
91
  node.option?("unnumbered") and attrs[:unnumbered] = true
162
92
  super
@@ -0,0 +1,113 @@
1
+ module Metanorma
2
+ module BIPM
3
+ class Converter < Metanorma::Generic::Converter
4
+ def metadata_committee(node, xml)
5
+ return unless node.attr("committee-en") || node.attr("committee-fr")
6
+
7
+ xml.editorialgroup do |a|
8
+ metadata_committee1(node, a)
9
+ i = 2
10
+ while node.attr("committee-en_#{i}") || node.attr("committee-fr_#{i}")
11
+ metadata_committee2(node, a, i)
12
+ i += 1
13
+ end
14
+ metadata_workgroup(node, a)
15
+ end
16
+ end
17
+
18
+ def metadata_committee1(node, xml)
19
+ xml.committee **attr_code(acronym:
20
+ node.attr("committee-acronym")) do |c|
21
+ e = node.attr("committee-en") and
22
+ c.variant e, language: "en", script: "Latn"
23
+ e = node.attr("committee-fr") and
24
+ c.variant e, language: "fr", script: "Latn"
25
+ end
26
+ end
27
+
28
+ def metadata_committee2(node, xml, num)
29
+ xml.committee **attr_code(acronym:
30
+ node.attr("committee-acronym_#{num}")) do |c|
31
+ %w(en fr).each do |lg|
32
+ e = node.attr("committee-#{lg}_#{num}") and
33
+ c.variant e, language: lg, script: "Latn"
34
+ end
35
+ end
36
+ end
37
+
38
+ def metadata_workgroup(node, xml)
39
+ xml.workgroup(node.attr("workgroup"),
40
+ **attr_code(acronym: node.attr("workgroup-acronym")))
41
+ i = 2
42
+ while node.attr("workgroup_#{i}")
43
+ xml.workgroup(
44
+ node.attr("workgroup_#{i}"),
45
+ **attr_code(acronym: node.attr("workgroup-acronym_#{i}")),
46
+ )
47
+ i += 1
48
+ end
49
+ end
50
+
51
+ def metadata_relations(node, xml)
52
+ super
53
+ relation_supersedes_self(node, xml, "")
54
+ i = 2
55
+ while relation_supersedes_self(node, xml, "_#{i}")
56
+ i += 1
57
+ end
58
+ end
59
+
60
+ def relation_supersedes_self(node, xml, suffix)
61
+ d = node.attr("supersedes-date#{suffix}")
62
+ draft = node.attr("supersedes-draft#{suffix}")
63
+ edition = node.attr("supersedes-edition#{suffix}")
64
+ return false unless d || draft || edition
65
+
66
+ relation_supersedes_self1(xml, d, edition, draft)
67
+ end
68
+
69
+ def relation_supersedes_self1(xml, date, edition, draft)
70
+ xml.relation **{ type: "supersedes" } do |r|
71
+ r.bibitem do |b|
72
+ date and b.date(date,
73
+ **{ type: edition ? "published" : "circulated" })
74
+ edition and b.edition edition
75
+ draft and b.version do |v|
76
+ v.draft draft
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ def personal_role(node, xml, suffix)
83
+ role = node.attr("role#{suffix}") || "author"
84
+ unless %w(author editor).include?(role.downcase)
85
+ desc = role
86
+ role = "editor"
87
+ end
88
+ xml.role desc, **{ type: role.downcase }
89
+ end
90
+
91
+ def title(node, xml)
92
+ ["en", "fr"].each do |lang|
93
+ at = { language: lang, format: "text/plain" }
94
+ xml.title **attr_code(at.merge(type: "main")) do |t1|
95
+ t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-#{lang}"))
96
+ end
97
+ %w(cover appendix annex part subpart provenance).each do |w|
98
+ typed_title(node, xml, lang, w)
99
+ end
100
+ end
101
+ end
102
+
103
+ def typed_title(node, xml, lang, type)
104
+ at = { language: lang, format: "text/plain" }
105
+ return unless title = node.attr("title-#{type}-#{lang}")
106
+
107
+ xml.title **attr_code(at.merge(type: type)) do |t1|
108
+ t1 << Metanorma::Utils::asciidoc_sub(title)
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "2.1.0".freeze
3
+ VERSION = "2.1.1".freeze
4
4
  end
5
5
  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: 2.1.0
4
+ version: 2.1.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: 2022-05-09 00:00:00.000000000 Z
11
+ date: 2022-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -274,6 +274,7 @@ files:
274
274
  - lib/metanorma/bipm/boilerplate-fr.xml
275
275
  - lib/metanorma/bipm/boilerplate-jcgm-en.xml
276
276
  - lib/metanorma/bipm/converter.rb
277
+ - lib/metanorma/bipm/front.rb
277
278
  - lib/metanorma/bipm/isodoc.rng
278
279
  - lib/metanorma/bipm/processor.rb
279
280
  - lib/metanorma/bipm/reqt.rng