relaton-bipm 1.14.4 → 1.14.6

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: 690219138f8ba35766ffabcbc32ebc6ee026d24eb3567c29a188bb152476c94b
4
- data.tar.gz: fd6a46875f31cb3a2ca5206768198ed93fbdadeb83d510657ea7429f720a9bb5
3
+ metadata.gz: f72520efca5d2a8525b052758d95563c5ca6d57d22b85b146e4ff77e02ee2594
4
+ data.tar.gz: 57803ee16e558e356c0529599ffa8ba881ef85dba99d8b28a1f936a577f711f7
5
5
  SHA512:
6
- metadata.gz: 18b47852d00d29de957bef59e9673a453547ce0df79a656aacf158b4ac5591909030f9d06e874b952507773154bae59e79e860f94510a1e641cab50498722df8
7
- data.tar.gz: 9475dfacb459044df90e16d7c24a3bcec90d21b7dea0f0b34275cfa56e60abf029157087aadf1ff0ef034b79209d158eedb8e04b0009b0dd1d31ba0dac9f6e3c
6
+ metadata.gz: e44f8da41d1c91944196344e85921988c14e5771f976af31471b14bfa216084717942b43b5e3ddc0053891c23e5bb4b7c9d4d9f07ad1abd9b825028fb2b49cd1
7
+ data.tar.gz: 1b6de32f1454222514c9867d86a1bf970d0b42fce78b8f927459e8907a9715ebaf45c17366acfbe2112599fd3c07fc5a93d9729fd43e7565e67dee6acbeb52c3
@@ -5,6 +5,7 @@ name: rake
5
5
  on:
6
6
  push:
7
7
  branches: [ master, main ]
8
+ tags: [ v* ]
8
9
  pull_request:
9
10
 
10
11
  jobs:
@@ -10,8 +10,9 @@ on:
10
10
  Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
11
  required: true
12
12
  default: 'skip'
13
- push:
14
- tags: [ v* ]
13
+ repository_dispatch:
14
+ types: [ do-release ]
15
+
15
16
 
16
17
  jobs:
17
18
  release:
data/README.adoc CHANGED
@@ -91,13 +91,13 @@ Short:
91
91
  {group name} {type-abbrev} {number} ({year}, {lang})
92
92
  ----
93
93
 
94
- `group name` - a name of the group, required. A full list of group names is available https://github.com/metanorma/bipm-editor-guides/blob/main/sources/bipm-outcomes-en.adoc#appendix-a-bipm-groups-and-codes[here].
95
- `type` - a type of document, required. A list of types is: Resolution (Résolution), Recommendation (Recommandation), Decision (Décision), Meeting (Réunion), Declaration (Déclaration).
96
- `type-abbrev` - an abbreviation of the type, required. A list of abbreviations: RES (Resolution), REC (Recommendation), DECN (Decision).
97
- `number` - a number of the document, optional. Can be with part, e.g. `1-2`.
98
- `zero_leading_number` - a number of the document with a leading zero, required. Can be used when a document has a 1 or 2 digits number. It's `00` for documents without a number.
99
- `year` - a year of the document, optional.
100
- `lang` - a language of the document, optional. Can be `EN` or `FR`.
94
+ - `group name` - a name of the group, required. A full list of group names is available https://github.com/metanorma/bipm-editor-guides/blob/main/sources/bipm-outcomes-en.adoc#appendix-a-bipm-groups-and-codes[here].
95
+ - `type` - a type of document, required. A list of types is: Resolution (Résolution), Recommendation (Recommandation), Decision (Décision), Meeting (Réunion), Declaration (Déclaration).
96
+ - `type-abbrev` - an abbreviation of the type, required. A list of abbreviations: RES (Resolution), REC (Recommendation), DECN (Decision).
97
+ - `number` - a number of the document, optional. Can be with part, e.g. `1-2`.
98
+ - `zero_leading_number` - a number of the document with a leading zero, required. Can be used when a document has a 1 or 2 digits number. It's `00` for documents without a number.
99
+ - `year` - a year of the document, optional.
100
+ - `lang` - a language of the document, optional. Can be `EN` or `FR`.
101
101
 
