relaton-bipm 1.5.pre → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac88df1719bfb7a141e85e07091855edecbaf43fe7fd8848acd2d57c05a3a675
4
- data.tar.gz: e5fc490ae0bc617473e97162c1da7d53b7b01b982711876a83077b28534a6441
3
+ metadata.gz: 6155907dfcf708b034a914e45245ab8fd8262de9c83d29fb6436fcd8130c5ad3
4
+ data.tar.gz: 251bf3228d0717ca3fcc4a181b50d2ae62f5e1df7fe6a7b3284404463ab389e4
5
5
  SHA512:
6
- metadata.gz: 1504e54965973446382011107e0d740f2050618dc14f40853f83c404223aba76770160b35d15219ee72a7851cabd1abe0139814c3213e11fa10cc6c29b08aba1
7
- data.tar.gz: 2071fef5c298d883941ecbd06a4d4163066b4bd3fec08209fe75ff4b136d2dffde82bb3e45cba25cd2724ecd10a07d845becf9639600db7b590c9a78dce1807e
6
+ metadata.gz: cbc54d6dfc3c066aada2bcd84cdde54a9218b02de719149fd8d556e281d3e232fe74a1094bb349b91a6bef748afe0c0398aeebbe3c96e27b8c55526efc1ed349
7
+ data.tar.gz: dfd7cf7dc70e74c3f4ec56b3f32e6c9816e3c49a2c94d26c4fbf0048f06bb21df15fea401e4c33a0e5927cdb2486888ecb312d670b04105dabb194620b3d62eb
@@ -26,6 +26,8 @@ jobs:
26
26
  - name: Update gems
27
27
  run: |
28
28
  sudo gem install bundler --force
29
+ ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
30
+ ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
29
31
  bundle install --jobs 4 --retry 3
30
32
  - name: Run specs
31
33
  run: |
