relaton-bipm 1.14.4 → 1.14.5

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: e0d5eb5717b605c2d3eec083e4ca529ccafb140246b1b8a042137d1025b41abb
4
+ data.tar.gz: bdef48071e8e5ab07d643e54fed9f21c38d29119927620216a23d2d2d9c84a7b
5
5
  SHA512:
6
- metadata.gz: 18b47852d00d29de957bef59e9673a453547ce0df79a656aacf158b4ac5591909030f9d06e874b952507773154bae59e79e860f94510a1e641cab50498722df8
7
- data.tar.gz: 9475dfacb459044df90e16d7c24a3bcec90d21b7dea0f0b34275cfa56e60abf029157087aadf1ff0ef034b79209d158eedb8e04b0009b0dd1d31ba0dac9f6e3c
6
+ metadata.gz: '09e75649f7ca561179506cf24c0eb9c06b2c2e6241aac712e3aaa01e85985542d7086d907068acc365b0b93386e83160646e41d67585b1c9a8e98c8b5c281f55'
7
+ data.tar.gz: ca8540f40846fe5d92b0b2da284c72cb3a44a4dfd580ad4a51eb6c625cfd400aa59b7a435c46af45244540482d02aff1bd9aa70b3cc5359a41b873602b5d5ecd
@@ -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,19 @@ 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.docnumber]
234
+ # SHORTTYPE.each do |k, v|
235
+ # if item.docnumber.include? k
236
+ # key << item.docnumber.sub(k, v)
237
+ # key << item.docnumber.sub(k, v).sub(/(\(\d{4})(\))/, "\\1, EN\\2")
238
+ # key << item.docnumber.sub(k, v).sub(/(\(\d{4})(\))/, "\\1, FR\\2")
239
+ # break
240
+ # end
241
+ # end
242
+ key = item.docidentifier.select { |i| i.type == "BIPM" }.map &:id
241
243
  @data_fetcher.index[key] = path
242
244
  @data_fetcher.index_new.add_or_update key, path
243
- key2 = Id.new(item.docnumber).normalized_hash
245
+ key2 = Id.new(item.docnumber).to_hash
244
246
  @data_fetcher.index2.add_or_update key2, path
245
247
  end
246
248
 
@@ -349,12 +351,12 @@ module RelatonBipm
349
351
  # @param [String] session number of meeting
350
352
  #
351
353
  def add_part(hash, part)
352
- regex = /(\p{L}+\s(?:--\s\p{L}+\s|\w+\/)\d+)/
354
+ regex = /(\p{L}+\s(?:\w+\/)?\d+)(?![\d-])/
353
355
  hash[:id] += "-#{part}"
354
356
  hash[:docnumber].sub!(regex) { |m| "#{m}-#{part}" }
355
357
  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)
358
+ did.instance_variable_get(:@id).sub!(regex) { "#{$1}-#{part}" }
359
+ # did.instance_variable_set(:@id, id)
358
360
  end
359
361
  hash[:structuredidentifier].instance_variable_set :@part, part
360
362
  end
@@ -374,12 +376,12 @@ module RelatonBipm
374
376
  # @return [Hash] Hash of BIPM meeting/resolution
375
377
  #
376
378
  def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
377
- docnum = create_docnum args[:body], args[:type], args[:num], args[:en]["date"]
379
+ docnum = create_meeting_docnum args[:body], args[:type], args[:num], args[:en]["date"]
378
380
  hash = { title: [], type: "proceedings", doctype: args[:type],
379
381
  place: [RelatonBib::Place.new(city: "Paris")] }
380
382
  hash[:title] = create_titles args.slice(:en, :fr)
381
383
  hash[:date] = [{ type: "published", on: args[:en]["date"] }]
382
- hash[:docid] = create_docids docnum
384
+ hash[:docid] = create_meeting_docids docnum
383
385
  hash[:docnumber] = docnum # .sub(" --", "").sub(/\s\(\d{4}\)/, "")
384
386
  hash[:id] = create_id(args[:body], args[:type], args[:num], args[:en]["date"])
385
387
  hash[:link] = create_links(**args)
@@ -426,16 +428,21 @@ module RelatonBipm
426
428
  #
427
429
  def create_docnum(body, type, num, date)
428
430
  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
431
+ # if special_id_case? body, type, year
432
+ # id = "#{type.capitalize} #{body}"
433
+ # id += "/#{num}" if num.to_i.positive?
434
+ # else
435
+ id = "#{body} #{SHORTTYPE[type.capitalize]}"
436
+ id += " #{num}" if num.to_i.positive?
437
+ # end
436
438
  "#{id} (#{year})"
437
439
  end
438
440
 
441
+ def create_meeting_docnum(body, type, num, date)
442
+ year = Date.parse(date).year
443
+ "#{body} #{num}th #{type} (#{year})"
444
+ end
445
+
439
446
  #
440
447
  # Create ID
441
448
  #
@@ -448,13 +455,11 @@ module RelatonBipm
448
455
  #
449
456
  def create_id(body, type, num, date)
450
457
  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
458
+ # if special_id_case?(body, type, year)
459
+ # [type.capitalize, body, year]
460
+ # else
461
+ [body, SHORTTYPE[type.capitalize], year, num].compact.join("-")
462
+ # end
458
463
  end
459
464
 
460
465
  #
@@ -466,10 +471,10 @@ module RelatonBipm
466
471
  #
467
472
  # @return [Boolean] is special case
468
473
  #
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
474
+ # def special_id_case?(body, type, year)
475
+ # (body == "CIPM" && type == "Decision" && year.to_i > 2011) ||
476
+ # (body == "JCRB" && %w[recomendation resolution descision].include?(type))
477
+ # end
473
478
 
474
479
  #
475
480
  # Create documetn IDs
@@ -478,12 +483,22 @@ module RelatonBipm
478
483
  #
479
484
  # @return [Array<RelatonBib::DocumentIdentifier>] document IDs
480
485
  #
481
- def create_docids(en_id)
482
- id = en_id.clone
486
+ def create_docids(id)
487
+ en_id = id.sub(/(\s\(\d{4})(\))$/, '\1, E\2')
488
+ fr_id = id.sub(/(\s\(\d{4})(\))$/, '\1, F\2')
483
489
  [
484
490
  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),
491
+ make_docid(id: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
492
+ make_docid(id: fr_id, type: "BIPM", primary: true, language: "fr", script: "Latn"),
493
+ # create_docid_fr(en_id),
494
+ ]
495
+ end
496
+
497
+ def create_meeting_docids(en_id)
498
+ fr_id = en_id.sub(/(\d+)th/, '\1e').sub("meeting", "réunion")
499
+ [
500
+ make_docid(id: en_id, type: "BIPM", primary: true, language: "en", script: "Latn"),
501
+ make_docid(id: fr_id, type: "BIPM", primary: true, language: "fr", script: "Latn"),
487
502
  ]
488
503
  end
489
504
 
@@ -494,11 +509,11 @@ module RelatonBipm
494
509
  #
495
510
  # @return [RelatonBib::DocumentIdentifier] french document ID
496
511
  #
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
512
+ # def create_docid_fr(en_id)
513
+ # tr = TRANSLATIONS.detect { |_, v| en_id.include? v }
514
+ # id = tr ? en_id.sub(tr[1], tr[0]) : en_id
515
+ # make_docid(id: id, type: "BIPM", primary: true, language: "fr", script: "Latn")
516
+ # end
502
517
 
503
518
  #
504
519
  # 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.5".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.5
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-02 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'