102
102
  ===== Special case pattern
103
103
 
@@ -209,54 +209,54 @@ bib = RelatonBipm::BipmBibliography.get "BIPM Metrologia 29 6 001"
209
209
  ...
210
210
 
211
211
  # get CGPM meetings
212
- RelatonBipm::BipmBibliography.get "CGPM -- Meeting 1 (1889)"
213
- [relaton-bipm] ("CGPM -- Meeting 1 (1889)") fetching...
214
- [relaton-bipm] ("CGPM -- Meeting 1 (1889)") found CGPM -- Meeting 1 (1889)
212
+ RelatonBipm::BipmBibliography.get "CGPM 1st Meeting (1889)"
213
+ [relaton-bipm] ("CGPM 1st Meeting (1889)") fetching...
214
+ [relaton-bipm] ("CGPM 1st Meeting (1889)") found CGPM 1th meeting (1889)
215
215
  => #<RelatonBipm::BipmBibliographicItem:0x00007f7fd02aba28
216
216
  ...
217
217
 
218
218
  # get CGPM resolutions
219
- RelatonBipm::BipmBibliography.get "CGPM -- RES (1889, EN)"
220
- [relaton-bipm] ("CGPM -- RES (1889, EN)") fetching...
221
- [relaton-bipm] ("CGPM -- RES (1889, EN)") found CGPM -- Resolution (1889)
219
+ RelatonBipm::BipmBibliography.get "CGPM RES (1889, E)"
220
+ [relaton-bipm] ("CGPM RES (1889, E)") fetching...
221
+ [relaton-bipm] ("CGPM RES (1889, E)") found CGPM RES (1889)
222
222
  => #<RelatonBipm::BipmBibliographicItem:0x00007f80421f93d8
223
223
  ...
224
224
 
225
- RelatonBipm::BipmBibliography.get "CGPM -- Resolution (1889)"
226
- [relaton-bipm] ("CGPM -- Resolution (1889)") fetching...
227
- [relaton-bipm] ("CGPM -- Resolution (1889)") found CGPM -- Resolution (1889)
225
+ RelatonBipm::BipmBibliography.get "CGPM Resolution (1889)"
226
+ [relaton-bipm] ("CGPM Resolution (1889)") fetching...
227
+ [relaton-bipm] ("CGPM Resolution (1889)") found CGPM RES (1889)
228
228
  => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f60c18
229
229
  ...
230
230
 
231
- RelatonBipm::BipmBibliography.get "CGPM -- Résolution (1889)"
232
- [relaton-bipm] ("CGPM -- Résolution (1889)") fetching...
233
- [relaton-bipm] ("CGPM -- Résolution (1889)") found CGPM -- Resolution (1889)
231
+ RelatonBipm::BipmBibliography.get "CGPM Résolution (1889)"
232
+ [relaton-bipm] ("CGPM Résolution (1889)") fetching...
233
+ [relaton-bipm] ("CGPM Résolution (1889)") found CGPM RES (1889)
234
234
  => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f492e8
235
235
  ...
236
236
 
237
237
  # get CIPM decision by year and decision number
238
238
  RelatonBipm::BipmBibliography.get "BIPM Decision CIPM/101-1 (2012)"
239
239
  [relaton-bipm] ("BIPM Decision CIPM/101-1 (2012)") fetching...
240
- [relaton-bipm] ("BIPM Decision CIPM/101-1 (2012)") found Decision CIPM/101-1 (2012)
240
+ [relaton-bipm] ("BIPM Decision CIPM/101-1 (2012)") found CIPM DECN 101-1 (2012)
241
241
  => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f2bd88
242
242
  ...
243
243
 
244
- RelatonBipm::BipmBibliography.get "BIPM DECN CIPM/101-1 (2012, EN)"
245
- [relaton-bipm] ("BIPM DECN CIPM/101-1 (2012, EN)") fetching...
246
- [relaton-bipm] ("BIPM DECN CIPM/101-1 (2012, EN)") found Decision CIPM/101-1 (2012)
244
+ RelatonBipm::BipmBibliography.get "BIPM DECN CIPM/101-1 (2012, E)"
245
+ [relaton-bipm] ("BIPM DECN CIPM/101-1 (2012, E)") fetching...
246
+ [relaton-bipm] ("BIPM DECN CIPM/101-1 (2012, E)") found CIPM DECN 101-1 (2012)
247
247
  => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f39438
