relaton-bipm 1.13.12 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/biblio.rng CHANGED
@@ -33,9 +33,10 @@
33
33
  <param name="pattern">([\+\-]?\d{4})((-?)((0[1-9]|1[0-2])((-?)([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6]))))?</param>
34
34
  </data>
35
35
  </define>
36
- <start>
37
- <ref name="bibitem"/>
38
- </start>
36
+ <!-- start = bibitem -->
37
+ <define name="BibData">
38
+ <ref name="BibliographicItem"/>
39
+ </define>
39
40
  <define name="status">
40
41
  <element name="status">
41
42
  <ref name="stage"/>
@@ -73,8 +74,14 @@
73
74
  <text/>
74
75
  </element>
75
76
  </define>
76
- <define name="script">
77
+ <define name="locale">
77
78
  <a:documentation>ISO-639</a:documentation>
79
+ <element name="locale">
80
+ <text/>
81
+ </element>
82
+ </define>
83
+ <define name="script">
84
+ <a:documentation>ISO-3166</a:documentation>
78
85
  <element name="script">
79
86
  <text/>
80
87
  </element>
@@ -93,6 +100,9 @@
93
100
  <!-- multiple languages and scripts possible: comma delimit them if so -->
94
101
  <attribute name="language"/>
95
102
  </optional>
103
+ <optional>
104
+ <attribute name="locale"/>
105
+ </optional>
96
106
  <optional>
97
107
  <attribute name="script"/>
98
108
  </optional>
@@ -136,6 +146,9 @@
136
146
  <!-- multiple languages and scripts possible: comma delimit them if so -->
137
147
  <attribute name="language"/>
138
148
  </optional>
149
+ <optional>
150
+ <attribute name="locale"/>
151
+ </optional>
139
152
  <optional>
140
153
  <attribute name="script"/>
141
154
  </optional>
@@ -158,27 +171,30 @@
158
171
  </define>
159
172
  <define name="contributor">
160
173
  <element name="contributor">
161
- <zeroOrMore>
174
+ <oneOrMore>
162
175
  <ref name="role"/>
163
- </zeroOrMore>
176
+ </oneOrMore>
164
177
  <ref name="ContributorInfo"/>
165
178
  </element>
166
179
  </define>
167
180
  <define name="role">
168
181
  <element name="role">
169
- <optional>
170
- <attribute name="type">
171
- <choice>
172
- <value>author</value>
173
- <value>performer</value>
174
- <value>publisher</value>
175
- <value>editor</value>
176
- <value>adapter</value>
177
- <value>translator</value>
178
- <value>distributor</value>
179
- </choice>
180
- </attribute>
181
- </optional>
182
+ <attribute name="type">
183
+ <choice>
184
+ <value>author</value>
185
+ <value>performer</value>
186
+ <value>publisher</value>
187
+ <value>editor</value>
188
+ <value>adapter</value>
189
+ <value>translator</value>
190
+ <value>distributor</value>
191
+ <value>realizer</value>
192
+ <value>owner</value>
193
+ <value>authorizer</value>
194
+ <value>enabler</value>
195
+ <value>subject</value>
196
+ </choice>
197
+ </attribute>
182
198
  <zeroOrMore>
183
199
  <ref name="roledescription"/>
184
200
  </zeroOrMore>
@@ -500,6 +516,17 @@
500
516
  </define>
501
517
  <define name="localityStack">
502
518
  <element name="localityStack">
519
+ <optional>
520
+ <attribute name="connective">
521
+ <choice>
522
+ <value>and</value>
523
+ <value>or</value>
524
+ <value>from</value>
525
+ <value>to</value>
526
+ <value/>
527
+ </choice>
528
+ </attribute>
529
+ </optional>
503
530
  <zeroOrMore>
504
531
  <ref name="locality"/>
505
532
  </zeroOrMore>
@@ -512,6 +539,17 @@
512
539
  </define>
513
540
  <define name="sourceLocalityStack">
514
541
  <element name="sourceLocalityStack">
