relaton-bipm 1.16.5 → 1.17.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: b1d91960ac9f8357a2ced7209b3dcb7c3ff4637b899639c09a622c2715fe7d36
4
- data.tar.gz: 56536641e820e1d14336f8d40efce9a1be829c9356d362761740fc09a39d5b6f
3
+ metadata.gz: 4d6ca7c2babd9a223b0ed3493818df34cee58241d4589edb19c640d28d2d473d
4
+ data.tar.gz: 42a2f2b7c16a9e06be43c0ddcfea027220a9bbcd4d9fe7aeed67b1fc579135c2
5
5
  SHA512:
6
- metadata.gz: 57a28e5cc70fd280b02caa1d267fa79d8aff4e7b120847bae458e283977e631190d622b727c1830fa442c0507a46227548cee50666bf0010fe50fa242b62edc6
7
- data.tar.gz: cf74e9ff7b2ad3d2db08b17f8c4139b42d43cfe8bba98d7bd81bf154ea51341ecd821e596780b9415e839f47b664adf6d085b8e678fa3497f773211beb64d015
6
+ metadata.gz: 4375e47c892a72b1f9c7a246d303fc2deb3334b42ca505121133246bdd59584338e12d4c8a6afcd791787267cd1c4574a145f72ede538cffcf87dab20b1d8d1b
7
+ data.tar.gz: b384da3f7d91958f0c1c8c8f4ef41e1f74cd2faa2a4e631684c93fdf2d9af8dd180cde2213d4a7e7a37bd99fce66c6f5e4a06e7e2fb30b2b4d6e33af8bcaf1c2
@@ -346,6 +346,8 @@
346
346
  <ref name="keyword"/>
347
347
  <ref name="xref"/>
348
348
  <ref name="hyperlink"/>
349
+ <ref name="index"/>
350
+ <ref name="index-xref"/>
349
351
  </choice>
350
352
  </oneOrMore>
351
353
  </element>
@@ -623,6 +625,8 @@
623
625
  <ref name="eref"/>
624
626
  <ref name="xref"/>
625
627
  <ref name="hyperlink"/>
628
+ <ref name="index"/>
629
+ <ref name="index-xref"/>
626
630
  </choice>
627
631
  </zeroOrMore>
628
632
  </element>
@@ -636,6 +640,8 @@
636
640
  <ref name="eref"/>
637
641
  <ref name="xref"/>
638
642
  <ref name="hyperlink"/>
643
+ <ref name="index"/>
644
+ <ref name="index-xref"/>
639
645
  </choice>
640
646
  </zeroOrMore>
641
647
  </element>
@@ -648,6 +654,8 @@
648
654
  <ref name="eref"/>
649
655
  <ref name="xref"/>
650
656
  <ref name="hyperlink"/>
657
+ <ref name="index"/>
658
+ <ref name="index-xref"/>
651
659
  </choice>
652
660
  </zeroOrMore>
653
661
  </element>
@@ -655,7 +663,11 @@
655
663
  <define name="keyword">
656
664
  <element name="keyword">
657
665
  <zeroOrMore>
658
- <ref name="PureTextElement"/>
666
+ <choice>
667
+ <ref name="PureTextElement"/>
668
+ <ref name="index"/>
669
+ <ref name="index-xref"/>
670
+ </choice>
659
671
  </zeroOrMore>
660
672
  </element>
661
673
  </define>
@@ -676,7 +688,11 @@
676
688
  <define name="strike">
677
689
  <element name="strike">
678
690
  <zeroOrMore>
679
- <ref name="PureTextElement"/>
691
+ <choice>
692
+ <ref name="PureTextElement"/>
693
+ <ref name="index"/>
694
+ <ref name="index-xref"/>
695
+ </choice>
680
696
  </zeroOrMore>
681
697
  </element>
682
698
  </define>
data/grammars/biblio.rng CHANGED
@@ -942,6 +942,7 @@
942
942
  <value>obsoleted</value>
943
943
  <value>confirmed</value>
944
944
  <value>updated</value>