248
248
  ...
249
249
 
250
250
  # get CIPM recommendation
251
- RelatonBipm::BipmBibliography.get "CIPM -- Recommendation 1 (2005)"
252
- [relaton-bipm] ("CIPM -- Recommendation 1 (2005)") fetching...
253
- [relaton-bipm] ("CIPM -- Recommendation 1 (2005)") found CIPM -- Recommendation 1 (2005)
251
+ RelatonBipm::BipmBibliography.get "CIPM Recommendation 1 (2005)"
252
+ [relaton-bipm] ("CIPM Recommendation 1 (2005)") fetching...
253
+ [relaton-bipm] ("CIPM Recommendation 1 (2005)") found CIPM REC 1 (2005)
254
254
  => #<RelatonBipm::BipmBibliographicItem:0x00007f8017f31da0
255
255
  ...
256
256
 
257
- RelatonBipm::BipmBibliography.get "CIPM -- REC 1 (2005, FR)"
258
- [relaton-bipm] ("CIPM -- REC 1 (2005, FR)") fetching...
259
- [relaton-bipm] ("CIPM -- REC 1 (2005, FR)") found CIPM -- Recommendation 1 (2005)
257
+ RelatonBipm::BipmBibliography.get "CIPM REC 1 (2005, FR)"
258
+ [relaton-bipm] ("CIPM REC 1 (2005, FR)") fetching...
259
+ [relaton-bipm] ("CIPM REC 1 (2005, FR)") found CIPM REC 1 (2005)
260
260
  => #<RelatonBipm::BipmBibliographicItem:0x00007f80422100d8
261
261
  ...
262
262
  ----
@@ -2,9 +2,9 @@ module RelatonBipm
2
2
  class BipmBibliographicItem < RelatonBib::BibliographicItem
3
3
  include RelatonBib
4
4
 
5
- TYPES = %w[brochure mise-en-pratique rapport monographie guide
6
- meeting-report technical-report working-party-note strategy
7
- cipm-mra resolutions].freeze
5
+ DOCTYPES = %w[brochure mise-en-pratique rapport monographie guide
6
+ meeting-report technical-report working-party-note strategy
7
+ cipm-mra resolutions].freeze
8
8
 
9
9
  STATUSES = %w[draft-proposal draft-development in-force retired].freeze
10
10
 
@@ -38,7 +38,7 @@ module RelatonBipm
38
38
  key = hash1["docnumber"] || basename
39
39
  @data_fetcher.index[[key]] = outfile
40
40
  @data_fetcher.index_new.add_or_update [key], outfile
41
- @data_fetcher.index2.add_or_update Id.new(key).normalized_hash, outfile
41
+ @data_fetcher.index2.add_or_update Id.new(key).to_hash, outfile
42
42
  hash = if File.exist? outfile
43
43
  warn_duplicate = false
44
44
  hash2 = YAML.load_file outfile
@@ -1,18 +1,20 @@
1
1
  module RelatonBipm
2
2
  class DataOutcomesParser