542
+ <optional>
543
+ <attribute name="connective">
544
+ <choice>
545
+ <value>and</value>
546
+ <value>or</value>
547
+ <value>from</value>
548
+ <value>to</value>
549
+ <value/>
550
+ </choice>
551
+ </attribute>
552
+ </optional>
515
553
  <zeroOrMore>
516
554
  <ref name="sourceLocality"/>
517
555
  </zeroOrMore>
@@ -614,6 +652,9 @@
614
652
  <ref name="BibItemType"/>
615
653
  </attribute>
616
654
  </optional>
655
+ <optional>
656
+ <attribute name="schema-version"/>
657
+ </optional>
617
658
  <optional>
618
659
  <ref name="fetched"/>
619
660
  </optional>
@@ -650,6 +691,9 @@
650
691
  <zeroOrMore>
651
692
  <ref name="language"/>
652
693
  </zeroOrMore>
694
+ <zeroOrMore>
695
+ <ref name="locale"/>
696
+ </zeroOrMore>
653
697
  <zeroOrMore>
654
698
  <ref name="script"/>
655
699
  </zeroOrMore>
@@ -705,6 +749,9 @@
705
749
  <ref name="BibItemType"/>
706
750
  </attribute>
707
751
  </optional>
752
+ <optional>
753
+ <attribute name="schema-version"/>
754
+ </optional>
708
755
  <optional>
709
756
  <ref name="fetched"/>
710
757
  </optional>
@@ -741,6 +788,9 @@
741
788
  <zeroOrMore>
742
789
  <ref name="language"/>
743
790
  </zeroOrMore>
791
+ <zeroOrMore>
792
+ <ref name="locale"/>
793
+ </zeroOrMore>
744
794
  <zeroOrMore>
745
795
  <ref name="script"/>
746
796
  </zeroOrMore>
@@ -857,6 +907,9 @@
857
907
  <optional>
858
908
  <attribute name="language"/>
859
909
  </optional>
910
+ <optional>
911
+ <attribute name="locale"/>
912
+ </optional>
860
913
  <optional>
861
914
  <attribute name="script"/>
862
915
  </optional>
@@ -937,6 +990,9 @@
937
990
  <optional>
938
991
  <attribute name="language"/>
939
992
  </optional>
993
+ <optional>
994
+ <attribute name="locale"/>
995
+ </optional>
940
996
  <optional>
941
997
  <attribute name="script"/>
942
998
  </optional>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <include href="basicdoc.rng"/>