@@ -0,0 +1,353 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <!--
4
+ Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
5
+ we cannot have a new default namespace: we will end up with a grammar with two different
6
+ namespaces, one for isostandard and one for csand additions. And we do not want that.
7
+ -->
8
+ <include href="isodoc.rng">
9
+ <start>
10
+ <ref name="bipm-standard"/>
11
+ </start>
12
+ <define name="xref">
13
+ <element name="xref">
14
+ <attribute name="target">
15
+ <data type="string">
16
+ <param name="pattern">\i\c*|\c+#\c+</param>
17
+ </data>
18
+ </attribute>
19
+ <optional>
20
+ <attribute name="type">
21
+ <ref name="ReferenceFormat"/>
22
+ </attribute>
23
+ </optional>
24
+ <optional>
25
+ <attribute name="alt"/>
26
+ </optional>
27
+ <optional>
28
+ <attribute name="case">
29
+ <choice>
30
+ <value>capital</value>
31
+ <value>lowercase</value>
32
+ </choice>
33
+ </attribute>
34
+ </optional>
35
+ <optional>
36
+ <attribute name="droploc">
37
+ <data type="boolean"/>
38
+ </attribute>
39
+ </optional>
40
+ <optional>
41
+ <attribute name="pagenumber">
42
+ <data type="boolean"/>
43
+ </attribute>
44
+ </optional>
45
+ <optional>
46
+ <attribute name="nosee">
47
+ <data type="boolean"/>
48
+ </attribute>
49
+ </optional>
50
+ <text/>
51
+ </element>
52
+ </define>
53
+ <define name="Clause-Section">
54
+ <optional>
55
+ <attribute name="id">
56
+ <data type="ID"/>
57
+ </attribute>
58
+ </optional>
59
+ <optional>
60
+ <attribute name="language"/>
61
+ </optional>
62
+ <optional>
63
+ <attribute name="script"/>
64
+ </optional>
65
+ <optional>
66
+ <attribute name="inline-header">
67
+ <data type="boolean"/>
68
+ </attribute>
69
+ </optional>
70
+ <optional>
71
+ <attribute name="obligation">
72
+ <choice>
73
+ <value>normative</value>
74
+ <value>informative</value>
75
+ </choice>
76
+ </attribute>
77
+ </optional>
78
+ <optional>
79
+ <attribute name="type"/>
80
+ </optional>
81
+ <optional>
82
+ <attribute name="unnumbered">
83
+ <data type="boolean"/>
84
+ </attribute>
85
+ </optional>
86
+ <optional>
87
+ <ref name="section-title"/>
88
+ </optional>
89
+ <group>
90
+ <choice>
91
+ <group>
92
+ <zeroOrMore>
93
+ <ref name="BasicBlock"/>
94
+ </zeroOrMore>
95
+ <zeroOrMore>
96
+ <ref name="note"/>
97
+ </zeroOrMore>
98
+ </group>
99
+ <ref name="amend"/>
100
+ </choice>
101
+ <zeroOrMore>
102
+ <choice>
103
+ <ref name="clause-subsection"/>
104
+ <ref name="terms"/>
105
+ <ref name="definitions"/>
106
+ </choice>
107
+ </zeroOrMore>
108
+ </group>
109
+ </define>
110
+ <define name="Annex-Section">
111
+ <optional>
112
+ <attribute name="id">
113
+ <data type="ID"/>
114
+ </attribute>
115
+ </optional>
116
+ <optional>
117
+ <attribute name="language"/>
118
+ </optional>
119
+ <optional>
120
+ <attribute name="script"/>
121
+ </optional>
122
+ <optional>
123
+ <attribute name="inline-header">
124
+ <data type="boolean"/>
125
+ </attribute>
126
+ </optional>
127
+ <optional>
128
+ <attribute name="obligation">
129
+ <choice>
130
+ <value>normative</value>
131
+ <value>informative</value>
132
+ </choice>
133
+ </attribute>
134
+ </optional>
135
+ <optional>
136
+ <attribute name="unnumbered">
137
+ <data type="boolean"/>
138
+ </attribute>
139
+ </optional>
140
+ <optional>
141
+ <ref name="section-title"/>
142
+ </optional>
143
+ <group>
144
+ <group>
145
+ <zeroOrMore>
146
+ <ref name="BasicBlock"/>
147
+ </zeroOrMore>
148
+ <zeroOrMore>
149
+ <ref name="note"/>
150
+ </zeroOrMore>
151
+ </group>
152
+ <zeroOrMore>
153
+ <choice>
154
+ <ref name="annex-subsection"/>
155
+ <ref name="terms"/>
156
+ <ref name="definitions"/>
157
+ <ref name="references"/>
158
+ </choice>
159
+ </zeroOrMore>
160
+ </group>
161
+ </define>
162
+ <define name="ol">
163
+ <element name="ol">
164
+ <attribute name="id">
165
+ <data type="ID"/>
166
+ </attribute>
167
+ <optional>
168
+ <attribute name="keep-with-next">
169
+ <data type="boolean"/>
170
+ </attribute>
171
+ </optional>
172
+ <optional>
173
+ <attribute name="keep-lines-together">
174
+ <data type="boolean"/>
175
+ </attribute>
176
+ </optional>
177
+ <attribute name="type">
178
+ <choice>
179
+ <value>roman</value>
180
+ <value>alphabet</value>
181
+ <value>arabic</value>
182
+ <value>roman_upper</value>
183
+ <value>alphabet_upper</value>
184
+ </choice>
185
+ </attribute>
186
+ <optional>
187
+ <attribute name="start"/>
188
+ </optional>
189
+ <oneOrMore>
190
+ <ref name="li"/>
191
+ </oneOrMore>
192
+ <zeroOrMore>
193
+ <ref name="note"/>
194
+ </zeroOrMore>
195
+ </element>
196
+ </define>
197
+ <define name="DocumentType">
198
+ <choice>
199
+ <value>brochure</value>
200
+ <value>mise-en-pratique</value>
201
+ <value>rapport</value>
202
+ <value>monographie</value>
203
+ <value>guide</value>
204
+ <value>meeting-report</value>
205
+ <value>technical-report</value>
206
+ <value>working-party-note</value>
207
+ <value>strategy</value>
208
+ <value>cipm-mra</value>
209
+ <value>resolution</value>
210
+ </choice>
211
+ </define>
212
+ <define name="editorialgroup">
213
+ <element name="editorialgroup">
214
+ <oneOrMore>
215
+ <ref name="committee"/>
216
+ </oneOrMore>
217
+ <zeroOrMore>
218
+ <ref name="workgroup"/>
219
+ </zeroOrMore>
220
+ </element>
221
+ </define>
222
+ <define name="structuredidentifier">
223
+ <element name="structuredidentifier">
224
+ <element name="docnumber">
225
+ <text/>
226
+ </element>
227
+ <optional>
228
+ <element name="part">
229
+ <text/>
230
+ </element>
231
+ </optional>
232
+ <optional>
233
+ <element name="appendix">
234
+ <text/>
235
+ </element>
236
+ </optional>
237
+ </element>
238
+ </define>
239
+ <define name="BibDataExtensionType">
240
+ <optional>
241
+ <ref name="doctype"/>
242
+ </optional>
243
+ <ref name="editorialgroup"/>
244
+ <optional>
245
+ <ref name="comment-period"/>
246
+ </optional>
247
+ <optional>
248
+ <ref name="si-aspect"/>
249
+ </optional>
250
+ <optional>
251
+ <ref name="meeting-note"/>
252
+ </optional>
253
+ <ref name="structuredidentifier"/>
254
+ </define>
255
+ </include>
256
+ <define name="comment-period">
257
+ <element name="comment-period">
258
+ <element name="from">
259
+ <ref name="ISO8601Date"/>
260
+ </element>
261
+ <element name="to">
262
+ <ref name="ISO8601Date"/>
263
+ </element>
264
+ </element>
265
+ </define>
266
+ <define name="si-aspect">
267
+ <element name="si-aspect">
268
+ <choice>
269
+ <value>A_e_deltanu</value>
270
+ <value>A_e</value>
271
+ <value>cd_Kcd_h_deltanu</value>
272
+ <value>cd_Kcd</value>
273
+ <value>full</value>
274
+ <value>K_k_deltanu</value>
275
+ <value>K_k</value>
276
+ <value>kg_h_c_deltanu</value>
277
+ <value>kg_h</value>
278
+ <value>m_c_deltanu</value>
279
+ <value>m_c</value>
280
+ <value>mol_NA</value>
281
+ <value>s_deltanu</value>
282
+ </choice>
283
+ </element>
284
+ </define>
285
+ <define name="committee">
286
+ <element name="committee">
287
+ <attribute name="acronym">
288
+ <choice>
289
+ <value>CGPM</value>
290
+ <value>CIPM</value>
291
+ <value>BIPM</value>
292
+ <value>CCAUV</value>
293
+ <value>CCEM</value>
294
+ <value>CCL</value>
295
+ <value>CCM</value>
296
+ <value>CCPR</value>
297
+ <value>CCQM</value>
298
+ <value>CCRI</value>
299
+ <value>CCT</value>
300
+ <value>CCTF</value>
301
+ <value>CCU</value>
302
+ <value>CCL-CCTF</value>
303
+ <value>JCGM</value>
304
+ <value>JCRB</value>
305
+ <value>JCTLM</value>
306
+ <value>INetQI</value>
307
+ </choice>
308
+ </attribute>
309
+ <ref name="LocalizedString"/>
310
+ </element>
311
+ </define>
312
+ <define name="workgroup">
313
+ <element name="workgroup">
314
+ <optional>
315
+ <attribute name="acronym"/>
316
+ </optional>
317
+ <text/>
318
+ </element>
319
+ </define>
320
+ <define name="meeting-note">
321
+ <element name="meeting-note">
322
+ <text/>
323
+ </element>
324
+ </define>
325
+ <define name="bipm-standard">
326
+ <element name="bipm-standard">
327
+ <attribute name="version"/>
328
+ <attribute name="type">
329
+ <choice>
330
+ <value>semantic</value>
331
+ <value>presentation</value>
332
+ </choice>
333
+ </attribute>
334
+ <ref name="bibdata"/>
335
+ <zeroOrMore>
336
+ <ref name="termdocsource"/>
337
+ </zeroOrMore>
338
+ <optional>
339
+ <ref name="boilerplate"/>
340
+ </optional>
341
+ <ref name="preface"/>
342
+ <oneOrMore>
343
+ <ref name="sections"/>
344
+ </oneOrMore>
345
+ <zeroOrMore>
346
+ <ref name="annex"/>
347
+ </zeroOrMore>
348
+ <optional>
349
+ <ref name="bibliography"/>
350
+ </optional>
351
+ </element>
352
+ </define>
353
+ </grammar>
@@ -24,6 +24,14 @@
24
24
  <start>