3
- TYPEABBREV = {
3
+ SHORTTYPE = {
4
4
  "Resolution" => "RES",
5
5
  "Recommendation" => "REC",
6
6
  "Decision" => "DECN",
7
7
  "Statement" => "DECL",
8
+ "Declaration" => "DECL",
9
+ "Action" => "ACT",
8
10
  }.freeze
9
11
 
10
12
  TRANSLATIONS = {
11
- "Déclaration" => "Declaration",
12
- "Réunion" => "Meeting",
13
- "Recommandation" => "Recommendation",
14
- "Résolution" => "Resolution",
15
- "Décision" => "Decision",
13
+ "Declaration" => "Déclaration",
14
+ "Meeting" => "Réunion",
15
+ "Recommendation" => "Recommandation",
16
+ "Resolution" => "Résolution",
17
+ "Decision" => "Décision",
16
18
  }.freeze
17
19
 
18
20
  #
@@ -228,19 +230,10 @@ module RelatonBipm
228
230
  # @param [String] path path to YAML file
229
231
  #
230
232
  def add_to_index(item, path) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
231
- key = [item.docnumber]
232
- TYPEABBREV.each do |k, v|
233
- if item.docnumber.include? k
234
- key << item.docnumber.sub(k, v)
235
- key << item.docnumber.sub(k, v).sub(/(\(\d{4})(\))/, "\\1, EN\\2")
236
- key << item.docnumber.sub(k, v).sub(/(\(\d{4})(\))/, "\\1, FR\\2")
237
- break
238
- end
239
- end
240
- key << item.docidentifier.detect { |i| i.language == "fr" }.id
233
+ key = item.docidentifier.select { |i| i.type == "BIPM" }.map &:id
241
234
  @data_fetcher.index[key] = path
242
235
  @data_fetcher.index_new.add_or_update key, path
243
- key2 = Id.new(item.docnumber).normalized_hash
236
+ key2 = Id.new(item.docnumber).to_hash
244
237
  @data_fetcher.index2.add_or_update key2, path
245
238
  end
246
239
 
@@ -252,20 +245,40 @@ module RelatonBipm
252
245
  #
253
246
  # @return [Array<Hash>] contributors
254
247
  #
255
- def contributors(date, body) # rubocop:disable Metrics/MethodLength
248
+ def contributors(date, body)
249
+ contribs = [{ entity: bipm_org, role: [{ type: "publisher" }] }]
250
+ author = author_org date, body
251
+ contribs << { entity: author, role: [{ type: "author" }] } if author
252
+ contribs
253
+ end
254
+
255
+ #
256
+ # Create author organization
257
+ #
258
+ # @param [String] date date of publication
259
+ # @param [String] body organization abbreviation (CCTF, CIPM, CGPM)
260
+ #
261
+ # @return [Hash, nil] author organization
262
+ #
263
+ def author_org(date, body)
256
264
  case body
257
265
  when "CCTF" then cctf_org date
258
266
  when "CGPM" then cgpm_org
259
267
  when "CIPM" then cipm_org
260
- else []
261
- end.reduce(
262
- [{ entity: {
263
- url: "www.bipm.org",
264
- name: "Bureau International des Poids et Mesures",
265
- abbreviation: "BIPM",
266
- },
267
- role: [{ type: "publisher" }] }],
268
- ) { |a, e| a << { entity: e, role: [{ type: "author" }] } }
268
+ end
269
+ end
270
+
271
+ #
272
+ # Create BIPM organization
273
+ #
274
+ # @return [Hash] BIPM organization
275
+ #
276
+ def bipm_org
277
+ nms = [
278
+ { content: "International Bureau of Weights and Measures", language: "en" },
279
+ { content: "Bureau international des poids et mesures", language: "fr" },
280
+ ]
281
+ organization(nms, "BIPM").tap { |org| org[:url] = "www.bipm.org" }
269
282
  end
270
283
 
271
284
  #
@@ -273,7 +286,7 @@ module RelatonBipm
273
286
  #
274
287
  # @param [String] date date of meeting
275
288
  #
276
- # @return [Array<Hash>] CCTF organization
289
+ # @return [Hash] CCTF organization
277
290
  #
278
291
  def cctf_org(date) # rubocop:disable Metrics/MethodLength
279
292
  if Date.parse(date).year < 1999
@@ -297,17 +310,17 @@ module RelatonBipm
297
310
  # @param [Array<Hash>] names organization names in different languages
298
311
  # @param [String] abbr abbreviation
299
312
  #
300
- # @return [Array<Hash>] organization
313
+ # @return [Hash] organization
301
314
  #
302
315
  def organization(names, abbr)
303
316
  names.each { |ctrb| ctrb[:script] = "Latn" }
304
- [{ name: names, abbreviation: { content: abbr, language: ["en", "fr"], script: "Latn" } }]
317
+ { name: names, abbreviation: { content: abbr, language: ["en", "fr"], script: "Latn" } }
305
318
  end
306
319
 
307
320
  #
308
321
  # Create CGPM organization
309
322
  #
310
- # @return [Array<Hash>] CGPM organization
323
+ # @return [Hash] CGPM organization
311
324
  #
312
325
  def cgpm_org
313
326
  nms = [
@@ -349,12 +362,12 @@ module RelatonBipm
349
362
  # @param [String] session number of meeting
350
363
  #
351
364
  def add_part(hash, part)
352
- regex = /(\p{L}+\s(?:--\s\p{L}+\s|\w+\/)\d+)/
365
+ regex = /(\p{L}+\s(?:\w+\/)?\d+)(?![\d-])/
353
366
  hash[:id] += "-#{part}"
354
367
  hash[:docnumber].sub!(regex) { |m| "#{m}-#{part}" }
355
368
  hash[:docid].select { |id| id.type == "BIPM" }.each do |did|
356
- id = did.instance_variable_get(:@id).sub!(regex) { "#{$1}-#{part}" }
357
- did.instance_variable_set(:@id, id)
369
+ did.instance_variable_get(:@id).sub!(regex) { "#{$1}-#{part}" }
370
+ # did.instance_variable_set(:@id, id)
358
371
  end
359
372
  hash[:structuredidentifier].instance_variable_set :@part, part
360
373
  end
@@ -374,12 +387,12 @@ module RelatonBipm
374
387
  # @return [Hash] Hash of BIPM meeting/resolution
375
388
  #
376
389
  def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
377
- docnum = create_docnum args[:body], args[:type], args[:num], args[:en]["date"]
390
+ docnum = create_meeting_docnum args[:body], args[:type], args[:num], args[:en]["date"]
378
391
  hash = { title: [], type: "proceedings", doctype: args[:type],
379
392
  place: [RelatonBib::Place.new(city: "Paris")] }
380
393
  hash[:title] = create_titles args.slice(:en, :fr)
381
394
  hash[:date] = [{ type: "published", on: args[:en]["date"] }]
382
- hash[:docid] = create_docids docnum
395
+ hash[:docid] = create_meeting_docids docnum
383
396
  hash[:docnumber] = docnum # .sub(" --", "").sub(/\s\(\d{4}\)/, "")
384
397
  hash[:id] = create_id(args[:body], args[:type], args[:num], args[:en]["date"])
385
398
  hash[:link] = create_links(**args)
@@ -426,16 +439,21 @@ module RelatonBipm
426
439
  #
427
440
  def create_docnum(body, type, num, date)
428
441
  year = Date.parse(date).year
429
- if special_id_case? body, type, year
430
- id = "#{type.capitalize} #{body}"
431
- id += "/#{num}" if num.to_i.positive?
432
- else
433
- id = "#{body} -- #{type.capitalize}"
434
- id += " #{num}" if num.to_i.positive?
435
- end
442
+ # if special_id_case? body, type, year
443
+ # id = "#{type.capitalize} #{body}"
444
+ # id += "/#{num}" if num.to_i.positive?
445
+ # else
446
+ id = "#{body} #{SHORTTYPE[type.capitalize]}"
447
+ id += " #{num}" if num.to_i.positive?
448
+ # end
436
449
  "#{id} (#{year})"
437
450
  end
438
451
 
452
+ def create_meeting_docnum(body, type, num, date)
453
+ year = Date.parse(date).year
454
+ "#{body} #{num}th #{type} (#{year})"
455
+ end
456
+
439
457
  #
440
458
  # Create ID
441
459
  #
@@ -448,13 +466,11 @@ module RelatonBipm
448
466
  #
449
467
  def create_id(body, type, num, date)
450
468
  year = Date.parse(date).year
451
- id = if special_id_case?(body, type, year)
452
- "#{type.capitalize}-#{body}-#{year}"
453
- else
454
- "#{body}-#{type.capitalize}-#{year}"
455
- end
456
- id += "-#{num}" if num.to_i.positive?
457
- id
469
+ # if special_id_case?(body, type, year)
470
+ # [type.capitalize, body, year]
471
+ # else
472
+ [body, SHORTTYPE[type.capitalize], year, num].compact.join("-")
473
+ # end
458
474
  end
459
475
 
460
476
  #
@@ -466,10 +482,10 @@ module RelatonBipm
466
482
  #
467
483
  # @return [Boolean] is special case
468
484
  #
469
- def special_id_case?(body, type, year)
470
- (body == "CIPM" && type == "Decision" && year.to_i > 2011) ||
471
- (body == "JCRB" && %w[recomendation resolution descision].include?(type))
472
- end
485
+ # def special_id_case?(body, type, year)
486
+ # (body == "CIPM" && type == "Decision" && year.to_i > 2011) ||
487
+ # (body == "JCRB" && %w[recomendation resolution descision].include?(type))
488
+ # end
473
489
 
474
490
  #
475
491
  # Create documetn IDs
@@ -478,12 +494,22 @@ module RelatonBipm
478
494
  #
479
495
  # @return [Array<RelatonBib::DocumentIdentifier>] document IDs
480
496
  #
481
- def create_docids(en_id)
482
- id = en_id.clone
497
+ def create_docids(id)
498
+ en_id = id.sub(/(\s\(\d{4})(\))$/, '\1, E\2')
499
+ fr_id = id.sub(/(\s\(\d{4})(\))$/, '\1, F\2')
483
500
  [
484
501
  make_docid(id: id, type: "BIPM", primary: true),
485
- make_docid(id: id.clone, type: "BIPM", primary: true, language: "en", script: "Latn"),
486
- create_docid_fr(en_id),
502
+ make_docid(id: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
503
+ make_docid(id: fr_id, type: "BIPM", primary: true, language: "fr", script: "Latn"),
504
+ # create_docid_fr(en_id),
505
+ ]
506
+ end
507
+
508
+ def create_meeting_docids(en_id)
509
+ fr_id = en_id.sub(/(\d+)th/, '\1e').sub("meeting", "réunion")
510
+ [
511
+ make_docid(id: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
512
+ make_docid(id: fr_id, type: "BIPM", primary: true, language: "fr", script: "Latn"),
487
513
  ]
488
514
  end
489
515
 
@@ -494,11 +520,11 @@ module RelatonBipm
494
520
  #
495
521
  # @return [RelatonBib::DocumentIdentifier] french document ID
496
522
  #
497
- def create_docid_fr(en_id)
498
- tr = TRANSLATIONS.detect { |_, v| en_id.include? v }
499
- id = tr ? en_id.sub(tr[1], tr[0]) : en_id
500
- make_docid(id: id, type: "BIPM", primary: true, language: "fr", script: "Latn")
501
- end
523
+ # def create_docid_fr(en_id)
524
+ # tr = TRANSLATIONS.detect { |_, v| en_id.include? v }
525
+ # id = tr ? en_id.sub(tr[1], tr[0]) : en_id
526
+ # make_docid(id: id, type: "BIPM", primary: true, language: "fr", script: "Latn")
527
+ # end
502
528
 
503
529
  #
504
530
  # Create doucment ID
@@ -11,11 +11,13 @@ module RelatonBipm
11
11
  rule(:delimeter) { str("--") >> space }
12
12
  rule(:delimeter?) { delimeter.maybe }
13
13
 
14
- rule(:lang) { comma >> match["A-Z"].repeat(2, 2).as(:lang) }
14
+ rule(:lang) { comma >> space? >> match["A-Z"].repeat(1, 2).as(:lang) }
15
15
  rule(:lang?) { lang.maybe }
16
16
 
17
- rule(:number) { match["0-9-"].repeat(1).as(:number) >> space? }
17
+ rule(:numdash) { match["0-9-"].repeat(1).as(:number) }
18
+ rule(:number) { numdash >> space? }
18
19
  rule(:number?) { number.maybe }
20
+ rule(:num_suff) { numdash >> match["a-z"].repeat(1, 2) >> space }
19
21
 
20
22
  rule(:year) { match["0-9"].repeat(4, 4).as(:year) }
21
23
  rule(:year_paren) { lparen >> year >> lang? >> rparen }
@@ -37,7 +39,8 @@ module RelatonBipm
37
39
 
38
40
  rule(:type_group) { type >> group >> slash >> num_and_year }
39
41
  rule(:group_type) { group >> space >> delimeter? >> type >> num_and_year }
40
- rule(:outcome) { group_type | type_group }
42
+ rule(:group_num) { group >> space >> num_suff >> type >> year_paren }
43
+ rule(:outcome) { group_num | group_type | type_group }
41
44
 
42
45
  rule(:append) { comma >> str("Appendix") >> space >> number }
43
46
  rule(:brochure) { str("SI").as(:group) >> space >> str("Brochure").as(:type) >> append.maybe }
@@ -58,6 +61,7 @@ module RelatonBipm
58
61
  "Décision" => "DECN",
59
62
  "Declaration" => "Déclaration",
60
63
  "Réunion" => "Meeting",
64
+ "Action" => "ACT",
61
65
  }.freeze
62
66
 
63
67
  # @return [Hash] the parsed id components
@@ -84,8 +88,8 @@ module RelatonBipm
84
88
  # @return [Boolean] true if the two Id objects are equal
85
89
  #
86
90
  def ==(other)
87
- other_hash = other.is_a?(Id) ? other.normalized_hash : other
88
- hash = normalized_hash
91
+ other_hash = other.is_a?(Id) ? other.to_hash : normalize_hash(other)
92
+ hash = to_hash
89
93
  hash.delete(:year) unless other_hash[:year]
90
94
  other_hash.delete(:year) unless hash[:year]
91
95
  hash.delete(:lang) unless other_hash[:lang]
@@ -99,16 +103,26 @@ module RelatonBipm
99
103
  #
100
104
  # @return [Hash] the normalized ID parts
101
105
  #
102
- def normalized_hash # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
103
- @normalized_hash ||= begin
104
- hash = { group: id[:group].to_s.sub("CCDS", "CCTF") }
105
- hash[:type] = normalized_type if id[:type]
106
- norm_num = normalized_number
107
- hash[:number] = norm_num unless norm_num.nil? || norm_num.empty?
108
- hash[:year] = id[:year].to_s if id[:year]
109
- hash[:lang] = id[:lang].to_s if id[:lang]
110
- hash
111
- end
106
+ def to_hash
107
+ @to_hash ||= normalize_hash id
108
+ end
109
+
110
+ #
111
+ # Normalize ID parts
112
+ # Traslate type into abbreviation, remove leading zeros from number
113
+ #
114
+ # @param [RelatonBipm::Id, Hash] src the ID parts
115
+ #
116
+ # @return [Hash] the normalized ID parts
117
+ #
118
+ def normalize_hash(src) # rubocop:disable Metrics/AbcSize
119
+ hash = { group: src[:group].to_s.sub("CCDS", "CCTF") }
120
+ hash[:type] = normalized_type(src) if src[:type]
121
+ norm_num = normalized_number(src)
122
+ hash[:number] = norm_num unless norm_num.nil? || norm_num.empty?
123
+ hash[:year] = src[:year].to_s if src[:year]
124
+ hash[:lang] = src[:lang].to_s if src[:lang]
125
+ hash
112
126
  end
113
127
 
114
128
  #
@@ -116,8 +130,9 @@ module RelatonBipm
116
130
  #
117
131
  # @return [String] the normalized type
118
132
  #
119
- def normalized_type
120
- TYPES[id[:type].to_s] || id[:type].to_s
133
+ def normalized_type(src)
134
+ type = TYPES[src[:type].to_s.capitalize] || src[:type].to_s
135
+ type == type.upcase ? type : type.capitalize
121
136
  end
122
137
 
123
138
  #
@@ -125,10 +140,10 @@ module RelatonBipm
125
140
  #
126
141
  # @return [String, nil] the normalized number
127
142
  #
128
- def normalized_number
129
- return unless id[:number]
143
+ def normalized_number(src)
144
+ return unless src[:number]
130
145
 
131
- id[:number].to_s.sub(/^0+/, "")
146
+ src[:number].to_s.sub(/^0+/, "")
132
147
  end
133
148
  end
134
149
  end
@@ -7,7 +7,7 @@ module RelatonBipm
7
7
  def initialize
8
8
  @short = :relaton_bipm
9
9
  @prefix = "BIPM"
10
- @defaultprefix = %r{^(?:BIPM|CCTF|CCDS|CGPM|CIPM)(?!\w)}
10
+ @defaultprefix = %r{^(?:BIPM|CCTF|CCDS|CGPM|CIPM|JCRB)(?!\w)}
11
11
  @idtype = "BIPM"
12
12
  @datasets = %w[bipm-data-outcomes bipm-si-brochure rawdata-bipm-metrologia]
13
13
  end
@@ -103,7 +103,10 @@ module RelatonBipm
103
103
  @meta.xpath("./title-group/article-title").map do |t|
104
104
  next if t.text.empty?
105
105
 
106
- RelatonBib::TypedTitleString.new content: t.text, language: t[:"xml:lang"], script: "Latn"
106
+ format = CGI.escapeHTML(t.inner_html) == t.inner_html ? "text/plain" : "text/html"
107
+ RelatonBib::TypedTitleString.new(
108
+ content: t.inner_html, language: t[:"xml:lang"], script: "Latn", format: format,
109
+ )
107
110
  end.compact
108
111
  end
109
112
 
@@ -35,7 +35,7 @@ module RelatonBipm
35
35
  out_path = File.join(@data_fetcher.output, file)
36
36
  @data_fetcher.index[[item.docidentifier.first.id]] = out_path
37
37
  @data_fetcher.index_new.add_or_update [item.docidentifier.first.id], out_path
38
- key = Id.new(item.docidentifier.first.id).normalized_hash
38
+ key = Id.new(item.docidentifier.first.id).to_hash
39
39
  @data_fetcher.index2.add_or_update key, out_path
40
40
  @data_fetcher.write_file out_path, item
41
41
  end
@@ -80,7 +80,7 @@ module RelatonBipm
80
80
  path = File.join(@data_fetcher.output, file)
81
81
  @data_fetcher.index[[id]] = path
82
82
  @data_fetcher.index_new.add_or_update [id], path
83
- @data_fetcher.index2.add_or_update Id.new(id).normalized_hash, path
83
+ @data_fetcher.index2.add_or_update Id.new(id).to_hash, path
84
84
  @data_fetcher.write_file path, item
85
85
  end
86
86
 
@@ -138,11 +138,12 @@ module RelatonBipm
138
138
  #
139
139
  def relation(*args)
140
140
  dir = [DIR, *args].join("/")
141
- Dir["#{dir}/*"].map do |path|
141
+ ids = Set.new
142
+ Dir["#{dir}/*"].each do |path|
142
143
  part = path.split("/").last
143
- id = identifier(*args, part)
144
- RelatonBib::DocumentRelation.new(type: "partOf", bibitem: rel_bibitem(id))
144
+ ids << identifier(*args, part)
145
145
  end
146
+ ids.map { |id| RelatonBib::DocumentRelation.new(type: "partOf", bibitem: rel_bibitem(id)) }
146
147
  end
147
148
 
148
149
  #
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.14.4".freeze
2
+ VERSION = "1.14.6".freeze
3
3
  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.14.4
4
+ version: 1.14.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-18 00:00:00.000000000 Z
11
+ date: 2023-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -175,7 +175,7 @@ licenses:
175
175
  metadata:
176
176
  homepage_uri: https://github.com/relaton/relaton-bipm
177
177
  source_code_uri: https://github.com/relaton/relaton-bipm
178
- post_install_message:
178
+ post_install_message:
179
179
  rdoc_options: []
180
180
  require_paths:
181
181
  - lib
@@ -190,8 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubygems_version: 3.1.6
194
- signing_key:
193
+ rubygems_version: 3.4.9
194
+ signing_key:
195
195
  specification_version: 4
196
196
  summary: 'RelatonBipm: retrieve BIPM Standards for bibliographic use using the BibliographicItem
197
197
  model'