4
+ <include href="relaton-bipm.rng"/>
5
+ <start>
6
+ <choice>
7
+ <ref name="bibitem"/>
8
+ <ref name="bibdata"/>
9
+ </choice>
10
+ </start>
11
+ </grammar>
@@ -0,0 +1,138 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <include href="biblio-standoc.rng">
4
+ <define name="DocumentType">
5
+ <choice>
6
+ <value>brochure</value>
7
+ <value>mise-en-pratique</value>
8
+ <value>rapport</value>
9
+ <value>monographie</value>
10
+ <value>guide</value>
11
+ <value>meeting-report</value>
12
+ <value>technical-report</value>
13
+ <value>working-party-note</value>
14
+ <value>strategy</value>
15
+ <value>cipm-mra</value>
16
+ <value>resolution</value>
17
+ </choice>
18
+ </define>
19
+ <define name="editorialgroup">
20
+ <element name="editorialgroup">
21
+ <oneOrMore>
22
+ <ref name="committee"/>
23
+ </oneOrMore>
24
+ <zeroOrMore>
25
+ <ref name="workgroup"/>
26
+ </zeroOrMore>
27
+ </element>
28
+ </define>
29
+ <define name="structuredidentifier">
30
+ <element name="structuredidentifier">
31
+ <element name="docnumber">
32
+ <text/>
33
+ </element>
34
+ <optional>
35
+ <element name="part">
36
+ <text/>
37
+ </element>
38
+ </optional>
39
+ <optional>
40
+ <element name="appendix">
41
+ <text/>
42
+ </element>
43
+ </optional>
44
+ </element>
45
+ </define>
46
+ <define name="BibDataExtensionType">
47
+ <optional>
48
+ <attribute name="schema-version"/>
49
+ </optional>
50
+ <optional>
51
+ <ref name="doctype"/>
52
+ </optional>
53
+ <optional>
54
+ <ref name="docsubtype"/>
55
+ </optional>
56
+ <ref name="editorialgroup"/>
57
+ <optional>
58
+ <ref name="comment-period"/>
59
+ </optional>
60
+ <optional>
61
+ <ref name="si-aspect"/>
62
+ </optional>
63
+ <optional>
64
+ <ref name="meeting-note"/>
65
+ </optional>
66
+ <ref name="structuredidentifier"/>
67
+ </define>
68
+ </include>
69
+ <define name="comment-period">
70
+ <element name="comment-period">
71
+ <element name="from">
72
+ <ref name="ISO8601Date"/>
73
+ </element>
74
+ <element name="to">
75
+ <ref name="ISO8601Date"/>
76
+ </element>
77
+ </element>
78
+ </define>
79
+ <define name="si-aspect">
80
+ <element name="si-aspect">
81
+ <choice>
82
+ <value>A_e_deltanu</value>
83
+ <value>A_e</value>
84
+ <value>cd_Kcd_h_deltanu</value>
85
+ <value>cd_Kcd</value>
86
+ <value>full</value>
87
+ <value>K_k_deltanu</value>
88
+ <value>K_k</value>
89
+ <value>kg_h_c_deltanu</value>
90
+ <value>kg_h</value>
91
+ <value>m_c_deltanu</value>
92
+ <value>m_c</value>
93
+ <value>mol_NA</value>
94
+ <value>s_deltanu</value>
95
+ </choice>
96
+ </element>
97
+ </define>
98
+ <define name="committee">
99
+ <element name="committee">
100
+ <attribute name="acronym">
101
+ <choice>
102
+ <value>CGPM</value>
103
+ <value>CIPM</value>
104
+ <value>BIPM</value>
105
+ <value>CCAUV</value>
106
+ <value>CCEM</value>
107
+ <value>CCL</value>
108
+ <value>CCM</value>
109
+ <value>CCPR</value>
110
+ <value>CCQM</value>
111
+ <value>CCRI</value>
112
+ <value>CCT</value>
113
+ <value>CCTF</value>
114
+ <value>CCU</value>
115
+ <value>CCL-CCTF-WGFS</value>
116
+ <value>JCGM</value>
117
+ <value>JCRB</value>
118
+ <value>JCTLM</value>
119
+ <value>INetQI</value>
120
+ </choice>
121
+ </attribute>
122
+ <ref name="LocalizedString"/>
123
+ </element>
124
+ </define>
125
+ <define name="workgroup">
126
+ <element name="workgroup">
127
+ <optional>
128
+ <attribute name="acronym"/>
129
+ </optional>
130
+ <text/>
131
+ </element>
132
+ </define>
133
+ <define name="meeting-note">
134
+ <element name="meeting-note">
135
+ <text/>
136
+ </element>
137
+ </define>
138
+ </grammar>
@@ -42,6 +42,15 @@ module RelatonBipm
42
42
  super
43
43
  end
44
44
 
45
+ #
46
+ # Fetch flavour schema version
47
+ #
48
+ # @return [String] flavour schema versio
49
+ #
50
+ def ext_schema
51
+ @ext_schema ||= schema_versions["relaton-model-bipm"]
52
+ end
53
+
45
54
  # @param hash [Hash]
46
55
  # @return [RelatonBipm::BipmBibliographicItem]
47
56
  def self.from_hash(hash)
@@ -59,7 +68,7 @@ module RelatonBipm
59
68
  if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
60
69
  si_aspect || comment_period ||
61
70
  structuredidentifier)
62
- b.ext do
71
+ ext = b.ext do
63
72
  b.doctype doctype if doctype