25
25
  <ref name="standard-document"/>
26
26
  </start>
27
+ <define name="doctype">
28
+ <element name="doctype">
29
+ <optional>
30
+ <attribute name="abbreviation"/>
31
+ </optional>
32
+ <ref name="DocumentType"/>
33
+ </element>
34
+ </define>
27
35
  <define name="hyperlink">
28
36
  <element name="link">
29
37
  <attribute name="target">
@@ -42,7 +50,6 @@
42
50
  </define>
43
51
  <define name="xref">
44
52
  <element name="xref">
45
- <!-- attribute target { xsd:IDREF }, -->
46
53
  <attribute name="target">
47
54
  <data type="string">
48
55
  <param name="pattern">\i\c*|\c+#\c+</param>
@@ -142,6 +149,11 @@
142
149
  <data type="boolean"/>
143
150
  </attribute>
144
151
  </optional>
152
+ <optional>
153
+ <attribute name="key">
154
+ <data type="boolean"/>
155
+ </attribute>
156
+ </optional>
145
157
  <oneOrMore>
146
158
  <ref name="dt"/>
147
159
  <ref name="dd"/>
@@ -864,6 +876,13 @@
864
876
  </define>
865
877
  <define name="standard-document">
866
878
  <element name="standard-document">
879
+ <attribute name="version"/>
880
+ <attribute name="type">
881
+ <choice>
882
+ <value>semantic</value>
883
+ <value>presentation</value>
884
+ </choice>
885
+ </attribute>
867
886
  <ref name="bibdata"/>
868
887
  <optional>
869
888
  <ref name="boilerplate"/>
@@ -1158,49 +1177,7 @@
1158
1177
  </define>
1159
1178
  <define name="annex">
1160
1179
  <element name="annex">
1161
- <optional>
1162
- <attribute name="id">
1163
- <data type="ID"/>
1164
- </attribute>
1165
- </optional>
1166
- <optional>
1167
- <attribute name="language"/>
1168
- </optional>
1169
- <optional>
1170
- <attribute name="script"/>
1171
- </optional>
1172
- <optional>
1173
- <attribute name="inline-header">
1174
- <data type="boolean"/>
1175
- </attribute>
1176
- </optional>
1177
- <attribute name="obligation">
1178
- <choice>
1179
- <value>normative</value>
1180
- <value>informative</value>
1181
- </choice>
1182
- </attribute>
1183
- <optional>
1184
- <ref name="section-title"/>
1185
- </optional>
1186
- <group>
1187
- <group>
1188
- <zeroOrMore>
1189
- <ref name="BasicBlock"/>
1190
- </zeroOrMore>
1191
- <zeroOrMore>
1192
- <ref name="note"/>
1193
- </zeroOrMore>
1194
- </group>
1195
- <zeroOrMore>
1196
- <choice>
1197
- <ref name="annex-subsection"/>
1198
- <ref name="terms"/>
1199
- <ref name="definitions"/>
1200
- <ref name="references"/>
1201
- </choice>
1202
- </zeroOrMore>
1203
- </group>
1180
+ <ref name="Annex-Section"/>
1204
1181
  </element>
1205
1182
  </define>
1206
1183
  <define name="terms">
@@ -1,10 +1,12 @@
1
1
  require "relaton_bib"
2
2
  require "relaton_bipm/version"
3
- require "relaton_bipm/project_team"
3
+ require "relaton_bipm/editorial_group"
4
+ require "relaton_bipm/committee"
5
+ require "relaton_bipm/workgroup"
6
+ require "relaton_bipm/structured_identifier"
4
7
  require "relaton_bipm/bibliographic_date"
5
8
  require "relaton_bipm/document_relation"
6
9
  require "relaton_bipm/comment_periond"
7
- require "relaton_bipm/document_status"
8
10
  require "relaton_bipm/bipm_bibliographic_item"
9
11
  require "relaton_bipm/bipm_bibliography"
10
12
  require "relaton_bipm/hash_converter"