945
+ <value>corrected</value>
945
946
  <value>issued</value>
946
947
  <value>transmitted</value>
947
948
  <value>copied</value>
@@ -2,10 +2,6 @@ module RelatonBipm
2
2
  class BipmBibliographicItem < RelatonBib::BibliographicItem
3
3
  include RelatonBib
4
4
 
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
-
9
5
  STATUSES = %w[draft-proposal draft-development in-force retired].freeze
10
6
 
11
7
  SI_ASPECTS = %w[
@@ -69,7 +65,7 @@ module RelatonBipm
69
65
  si_aspect || comment_period ||
70
66
  structuredidentifier)
71
67
  ext = b.ext do
72
- b.doctype doctype if doctype
68
+ doctype&.to_xml b
73
69
  editorialgroup&.to_xml b
74
70
  comment_period&.to_xml b
75
71
  b.send :"si-aspect", si_aspect if si_aspect
@@ -62,7 +62,7 @@ module RelatonBipm
62
62
 
63
63
  def index
64
64
  Relaton::Index.find_or_create(
65
- :bipm, url: "#{GH_ENDPOINT}index2.zip", file: INDEX_FILE, id_keys: %i[group type number year]
65
+ :bipm, url: "#{GH_ENDPOINT}index2.zip", file: INDEX_FILE, id_keys: %i[group type number year corr]
66
66
  )
67
67
  end
68
68
 
@@ -159,7 +159,7 @@ module RelatonBipm
159
159
  args[:en]["resolutions"].each.with_index do |r, i| # rubocop:disable Metrics/BlockLength
160
160
  hash = {
161
161
  type: "proceedings", title: [],
162
- doctype: r["type"], place: [RelatonBib::Place.new(city: "Paris")]
162
+ doctype: DocumentType.new(type: r["type"]), place: [RelatonBib::Place.new(city: "Paris")]
163
163
  }
164
164
  fr_r = args[:fr]["resolutions"].fetch(i, nil)
165
165
  hash[:title] = resolution_title r, fr_r
@@ -385,7 +385,7 @@ module RelatonBipm
385
385
  #
386
386
  def meeting_bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
387
387
  docnum = create_meeting_docnum args[:body], args[:type], args[:num], args[:en]["date"]