64
73
  editorialgroup&.to_xml b
65
74
  comment_period&.to_xml b
@@ -67,12 +76,19 @@ module RelatonBipm
67
76
  b.send :"meeting-note", meeting_note if meeting_note
68
77
  structuredidentifier&.to_xml b
69
78
  end
79
+ ext["schema-version"] = ext_schema unless opts[:embedded]
70
80
  end
71
81
  end
72
82
  end
73
83
 
74
- # @return [Hash]
75
- def to_hash
84
+ #
85
+ # Rnder document as Hash
86
+ #
87
+ # @param embedded [Boolean] treu if embedded in another document
88
+ #
89
+ # @return [Hash] document as Hash
90
+ #
91
+ def to_hash(embedded: false)
76
92
  hash = super
77
93
  hash["comment_period"] = comment_period.to_hash if comment_period
78
94
  hash["si_aspect"] = si_aspect if si_aspect
@@ -66,7 +66,7 @@ module RelatonBipm
66
66
  return unless resp.code == "200"
67
67
 
68
68
  yaml = RelatonBib.parse_yaml resp.body, [Date]
69
- yaml["fetched"] = Date.today.to_s
69
+ # yaml["fetched"] = Date.today.to_s
70
70
  bib_hash = HashConverter.hash_to_bib yaml
71
71
  BipmBibliographicItem.new(**bib_hash)
72
72
  end
@@ -264,7 +264,7 @@ module RelatonBipm
264
264
  # @return [RelatonBipm::BipmBibliographicItem]
265
265
  def bibitem(**args)
266
266
  BipmBibliographicItem.new(
267
- fetched: Date.today.to_s, type: "article", language: ["en"], script: ["Latn"], **args,
267
+ type: "article", language: ["en"], script: ["Latn"], **args,
268
268
  )
269
269
  end
270
270
 
@@ -11,8 +11,8 @@ module RelatonBipm
11
11
  def initialize(acronym:, content: nil)
12
12
  acronyms = YAML.load_file File.join(__dir__, "acronyms.yaml")
13
13
  unless acronyms[acronym]
14
- warn "[relaton-bipm] WARNING: invalid acronym: #{acronym}. Allowed "\
15
- "values: #{acronyms.map { |k, _v| k }.join ', '}"
14
+ warn "[relaton-bipm] WARNING: invalid acronym: #{acronym}. Allowed " \
15
+ "values: #{acronyms.map { |k, _v| k }.join ', '}"
16
16
  end
17
17
 
18
18
  @acronym = acronym
@@ -127,15 +127,9 @@ module RelatonBipm
127
127
  type: "proceedings", title: [],
128
128
  doctype: r["type"], place: [RelatonBib::Place.new(city: "Paris")]
129
129
  }
130
- hash[:title] << title(r["title"], "en") if r["title"]
131
130
  fr_r = args[:fr]["resolutions"].fetch(i, nil)
132
- hash[:link] = [{ type: "citation", content: r["url"], language: "en", script: "Latn" }]
133
- if fr_r
134
- hash[:title] << title(fr_r["title"], "fr") if fr_r["title"]
135
- hash[:link] << { type: "citation", content: fr_r["url"], language: "fr", script: "Latn" }
136
- end
137
- hash[:link] += args[:src]
138
- hash[:link] << { type: "pdf", content: r["reference"] } if r["reference"]
131
+ hash[:title] = resolution_title r, fr_r
132
+ hash[:link] = resolution_link r, fr_r, args[:src]
139
133
  date = r["dates"].first.to_s
140
134
  hash[:date] = [{ type: "published", on: date }]
141
135
  num = r["identifier"].to_s # .split("-").last
@@ -163,6 +157,40 @@ module RelatonBipm
163
157
  end
164
158
  end
165
159
 