@@ -0,0 +1,57 @@
1
+ CCAUV:
2
+ fr: Comité consultatif de l’acoustique, des ultrasons et des vibrations
3
+ en: Consultative Committee for Acoustics, Ultrasound and Vibration
4
+ CCDS:
5
+ fr: Comité consultatif pour la définition de la seconde
6
+ en: Consultative Committee for the Definition of the Second
7
+ note: see CCTF
8
+ CCE:
9
+ fr: Comité consultatif d’électricité
10
+ en: Consultative Committee for Electricity
11
+ note: see CCEM
12
+ CCEM:
13
+ fr: Comité consultatif d’électricité et magnétisme
14
+ en: Consultative Committee for Electricity and Magnetism
15
+ note: formerly the CCE
16
+ CCL:
17
+ fr: Comité consultatif des longueurs
18
+ en: Consultative Committee for Length
19
+ CCM:
20
+ fr: Comité consultatif pour la masse et les grandeurs apparentées
21
+ en: Consultative Committee for Mass and Related Quantities
22
+ CCPR:
23
+ fr: Comité consultatif de photométrie et radiométrie
24
+ en: Consultative Committee for Photometry and Radiometry
25
+ CCQM:
26
+ fr: 'Comité consultatif pour la quantité de matière : métrologie en chimie et biologie'
27
+ en: 'Consultative Committee for Amount of Substance: Metrology in Chemistry and Biology'
28
+ CCRI:
29
+ fr: Comité consultatif des rayonnements ionisants
30
+ en: Consultative Committee for Ionizing Radiation
31
+ CCT:
32
+ fr: Comité consultatif de thermométrie
33
+ en: Consultative Committee for Thermometry
34
+ CCTF:
35
+ fr: Comité consultatif du temps et des fréquences
36
+ en: Consultative Committee for Time and Frequency
37
+ note: formerly the CCDS
38
+ CCU:
39
+ fr: Comité consultatif des unités
40
+ en: Consultative Committee for Units
41
+ CGPM:
42
+ fr: Conférence générale des poids et mesures
43
+ en: General Conference on Weights and Measures
44
+ CIPM:
45
+ fr: Comité international des poids et mesures
46
+ en: International Committee for Weights and Measures
47
+ BIPM:
48
+ en: Joint Committees of the BIPM and other international organizations
49
+ CCL-CCTF:
50
+ JCGM:
51
+ en: Joint Committee for Guides in Metrology
52
+ JCRB:
53
+ en: Joint Committee of the Regional Metrology Organizations and the BIPM
54
+ JCTLM:
55
+ en: Joint Committee for Traceability in Laboratory Medicine
56
+ INetQI:
57
+ en: International Network on Quality Infrastructure
@@ -8,26 +8,37 @@ module RelatonBipm
8
8
 
9
9
  STATUSES = %w[draft-proposal draft-development in-force retired].freeze
10
10
 
11
- # @return [Array<RelatonBipm::BipmProjectTeam>]
12
- attr_reader :project_group
11
+ SI_ASPECTS = %w[
12
+ A_e_deltanu A_e cd_Kcd_h_deltanu cd_Kcd full K_k_deltanu K_k
13
+ kg_h_c_deltanu kg_h m_c_deltanu m_c mol_NA s_deltanu
14
+ ].freeze
13
15
 
14
- # @return [RelatonIho::CommentPeriod, NilClass]
15
- attr_reader :commentperiod
16
+ # @return [RelatonBipm::CommentPeriod, nil]
17
+ attr_reader :comment_period
18
+
19
+ # @return [String, nil]
20
+ attr_reader :si_aspect, :meeting_note
16
21
 
17
- # @param project_group [Array<RelatonBipm::ProjectTeam>]
18
- # @param title [Array<RelatonBib::FormattedString>]
19
- # @param date [Array<RelatonBipm::BibliographicDate>]
20
22
  # @param relation [Array<RelatonBipm::DocumentRelation>]
21
- # @param docstatus [RelatonBipm::DocumentStatus, nil]
22
- # @param commentperiod [RelatonBipm::CommentPeriod, NilClass]
23
- def initialize(**args)
24
- if args[:docstatus] && !STATUSES.include?(args[:docstatus].status)
25
- warn "[relaton-bipm] Warning: invalid docstatus #{args[:docstatus]}. "\
23
+ # @param editorialgroup [RelatonBipm::EditorialGroup]
24
+ # @param comment_period [RelatonBipm::CommentPeriod, nil]
25
+ # @param si_aspect [String, nil]
26
+ # @param meeting_note [String, nil]
27
+ # @param structuredidentifier [RelatonBipm::StructuredIdentifier]
28
+ def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
29
+ if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage.value)
30
+ warn "[relaton-bipm] Warning: invalid docstatus: #{args[:docstatus]}. "\
26
31
  "It should be one of: #{STATUSES}"
27
32
  end
28
- @project_group = args.delete(:project_group) || []
29
- # @status = args.delete :docstatus
30
- @commentperiod = args.delete :commentperiod
33
+
34
+ if args[:si_aspect] && !SI_ASPECTS.include?(args[:si_aspect])
35
+ warn "[relaton-bipm] Warning: invalid si_aspect: #{args[:si_aspect]}. "\
36
+ "It should be one of: #{SI_ASPECTS}"
37
+ end
38
+
39
+ @comment_period = args.delete :comment_period
40
+ @si_aspect = args.delete :si_aspect
41
+ @meeting_note = args[:meeting_note]
31
42
  super
32
43
  end
33
44
 
@@ -37,15 +48,17 @@ module RelatonBipm
37
48
  # @option opts [String] :lang language
38
49
  # @return [String] XML
39
50
  def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
40
- super ext: !commentperiod.nil?, **opts do |b|
51
+ super ext: !comment_period.nil?, **opts do |b|
41
52
  if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
42
- ics.any? || commentperiod)
53
+ si_aspect || comment_period ||
54
+ structuredidentifier)
43
55
  b.ext do
44
56
  b.doctype doctype if doctype
45
57
  editorialgroup&.to_xml b
46
- ics.each { |i| i.to_xml b }
47
- project_group.each { |pg| pg.to_xml b }
48
- commentperiod&.to_xml b
58
+ comment_period&.to_xml b
59
+ b.send "si-aspect", si_aspect if si_aspect
60
+ b.send "meeting-note", meeting_note if meeting_note
61
+ structuredidentifier&.to_xml b
49
62
  end
