relaton-bipm 1.16.6 → 1.17.1

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: fed200c28077ec8e08f755b1185ec918797d15bf6937b884f207efd95837e230
4
- data.tar.gz: e252b80a27cf21e0fd9c66af2bec464eea8cc578b6da66b4c51316b707aa4b39
3
+ metadata.gz: 4b1fb15e763da98895e7053e9fc0e9c8d171e479e4b89e6a0353dd1399955a0d
4
+ data.tar.gz: ac9db3bb0fc7bccebf5eb8e11cc392b98a8f16514e07aa5436b3817e4b54253d
5
5
  SHA512:
6
- metadata.gz: 7d73f4d65055a47285532d0bcc0f812e58fa75a0790fc92a1e396d40b444732a84192e9f81467246552c61d0ae780a6449333186417f2a0154c756ae555e5097
7
- data.tar.gz: 7415e3f9f5bb4cacaa3e28f79b25a08a22814a6de7c52e5effd21f53632c59bcce41a6d4ef52a84169ad996efdd8e82687c7404f32cd22b199ee50a6cfbd77f8
6
+ metadata.gz: d2b145a2a5facc0782ad9600c7240357e80367f191205fe5e2e40a0e2b1c36019cb638d77130b17183cca67b2f35ab1868a30aa097913dbcc1c83e2598cdf127
7
+ data.tar.gz: 2dd15163fcfb619fa3c5b63705cdce127d13d17799e120d5a4e506747042d52133929c92e8f2a5e40012bb8a2a052928ca2f51021b6d37a19adc28c3698e7d80
@@ -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>
@@ -898,44 +914,47 @@
898
914
  -->
899
915
  <define name="image">
900
916
  <element name="image">
901
- <attribute name="id">
902
- <data type="ID"/>
917
+ <ref name="Image"/>
918
+ </element>
919
+ </define>
920
+ <define name="Image">
921
+ <attribute name="id">
922
+ <data type="ID"/>
923
+ </attribute>
924
+ <attribute name="src">
925
+ <data type="anyURI"/>
926
+ </attribute>
927
+ <attribute name="mimetype"/>
928
+ <optional>
929
+ <attribute name="filename"/>
930
+ </optional>
931
+ <optional>
932
+ <attribute name="width">
933
+ <choice>
934
+ <data type="int"/>
935
+ <value>auto</value>
936
+ </choice>
903
937
  </attribute>
904
- <attribute name="src">
938
+ </optional>
939
+ <optional>
940
+ <attribute name="height">
941
+ <choice>
942
+ <data type="int"/>
943
+ <value>auto</value>
944
+ </choice>
945
+ </attribute>
946
+ </optional>
947
+ <optional>
948
+ <attribute name="alt"/>
949
+ </optional>
950
+ <optional>
951
+ <attribute name="title"/>
952
+ </optional>
953
+ <optional>
954
+ <attribute name="longdesc">
905
955
  <data type="anyURI"/>
906
956
  </attribute>
907
- <attribute name="mimetype"/>
908
- <optional>
909
- <attribute name="filename"/>
910
- </optional>
911
- <optional>
912
- <attribute name="width">
913
- <choice>
914
- <data type="int"/>
915
- <value>auto</value>
916
- </choice>
917
- </attribute>
918
- </optional>
919
- <optional>
920
- <attribute name="height">
921
- <choice>
922
- <data type="int"/>
923
- <value>auto</value>
924
- </choice>
925
- </attribute>
926
- </optional>
927
- <optional>
928
- <attribute name="alt"/>
929
- </optional>
930
- <optional>
931
- <attribute name="title"/>
932
- </optional>
933
- <optional>
934
- <attribute name="longdesc">
935
- <data type="anyURI"/>
936
- </attribute>
937
- </optional>
938
- </element>
957
+ </optional>
939
958
  </define>
940
959
  <define name="video">
941
960
  <element name="video">
data/grammars/biblio.rng CHANGED
@@ -348,6 +348,9 @@
348
348
  <zeroOrMore>
349
349
  <ref name="contact"/>
350
350
  </zeroOrMore>
351
+ <optional>
352
+ <ref name="logo"/>
353
+ </optional>
351
354
  </element>
352
355
  </define>
353
356
  <define name="orgname">
@@ -366,6 +369,21 @@
366
369
  </choice>
367
370
  </element>
368
371
  </define>
372
+ <define name="logo">
373
+ <element name="logo">
374
+ <ref name="image"/>
375
+ </element>
376
+ </define>
377
+ <define name="depiction">
378
+ <element name="depiction">
379
+ <optional>
380
+ <attribute name="scope"/>
381
+ </optional>
382
+ <zeroOrMore>
383
+ <ref name="image"/>
384
+ </zeroOrMore>
385
+ </element>
386
+ </define>
369
387
  <define name="NameWithVariants">
370
388
  <element name="primary">
371
389
  <ref name="LocalizedString"/>
@@ -752,6 +770,9 @@
752
770
  <optional>
753
771
  <ref name="validity"/>
754
772
  </optional>
773
+ <optional>
774
+ <ref name="depiction"/>
775
+ </optional>
755
776
  </define>
756
777
  <define name="ReducedBibliographicItem">
757
778
  <optional>
@@ -942,6 +963,7 @@
942
963
  <value>obsoleted</value>
943
964
  <value>confirmed</value>
944
965
  <value>updated</value>
966
+ <value>corrected</value>
945
967
  <value>issued</value>
946
968
  <value>transmitted</value>
947
969
  <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
@@ -50,7 +50,8 @@ module RelatonBipm
50
50
  rows = index.search { |r| ref_id == r[:id] }
51
51
  return unless rows.any?
52
52
 
53
- url = "#{GH_ENDPOINT}#{rows.first[:file]}"
53
+ row = rows.sort_by { |r| r[:id][:year] }.last
54
+ url = "#{GH_ENDPOINT}#{row[:file]}"
54
55
  resp = Mechanize.new.get url
55
56
  return unless resp.code == "200"
56
57
 
@@ -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
@@ -94,9 +94,9 @@ module RelatonBipm
94
94
  #
95
95
  def ==(other) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
96
96
  other_hash = other.is_a?(Id) ? other.to_hash : normalize_hash(other)
97
- hash = to_hash
98
- hash.delete(:number) if other_hash[:number].nil? && hash[:number] == "1" and hash[:year]
99
- other_hash.delete(:number) if hash[:number].nil? && other_hash[:number] == "1"
97
+ hash = to_hash.dup
98
+ hash.delete(:number) if other_hash[:number].nil? && hash[:number] == "1" && hash[:year]
99
+ other_hash.delete(:number) if hash[:number].nil? && other_hash[:number] == "1" && other_hash[:year]
100
100
  # hash.delete(:year) unless other_hash[:year]
101
101
  other_hash.delete(:year) unless hash[:year]
102
102
  hash.delete(:lang) unless other_hash[:lang]
@@ -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.6".freeze
2
+ VERSION = "1.17.1".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"
@@ -27,7 +28,7 @@ require "relaton_bipm/rawdata_bipm_metrologia/article_parser"
27
28
  module RelatonBipm
28
29
  class Error < StandardError; end
29
30
 
30
- # Returns hash of XML reammar
31
+ # Returns hash of gems versions used to generate the data model.
31
32
  # @return [String]
32
33
  def grammar_hash
33
34
  # gem_path = File.expand_path "..", __dir__
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.6
4
+ version: 1.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-12 00:00:00.000000000 Z
11
+ date: 2023-12-28 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