388
- hash = { title: [], type: "proceedings", doctype: args[:type],
388
+ hash = { title: [], type: "proceedings", doctype: DocumentType.new(type: args[:type]),
389
389
  place: [RelatonBib::Place.new(city: "Paris")] }
390
390
  hash[:title] = create_titles args.slice(:en, :fr)
391
391
  hash[:date] = [{ type: "published", on: args[:en]["date"] }]
@@ -0,0 +1,29 @@
1
+ module RelatonBipm
2
+ class DocumentType < RelatonBib::DocumentType
3
+ DOCTYPES = %w[brochure mise-en-pratique rapport monographie guide
4
+ meeting-report technical-report working-party-note strategy
5
+ cipm-mra resolutions].freeze
6
+
7
+ #
8
+ # Initialize a document type object.
9
+ #
10
+ # @param [String] type document type
11
+ # @param [String, nil] abbreviation abbreviation
12
+ #
13
+ def initialize(type:, abbreviation: nil)
14
+ check_type type
15
+ super
16
+ end
17
+
18
+ #
19
+ # Check if document type is valid.
20
+ #
21
+ # @param [String] type document type
22
+ #
23
+ def check_type(type)
24
+ # unless DOCTYPES.include? type
25
+ # Util.warn "WARNING: invalid doctype: `#{type}`"
26
+ # end
27
+ end
28
+ end
29
+ end
@@ -1,105 +1,110 @@
1
1
  require "yaml"
2
2
 
3
3
  module RelatonBipm
4
- class HashConverter < RelatonBib::HashConverter
4
+ module HashConverter
5
+ include RelatonBib::HashConverter
6
+ extend self
7
+
5
8
  @@acronyms = nil
6
9
 
7
- class << self
8
- # @override RelatonIsoBib::HashConverter.hash_to_bib
9
- # @param args [Hash]
10
- # @param nested [TrueClass, FalseClass]
11
- # @return [Hash]
12
- def hash_to_bib(args)
13
- ret = super
14
- return if ret.nil?
15
-
16
- # project_group_hash_to_bib ret
17
- commentperiod_hash_to_bib ret
18
- ret
19
- end
10
+ # @override RelatonIsoBib::HashConverter.hash_to_bib
11
+ # @param args [Hash]
12
+ # @param nested [TrueClass, FalseClass]
13
+ # @return [Hash]
14
+ def hash_to_bib(args)
15
+ ret = super
16
+ return if ret.nil?
20
17
 
21
- private
18
+ # project_group_hash_to_bib ret
19
+ commentperiod_hash_to_bib ret
20
+ ret
21
+ end
22
22
 
23
- # @param item_hash [Hash]
24
- # @return [RelatonBib::BibliographicItem]
25
- def bib_item(item_hash)
26
- BipmBibliographicItem.new(**item_hash)
27
- end
23
+ private
28
24
 
29
- # @param ret [Hash]
30
- def title_hash_to_bib(ret)
31
- ret[:title] &&= RelatonBib.array(ret[:title])
32
- .reduce(RelatonBib::TypedTitleStringCollection.new) do |m, t|
33
- m << if t.is_a? Hash
34
- RelatonBib::TypedTitleString.new(**t)
35
- else
36
- RelatonBib::TypedTitleString.new(content: t)
37
- end
38
- end
39
- end
25
+ # @param item_hash [Hash]
26
+ # @return [RelatonBib::BibliographicItem]
27
+ def bib_item(item_hash)
28
+ BipmBibliographicItem.new(**item_hash)
29
+ end
40
30
 
41
- # @param ret [Hash]
42
- def commentperiod_hash_to_bib(ret)
43
- ret[:comment_period] &&= CommentPeriond.new(**ret[:comment_period])
31
+ # @param ret [Hash]
32
+ def title_hash_to_bib(ret)
33
+ ret[:title] &&= RelatonBib.array(ret[:title])
34
+ .reduce(RelatonBib::TypedTitleStringCollection.new) do |m, t|
35
+ m << if t.is_a? Hash
36
+ RelatonBib::TypedTitleString.new(**t)
37
+ else
38
+ RelatonBib::TypedTitleString.new(content: t)
39
+ end
44
40
  end
41
+ end
45
42
 
46
- # @param ret [Hash]
47
- # def project_group_hash_to_bib(ret)
48
- # ret[:project_group] &&= RelatonBib.array(ret[:project_group]).map do |pg|
49
- # wg = RelatonBib::FormattedString.new pg[:workgroup]
50
- # ProjectTeam.new(committee: pg[:committee], workgroup: wg)
51
- # end
52
- # end
53
-
54
- # @param ret [Hash]
55
- def dates_hash_to_bib(ret)
56
- super
57
- ret[:date] &&= ret[:date].map { |d| BibliographicDate.new(**d) }
58
- end
43
+ # @param ret [Hash]
44
+ def commentperiod_hash_to_bib(ret)
45
+ ret[:comment_period] &&= CommentPeriond.new(**ret[:comment_period])
46
+ end
59
47
 
60
- # @param ret [Hash]
61
- def relations_hash_to_bib(ret)
62
- super
63
- ret[:relation] &&= ret[:relation].map do |r|
64
- RelatonBipm::DocumentRelation.new(**r)
65
- end
66
- end
48
+ # @param ret [Hash]
49
+ # def project_group_hash_to_bib(ret)
50
+ # ret[:project_group] &&= RelatonBib.array(ret[:project_group]).map do |pg|
51
+ # wg = RelatonBib::FormattedString.new pg[:workgroup]
52
+ # ProjectTeam.new(committee: pg[:committee], workgroup: wg)
53
+ # end
54
+ # end
67
55
 
68
- # @param ret [Hash]
69
- def editorialgroup_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
70
- return unless ret[:editorialgroup]
71
-
72
- cmt = ret[:editorialgroup][:committee].map do |c|
73
- if (vars = committee_variants c).any?
74
- content = RelatonBib::LocalizedString.new vars
75
- Committee.new acronym: c[:acronym], content: content
76
- else
77
- Committee.new(**c)
78
- end
79
- end
80
- wg = RelatonBib.array(ret[:editorialgroup][:workgroup]).map do |w|
81
- w.is_a?(Hash) ? WorkGroup.new(**w) : WorkGroup.new(content: w)
82
- end
83
- ret[:editorialgroup] = EditorialGroup.new committee: cmt, workgroup: wg
56
+ # @param ret [Hash]
57
+ def dates_hash_to_bib(ret)
58
+ super
59
+ ret[:date] &&= ret[:date].map { |d| BibliographicDate.new(**d) }
60
+ end
61
+
62
+ # @param ret [Hash]
63
+ def relations_hash_to_bib(ret)
64
+ super
65
+ ret[:relation] &&= ret[:relation].map do |r|
66
+ RelatonBipm::DocumentRelation.new(**r)
84
67
  end
68
+ end
85
69
 
86
- def committee_variants(cmt)
87
- RelatonBib.array(cmt[:variants]).each_with_object([]) do |v, a|
88
- c = v[:content] || (ac = acronyms[cmt[:acronym]]) && ac[v[:language]]
89
- a << RelatonBib::LocalizedString.new(c, v[:language], v[:script]) if c
70
+ # @param ret [Hash]
71
+ def editorialgroup_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
72
+ return unless ret[:editorialgroup]
73
+
74
+ cmt = ret[:editorialgroup][:committee].map do |c|
75
+ if (vars = committee_variants c).any?
76
+ content = RelatonBib::LocalizedString.new vars
77
+ Committee.new acronym: c[:acronym], content: content
78
+ else
79
+ Committee.new(**c)
90
80
  end
91
81
  end
92
-
93
- def acronyms
94
- @@acronyms ||= YAML.load_file File.join __dir__, "acronyms.yaml"
82
+ wg = RelatonBib.array(ret[:editorialgroup][:workgroup]).map do |w|
83
+ w.is_a?(Hash) ? WorkGroup.new(**w) : WorkGroup.new(content: w)
95
84
  end
85
+ ret[:editorialgroup] = EditorialGroup.new committee: cmt, workgroup: wg
86
+ end
96
87
 
97
- # @param ret [Hash]
98
- def structuredidentifier_hash_to_bib(ret)
99
- ret[:structuredidentifier] &&= StructuredIdentifier.new(
100
- **ret[:structuredidentifier],
101
- )
88
+ def committee_variants(cmt)
89
+ RelatonBib.array(cmt[:variants]).each_with_object([]) do |v, a|
90
+ c = v[:content] || (ac = acronyms[cmt[:acronym]]) && ac[v[:language]]
91
+ a << RelatonBib::LocalizedString.new(c, v[:language], v[:script]) if c
102
92
  end
103
93
  end
94
+
95
+ def acronyms
96
+ @@acronyms ||= YAML.load_file File.join __dir__, "acronyms.yaml"
97
+ end
98
+
99
+ # @param ret [Hash]
100
+ def structuredidentifier_hash_to_bib(ret)
101
+ ret[:structuredidentifier] &&= StructuredIdentifier.new(
102
+ **ret[:structuredidentifier],
103
+ )
104
+ end
105
+
106
+ def create_doctype(**args)
107
+ DocumentType.new(**args)
108
+ end
104
109
  end
105
110
  end
@@ -14,7 +14,7 @@ module RelatonBipm
14
14
  rule(:lang) { comma >> space? >> match["A-Z"].repeat(1, 2).as(:lang) }
15
15
  rule(:lang?) { lang.maybe }
16
16
 
17
- rule(:numdash) { match["0-9-"].repeat(1).as(:number) }
17
+ rule(:numdash) { match["A-Z0-9-"].repeat(1).as(:number) }
18
18
  rule(:number) { numdash >> space? }
19
19
  rule(:number?) { number.maybe }
20
20
  rule(:num_suff) { numdash >> match["a-z"].repeat(1, 2) >> space }
@@ -47,7 +47,11 @@ module RelatonBipm
47
47
 
48
48
  rule(:metrologia) { str("Metrologia").as(:group) >> (space >> match["a-zA-Z0-9\s"].repeat(1).as(:number)).maybe }
49
49
 
50
- rule(:result) { outcome | brochure | metrologia }
50
+ rule(:corr) { space >> str("Corrigendum").as(:corr) }
51
+ rule(:corr?) { corr.maybe }
52
+ rule(:jcgm) { group >> space >> numdash >> (str(":") >> year).maybe >> corr? }
53
+
54
+ rule(:result) { outcome | brochure | metrologia | jcgm }
51
55
 
52
56
  root :result
53
57
  end
@@ -93,7 +97,7 @@ module RelatonBipm
93
97
  hash = to_hash
94
98
  hash.delete(:number) if other_hash[:number].nil? && hash[:number] == "1" and hash[:year]
95
99
  other_hash.delete(:number) if hash[:number].nil? && other_hash[:number] == "1"
96
- hash.delete(:year) unless other_hash[:year]
100
+ # hash.delete(:year) unless other_hash[:year]
97
101
  other_hash.delete(:year) unless hash[:year]
98
102
  hash.delete(:lang) unless other_hash[:lang]
99
103
  other_hash.delete(:lang) unless hash[:lang]
@@ -124,6 +128,7 @@ module RelatonBipm
124
128
  norm_num = normalized_number(src)
125
129
  hash[:number] = norm_num unless norm_num.nil? || norm_num.empty?
126
130
  hash[:year] = src[:year].to_s if src[:year]
131
+ hash[:corr] = true if src[:corr]
127
132
  hash[:lang] = src[:lang].to_s if src[:lang]
128
133
  hash
129
134
  end
@@ -316,7 +316,9 @@ module RelatonBipm
316
316
  "article"
317
317
  end
318
318
 
319
- alias_method :parse_doctype, :parse_type
319
+ def parse_doctype
320
+ DocumentType.new type: "article"
321
+ end
320
322
  end
321
323
  end
322
324
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.16.5".freeze
2
+ VERSION = "1.17.0".freeze
3
3
  end
data/lib/relaton_bipm.rb CHANGED
@@ -7,6 +7,7 @@ require "relaton_bipm/config"
7
7
  require "relaton_bipm/util"
8
8
  require "relaton_bipm/id_parser"
9
9
  require "relaton_bipm/version"
10
+ require "relaton_bipm/document_type"
10
11
  require "relaton_bipm/editorial_group"
11
12
  require "relaton_bipm/committee"
12
13
  require "relaton_bipm/workgroup"
data/relaton_bipm.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
35
35
  spec.add_dependency "faraday", "~> 2.7.0"
36
36
  spec.add_dependency "mechanize", "~> 2.8.0"
37
37
  spec.add_dependency "parslet", "~> 2.0.0"
38
- spec.add_dependency "relaton-bib", "~> 1.16.0"
38
+ spec.add_dependency "relaton-bib", "~> 1.17.0"
39
39
  spec.add_dependency "relaton-index", "~> 0.2.2"
40
40
  spec.add_dependency "rubyzip", "~> 2.3.0"
41
41
  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.16.5
4
+ version: 1.17.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: 2023-11-08 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.16.0
61
+ version: 1.17.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.16.0
68
+ version: 1.17.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: relaton-index
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,7 @@ files:
131
131
  - lib/relaton_bipm/data_fetcher.rb
132
132
  - lib/relaton_bipm/data_outcomes_parser.rb
133
133
  - lib/relaton_bipm/document_relation.rb
134
+ - lib/relaton_bipm/document_type.rb
134
135
  - lib/relaton_bipm/editorial_group.rb
135
136
  - lib/relaton_bipm/hash_converter.rb
136
137
  - lib/relaton_bipm/id_parser.rb