50
63
  end
51
64
  end
@@ -54,17 +67,20 @@ module RelatonBipm
54
67
  # @return [Hash]
55
68
  def to_hash
56
69
  hash = super
57
- hash["project_group"] = single_element_array project_group
58
- hash["commentperiod"] = commentperiod.to_hash if commentperiod
70
+ hash["comment_period"] = comment_period.to_hash if comment_period
71
+ hash["si_aspect"] = si_aspect if si_aspect
72
+ hash["meeting-note"] = meeting_note if meeting_note
59
73
  hash
60
74
  end
61
75
 
62
76
  # @param prefix [String]
63
77
  # @return [String]
64
78
  def to_asciibib(prefix = "")
79
+ pref = prefix.empty? ? prefix : prefix + "."
65
80
  out = super
66
- project_group.each { |p| out += p.to_asciibib prefix, project_group.size }
67
- out += commentperiod.to_asciibib prefix if commentperiod
81
+ out += comment_period.to_asciibib prefix if comment_period
82
+ out += "#{pref}si_aspect:: #{si_aspect}\n" if si_aspect
83
+ out += "#{pref}meeting_note:: #{meeting_note}\h" if meeting_note
68
84
  out
69
85
  end
70
86
  end
@@ -10,7 +10,7 @@ module RelatonBipm
10
10
  # @return [RelatonBipm::BipmBibliographicItem]
11
11
  def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
12
12
  warn "[relaton-bipm] (\"#{text}\") fetching..."
13
- ref = text.sub(/^BIPM\s/, "").downcase # .sub /^([[:alpha:]]+)(\d+)/, '\1-\2'
13
+ ref = text.sub(/^BIPM\s/, "").downcase.split(" ").join "-"
14
14
  uri = URI("#{ENDPOINT}#{ref}.yaml")
15
15
  resp = Net::HTTP.get_response uri
16
16
  return unless resp.code == "200"
@@ -15,7 +15,7 @@ module RelatonBipm
15
15
 
16
16
  # @param builder [Nokogiri::XML::builder]
17
17
  def to_xml(builder)
18
- builder.commentperiod do
18
+ builder.send "comment-period" do
19
19
  builder.from from.to_s
20
20
  builder.to to.to_s if to
21
21
  end
@@ -0,0 +1,60 @@
1
+ module RelatonBipm
2
+ class Committee
3
+ # @return [String]
4
+ attr_reader :acronym
5
+
6
+ # @return [RelatonBib::LocalizedString]
7
+ attr_reader :content
8
+
9
+ # @param acronym [String]
10
+ # @param content [RelatonBib::LocalisedString, String, nil]
11
+ def initialize(acronym:, content: nil)
12
+ acronyms = YAML.load_file File.join(__dir__, "acronyms.yaml")
13
+ unless acronyms[acronym]
14
+ warn "[relaton-bipm] WARNING: invalid acronym: #{acronym}. Allowed "\
15
+ "values: #{acronyms.map { |k, _v| k }.join ', '}"
16
+ end
17
+
18
+ @acronym = acronym
19
+ @content = localized_content content, acronyms[acronym]
20
+ end
21
+
22
+ # @param builder [Nokogiri::XML::Builder]
23
+ def to_xml(builder)
24
+ builder.committee(acronym: acronym) { |b| content.to_xml b }
25
+ end
26
+
27
+ # @param prefix [String]
28
+ # @param count [Integer]
29
+ # @return [String]
30
+ def to_asciibib(prefix, count = 1)
31
+ pref = prefix.empty? ? prefix : prefix + "."
32
+ pref += "committee"
33
+ out = count > 1 ? "#{pref}::\n" : ""
34
+ out += "#{pref}.acronym:: #{acronym}\n"
35
+ out + content.to_asciibib(pref)
36
+ end
37
+
38
+ # @return [Hash]
39
+ def to_hash
40
+ hash = { "acronym" => acronym }
41
+ cnt = content.to_hash
42
+ if cnt.is_a? Array then hash["variants"] = cnt
43
+ elsif cnt.is_a? Hash then hash.merge! cnt
44
+ else hash["content"] = cnt
45
+ end
46
+ hash
47
+ end
48
+
49
+ private
50
+
51
+ def localized_content(cnt, acr)
52
+ if cnt.is_a? String
53
+ RelatonBib::LocalizedString.new cnt
54
+ elsif (cnt.nil? || cnt.empty?) && acr && acr["en"]
55
+ RelatonBib::LocalizedString.new(acr["en"], "en", "Latn")
56
+ else cnt
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,47 @@
1
+ module RelatonBipm
2
+ class EditorialGroup
3
+ include RelatonBib
4
+
5
+ # @return [Array<String>]
6
+ attr_reader :committee, :workgroup
7
+
8
+ # @param committee [Array<RelatonBipm::Committee>]
9
+ # @param workgroup [Array<RelatonBipm::WorkGroup>]
10
+ def initialize(committee:, workgroup: [])
11
+ @committee = committee
12
+ @workgroup = workgroup
13
+ end
14
+
15
+ # @param builder [Nokogiri::XML::Builder]
16
+ def to_xml(builder)
17
+ builder.editorialgroup do |b|
18
+ committee.each { |c| c.to_xml b }
19
+ workgroup.each { |c| c.to_xml b }
20
+ end
21
+ end
22
+
23
+ # @param prefix [String]
24
+ # @return [String]
25
+ def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize
26
+ pref = prefix.empty? ? prefix : prefix + "."
27
+ pref += "editorialgroup"
28
+ out = ""
29
+ committee.each { |c| out += c.to_asciibib pref, committee.size }
30
+ workgroup.each { |w| out += w.to_asciibib pref, workgroup.size }
31
+ out
32
+ end
33
+
34
+ # @return [Hash]
35
+ def to_hash
36
+ {
37
+ "committee" => single_element_array(committee),
38
+ "workgroup" => single_element_array(workgroup),
39
+ }
40
+ end
41
+
42
+ # @return [true]
43
+ def presence?
44
+ true
45
+ end
46
+ end
47
+ end
@@ -2,6 +2,8 @@ require "yaml"
2
2
 