160
+ #
161
+ # Parse resolution titles
162
+ #
163
+ # @param [Hash] en_r english resolution
164
+ # @param [Hash] fr_r french resolution
165
+ #
166
+ # @return [Array<Hash>] titles
167
+ #
168
+ def resolution_title(en_r, fr_r)
169
+ title = []
170
+ title << create_title(en_r["title"], "en") if en_r["title"] && !en_r["title"].empty?
171
+ title << create_title(fr_r["title"], "fr") if fr_r && fr_r["title"] && !fr_r["title"].empty?
172
+ title
173
+ end
174
+
175
+ #
176
+ # Parse resolution links
177
+ #
178
+ # @param [Hash] en_r english resolution
179
+ # @param [Hash] fr_r french resolution
180
+ # @param [Array<Hash>] src data source links
181
+ #
182
+ # @return [Array<Hash>] links
183
+ #
184
+ def resolution_link(en_r, fr_r, src)
185
+ link = [{ type: "citation", content: en_r["url"], language: "en", script: "Latn" }]
186
+ if fr_r
187
+ link << { type: "citation", content: fr_r["url"], language: "fr", script: "Latn" }
188
+ end
189
+ link += src
190
+ link << { type: "pdf", content: en_r["reference"] } if en_r["reference"]
191
+ link
192
+ end
193
+
166
194
  #
167
195
  # Add item to index
168
196
  #
@@ -276,7 +304,7 @@ module RelatonBipm
276
304
  #
277
305
  # @return [Hash] title
278
306
  #
279
- def title(content, language)
307
+ def create_title(content, language)
280
308
  { content: content, language: language, script: "Latn" }
281
309
  end
282
310
 
@@ -315,8 +343,8 @@ module RelatonBipm
315
343
  docnum = create_docnum args[:body], args[:type], args[:num], args[:en]["date"]
316
344
  hash = { title: [], type: "proceedings", doctype: args[:type],
317
345
  place: [RelatonBib::Place.new(city: "Paris")] }
318
- hash[:title] << title(args[:en]["title"], "en") if args[:en]["title"]
319
- hash[:title] << title(args[:fr]["title"], "fr") if args[:fr]["title"]
346
+ hash[:title] << create_title(args[:en]["title"], "en") if args[:en]["title"]
347
+ hash[:title] << create_title(args[:fr]["title"], "fr") if args[:fr]["title"]
320
348
  hash[:date] = [{ type: "published", on: args[:en]["date"] }]
321
349
  hash[:docid] = create_docids docnum
322
350
  hash[:docnumber] = docnum # .sub(" --", "").sub(/\s\(\d{4}\)/, "")
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.13.12".freeze
2
+ VERSION = "1.14.0".freeze
3
3
  end
data/relaton_bipm.gemspec CHANGED
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
42
42
 
43
43
  spec.add_dependency "faraday", "~> 1.0"
44
44
  spec.add_dependency "mechanize", "~> 2.8.0"
45
- spec.add_dependency "relaton-bib", "~> 1.13.13"
45
+ spec.add_dependency "relaton-bib", "~> 1.14.0"
46
46
  spec.add_dependency "rubyzip", "~> 2.3.0"
47
47
  spec.add_dependency "serrano", "~> 1.0"
48
48
  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.13.12
4
+ version: 1.14.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: 2022-11-13 00:00:00.000000000 Z
11
+ date: 2022-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.13.13
145
+ version: 1.14.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.13.13
152
+ version: 1.14.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rubyzip
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -199,10 +199,10 @@ files:
199
199
  - bin/rspec
200
200
  - bin/setup
201
201
  - grammars/basicdoc.rng
202
+ - grammars/biblio-standoc.rng
202
203
  - grammars/biblio.rng
203
- - grammars/bipm.rng
204
- - grammars/isodoc.rng
205
- - grammars/reqt.rng
204
+ - grammars/relaton-bipm-compile.rng
205
+ - grammars/relaton-bipm.rng
206
206
  - lib/relaton_bipm.rb
207
207
  - lib/relaton_bipm/acronyms.yaml
208
208
  - lib/relaton_bipm/bibliographic_date.rb