3
3
  module RelatonBipm
4
4
  class HashConverter < RelatonBib::HashConverter
5
+ @@acronyms = nil
6
+
5
7
  class << self
6
8
  # @override RelatonIsoBib::HashConverter.hash_to_bib
7
9
  # @param args [Hash]
@@ -11,7 +13,7 @@ module RelatonBipm
11
13
  ret = super
12
14
  return if ret.nil?
13
15
 
14
- project_group_hash_to_bib ret
16
+ # project_group_hash_to_bib ret
15
17
  commentperiod_hash_to_bib ret
16
18
  ret
17
19
  end
@@ -37,23 +39,18 @@ module RelatonBipm
37
39
  end
38
40
  end
39
41
 
40
- # @param ret [Hash]
41
- def docstatus_hash_to_bib(ret)
42
- ret[:docstatus] &&= DocumentStatus.new ret[:docstatus]
43
- end
44
-
45
42
  # @param ret [Hash]
46
43
  def commentperiod_hash_to_bib(ret)
47
- ret[:commentperiod] &&= CommentPeriond.new(ret[:commentperiod])
44
+ ret[:comment_period] &&= CommentPeriond.new(ret[:comment_period])
48
45
  end
49
46
 
50
47
  # @param ret [Hash]
51
- def project_group_hash_to_bib(ret)
52
- ret[:project_group] &&= array(ret[:project_group]).map do |pg|
53
- wg = RelatonBib::FormattedString.new pg[:workgroup]
54
- ProjectTeam.new(committee: pg[:committee], workgroup: wg)
55
- end
56
- end
48
+ # def project_group_hash_to_bib(ret)
49
+ # ret[:project_group] &&= array(ret[:project_group]).map do |pg|
50
+ # wg = RelatonBib::FormattedString.new pg[:workgroup]
51
+ # ProjectTeam.new(committee: pg[:committee], workgroup: wg)
52
+ # end
53
+ # end
57
54
 
58
55
  # @param ret [Hash]
59
56
  def dates_hash_to_bib(ret)
@@ -70,6 +67,42 @@ module RelatonBipm
70
67
  RelatonBipm::DocumentRelation.new r
71
68
  end
72
69
  end
70
+
71
+ # @param ret [Hash]
72
+ def editorialgroup_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
73
+ return unless ret[:editorialgroup]
74
+
75
+ cmt = ret[:editorialgroup][:committee].map do |c|
76
+ if (vars = committee_variants c).any?
77
+ content = RelatonBib::LocalizedString.new vars
78
+ Committee.new acronym: c[:acronym], content: content
79
+ else
80
+ Committee.new c
81
+ end
82
+ end
83
+ wg = array(ret[:editorialgroup][:workgroup]).map do |w|
84
+ w.is_a?(Hash) ? WorkGroup.new(w) : WorkGroup.new(content: w)
85
+ end
86
+ ret[:editorialgroup] = EditorialGroup.new committee: cmt, workgroup: wg
87
+ end
88
+
89
+ def committee_variants(cmt)
90
+ array(cmt[:variants]).each_with_object([]) do |v, a|
91
+ c = v[:content] || (ac = acronyms[cmt[:acronym]]) && ac[v[:language]]
92
+ a << RelatonBib::LocalizedString.new(c, v[:language], v[:script]) if c
93
+ end
94
+ end
95
+
96
+ def acronyms
97
+ @@acronyms ||= YAML.load_file File.join __dir__, "acronyms.yaml"
98
+ end
99
+
100
+ # @param ret [Hash]
101
+ def structuredidentifier_hash_to_bib(ret)
102
+ ret[:structuredidentifier] &&= StructuredIdentifier.new(
103
+ **ret[:structuredidentifier]
104
+ )
105
+ end
73
106
  end
74
107
  end
75
108
  end
@@ -0,0 +1,51 @@
1
+ module RelatonBipm
2
+ class StructuredIdentifier
3
+ # @return [String]
4
+ attr_reader :docnumber
5
+
6
+ # @return [String, nil]
7
+ attr_reader :part, :appendix
8
+
9
+ # @param docnumber [String]
10
+ # @param part [String]
11
+ # @param appendix [String]
12
+ def initialize(docnumber:, part: nil, appendix: nil)
13
+ @docnumber = docnumber
14
+ @part = part
15
+ @appendix = appendix
16
+ end
17
+
18
+ # @param builder [Nokogiri::XML::Builder]
19
+ def to_xml(builder)
20
+ builder.structuredidentifier do |b|
21
+ b.docnumber docnumber
22
+ b.part part if part
23
+ b.appendix appendix if appendix
24
+ end
25
+ end
26
+
27
+ # @return [Hash]
28
+ def to_hash
29
+ hash = { "docnumber" => docnumber }
30
+ hash["part"] = part if part
31
+ hash["appendix"] = appendix if appendix
32
+ hash
33
+ end
34
+
35
+ # @param prefix [String]
36
+ # @return [String]
37
+ def to_asciibib(prefix = "")
38
+ pref = prefix.empty? ? prefix : prefix + "."
39
+ pref += "structuredidentifier"
40
+ out = "#{pref}.docnumber:: #{docnumber}\n"
41
+ out += "#{pref}.part:: #{part}\n" if part
42
+ out += "#{pref}.appendix:: #{appendix}\n" if appendix
43
+ out
44
+ end
45
+
46
+ # @return [true]
47
+ def presence?
48
+ true
49
+ end
50
+ end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.5.pre".freeze
2
+ VERSION = "1.7.0".freeze
3
3
  end
@@ -0,0 +1,46 @@
1
+ module RelatonBipm
2
+ class WorkGroup
3
+ # @return [String]
4
+ attr_reader :content
5
+
6
+ # @return [String, nil]
7
+ attr_reader :acronym
8
+
9
+ # @param content [String]
10
+ # @param acronym [String, nil]
11
+ def initialize(content:, acronym: nil)
12
+ @content = content
13
+ @acronym = acronym
14
+ end
15
+
16
+ # @param builder [Nokogiri::XML::Builder]
17
+ def to_xml(builder)
18
+ xml = builder.workgroup content
19
+ xml[:acronym] = acronym if acronym
20
+ end
21
+
22
+ # @param prefix [String]
23
+ # @param count [Integer]
24
+ # @return [String]
25
+ def to_asciibib(prefix, count = 1)
26
+ pref = prefix.empty? ? prefix : prefix + "."
27
+ pref += "workgroup"
28
+ if acronym
29
+ out = count > 1 ? "#{pref}::\n" : ""
30
+ out += "#{pref}.acronym:: #{acronym}\n"
31
+ out + "#{pref}.content:: #{content}\n"
32
+ else "#{pref}:: #{content}\n"
33
+ end
34
+ end
35
+
36
+ # @return [Hash, String]
37
+ def to_hash
38
+ if acronym
39
+ hash = { "content" => content }
40
+ hash["acronym"] = acronym
41
+ hash
42
+ else content
43
+ end
44
+ end
45
+ end
46
+ end
@@ -11,8 +11,9 @@ module RelatonBipm
11
11
  ext = item.at "./ext"
12
12
  return data unless ext
13
13
 
14
- data[:project_group] = fetch_project_group ext
15
- data[:commentperiod] = fetch_commentperiond ext
14
+ data[:comment_period] = fetch_commentperiond ext
15
+ data[:si_aspect] = ext.at("si-aspect")&.text
16
+ data[:meeting_note] = ext.at("meeting-note")&.text
16
17
  data
17
18
  end
18
19
 
@@ -22,18 +23,6 @@ module RelatonBipm
22
23
  BipmBibliographicItem.new item_hash
23
24
  end
24
25
 
25
- def fetch_project_group(ext)
26
- ext.xpath("./project-group").map do |pg|
27
- wg = pg.at "workgroup"
28
- workgroup = RelatonBib::FormattedString.new(
29
- content: wg.text, language: wg[:language], script: wg[:script],
30
- format: wg[:format]
31
- )
32
- ProjectTeam.new(committee: pg.at("committee").text,
33
- workgroup: workgroup)
34
- end
35
- end
36
-
37
26
  # @param item [Nokogiri::XML::Element]
38
27
  # @return [Array<RelatonBib::FormattedString>]
39
28
  def fetch_titles(item)
@@ -60,26 +49,58 @@ module RelatonBipm
60
49
 
61
50
  # @param item [Nokogiri::XML::Element]
62
51
  # @param klass [RelatonBipm::DocumentRelation.class]
63
- # @return [Array<RelatonBib::DocumentRelation>]
52
+ # @return [Array<RelatonBipm::DocumentRelation>]
64
53
  def fetch_relations(item, klass = DocumentRelation)
65
54
  super
66
55
  end
67
56
 
68
- # @param item [Nokogiri::XML::Element]
69
- # @return [RelatonBipm::DocumentStatus]
70
- def fetch_status(item)
71
- status = item.at("./status")
72
- return unless status
57
+ # @param ext [Nokogiri::XML::Element]
58
+ # @return [RelatonBipm::CommentPeriod, nil]
59
+ def fetch_commentperiond(ext)
60
+ return unless ext && (cp = ext.at "comment-period")
73
61
 
74
- DocumentStatus.new status.text
62
+ CommentPeriond.new from: cp.at("from")&.text, to: cp.at("to")&.text
75
63
  end
76
64
 
77
65
  # @param ext [Nokogiri::XML::Element]
78
- # @return [RelatonIho::CommentPeriod, nil]
79
- def fetch_commentperiond(ext)
80
- return unless ext && (cp = ext.at "commentperiod")
66
+ # @return [RelatonBipm::EditorialGroup, nil]
67
+ def fetch_editorialgroup(ext) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
68
+ return unless ext && (eg = ext.at "editorialgroup")
81
69
 
82
- CommentPeriond.new from: cp.at("from")&.text, to: cp.at("to")&.text
70
+ cm = eg.xpath("committee").map do |c|
71
+ vars = variants c
72
+ cnt = if vars.any?
73
+ RelatonBib::LocalizedString.new vars
74
+ else
75
+ RelatonBib::LocalizedString.new c.text, c[:language], c[:script]
76
+ end
77
+ Committee.new acronym: c[:acronym], content: cnt
78
+ end
79
+ wg = eg.xpath("workgroup").map do |w|
80
+ WorkGroup.new content: w.text, acronym: w[:acronym]
81
+ end
82
+ EditorialGroup.new committee: cm, workgroup: wg
83
+ end
84
+
85
+ # @TODO remove this method before next (1.7.0) relaton release
86
+ # it's in the relaton-bib but hasn't released yet
87
+ # @param title [Nokogiri::XML::Element]
88
+ # @return [Array<RelatonBib::LocalizedString>]
89
+ def variants(elm)
90
+ elm.xpath("variant").map do |v|
91
+ RelatonBib::LocalizedString.new v.text, v[:language], v[:script]
92
+ end
93
+ end
94
+
95
+ # @param ext [Nokogiri::XML::Element]
96
+ # @return [RelatonBipm::StructuredIdentifier]
97
+ def fetch_structuredidentifier(ext)
98
+ return unless ext && (sid = ext.at("structuredidentifier"))
99
+
100
+ StructuredIdentifier.new(
101
+ docnumber: sid.at("docnumber")&.text, part: sid.at("part")&.text,
102
+ appendix: sid.at("appendix")&.text
103
+ )
83
104
  end
84
105
  end
85
106
  end
@@ -38,9 +38,10 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
38
38
  spec.add_development_dependency "pry-byebug"
39
39
  spec.add_development_dependency "rake", "~> 10.0"
40
40
  spec.add_development_dependency "ruby-debug-ide"
41
+ spec.add_development_dependency "ruby-jing"
41
42
  spec.add_development_dependency "simplecov"
42
43
  spec.add_development_dependency "vcr"
43
44
  spec.add_development_dependency "webmock"
44
45
 
45
- spec.add_dependency "relaton-bib", "~> 1.5.pre"
46
+ spec.add_dependency "relaton-bib", "~> 1.7.0"
46
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.pre
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-07 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby-jing
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +156,14 @@ dependencies:
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: 1.5.pre
159
+ version: 1.7.0
146
160
  type: :runtime
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 1.5.pre
166
+ version: 1.7.0
153
167
  description: 'RelatonBipm: retrieve BIPM Standards for bibliographic use using the
154
168
  BibliographicItem model'
155
169
  email:
@@ -173,19 +187,23 @@ files:
173
187
  - bin/setup
174
188
  - grammars/basicdoc.rng
175
189
  - grammars/biblio.rng
190
+ - grammars/bipm.rng
176
191
  - grammars/isodoc.rng
177
192
  - grammars/reqt.rng
178
193
  - lib/relaton_bipm.rb
194
+ - lib/relaton_bipm/acronyms.yaml
179
195
  - lib/relaton_bipm/bibliographic_date.rb
180
196
  - lib/relaton_bipm/bipm_bibliographic_item.rb
181
197
  - lib/relaton_bipm/bipm_bibliography.rb
182
198
  - lib/relaton_bipm/comment_periond.rb
199
+ - lib/relaton_bipm/committee.rb
183
200
  - lib/relaton_bipm/document_relation.rb
184
- - lib/relaton_bipm/document_status.rb
201
+ - lib/relaton_bipm/editorial_group.rb
185
202
  - lib/relaton_bipm/hash_converter.rb
186
203
  - lib/relaton_bipm/processor.rb
187
- - lib/relaton_bipm/project_team.rb
204
+ - lib/relaton_bipm/structured_identifier.rb
188
205
  - lib/relaton_bipm/version.rb
206
+ - lib/relaton_bipm/workgroup.rb
189
207
  - lib/relaton_bipm/xml_parser.rb
190
208
  - relaton_bipm.gemspec
191
209
  homepage: https://github.com/relaton/relaton-bipm
@@ -205,9 +223,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
223
  version: 2.4.0
206
224
  required_rubygems_version: !ruby/object:Gem::Requirement
207
225
  requirements:
208
- - - ">"
226
+ - - ">="
209
227
  - !ruby/object:Gem::Version
210
- version: 1.3.1
228
+ version: '0'
211
229
  requirements: []
212
230
  rubygems_version: 3.0.6
213
231
  signing_key:
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RelatonBipm
4
- # Document status.
5
- class DocumentStatus
6
- # @return [String]
7
- attr_reader :status
8
-
9
- # @param status [String]
10
- def initialize(status)
11
- @status = status
12
- end
13
-
14
- # @param [Nokogiri::XML::Builder]
15
- def to_xml(builder)
16
- builder.status status
17
- end
18
-
19
- # @return [String]
20
- def to_hash
21
- status
22
- end
23
-
24
- # @param prefix [String]
25
- # @return [String]
26
- def to_asciibib(prefix = "")
27
- pref = prefix.empty? ? prefix : prefix + "."
28
- "#{pref}docstatus:: #{status}\n"
29
- end
30
- end
31
- end
@@ -1,48 +0,0 @@
1
- module RelatonBipm
2
- class ProjectTeam
3
- COMMITTEES = %w[cgpm cipm bipm ccauv ccem ccl ccm ccpr ccqm ccri cct cctf
4
- ccu ccl-cctfwg jcgm jcrb jctlm inetqi].freeze
5
-
6
- # @return [String]
7
- attr_reader :committee
8
-
9
- # @return [RelatonBib::FormattedString]
10
- attr_reader :workgroup
11
-
12
- # @param committee [String]
13
- # @param workgroup [RelatonBib::FormattedString]
14
- def initialize(committee:, workgroup:)
15
- unless COMMITTEES.include? committee
16
- warn "[relaton-bipm] Warning: invalid committee: #{committee}. "\
17
- "It should be one of: #{COMMITTEES}"
18
- end
19
- @committee = committee
20
- @workgroup = workgroup
21
- end
22
-
23
- # @param builder [Nokogiri::XML::Builder]
24
- def to_xml(builder)
25
- builder.send "project-group" do |b|
26
- b.committee committee
27
- b.workgroup { workgroup.to_xml b }
28
- end
29
- end
30
-
31
- # @return [Hash]
32
- def to_hash
33
- { "committee" => committee, "workgroup" => workgroup.to_hash }
34
- end
35
-
36
- # @param prefix [String]
37
- # 2param count [Integer]
38
- # @return [String]
39
- def to_asciibib(prefix = "", count = 1)
40
- pref = prefix.empty? ? prefix : prefix + "."
41
- pref += "project_group"
42
- out = count > 1 ? "#{pref}::\n" : ""
43
- out += "#{pref}.committee:: #{committee}\n"
44
- out += workgroup.to_asciibib prefix
45
- out
46
- end
47
- end
48
- end