relaton-bipm 1.13.2 → 1.13.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: 8684961db2e3b70deffa9ba3a943ac4ce4990edd0b00a0e5311c0d92ca61f344
4
- data.tar.gz: 4d585b8f37043d19e14bf2bf9f1a9ee32186978f86db61a9fa2aade824171133
3
+ metadata.gz: 44b5e29b765a1c5abb4e7d1e30f25924a3aba14462c654da9926e91b4c60c040
4
+ data.tar.gz: 772df92aa9bfd854f0228bfeaaf0edcda9665a5cf10237ff5bca89a9276f285e
5
5
  SHA512:
6
- metadata.gz: f426fa79bd1c71061fe411ff764435817c49d0a9c9e56333304ae54390a6f20384dbdaf40fba7e19062c3618ca212fbd2d21dc3180ee461f75d0d2f5d6c6ffe3
7
- data.tar.gz: 0b7b9707e8cd16955591edd14592bc59550cb0efb21cfcdceacd5733a471af0d4b8ee4ec39138e8ae6653f22e006144195e1ab8e1a685e95199f2f6408ebdee5
6
+ metadata.gz: 041beb9bc400b47198472a9ffab00427f3d08bae04121360527d8810354406a67602f68daff60e3ee16e9e195d37d33d0ce968f20b96f4005a5796d1e6caf200
7
+ data.tar.gz: e509099ba765739a5792f9f56ba58e6e93beb1e84b7f31e0f9cec09e95d34e70b4bd099a427640d5bab4800f138587930dd11a446f88149cb9f0004d14d2a29a
@@ -0,0 +1,22 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ push:
14
+ tags: [ v* ]
15
+
16
+ jobs:
17
+ release:
18
+ uses: relaton/support/.github/workflows/release.yml@master
19
+ with:
20
+ next_version: ${{ github.event.inputs.next_version }}
21
+ secrets:
22
+ rubygems-api-key: ${{ secrets.RELATON_CI_RUBYGEMS_API_KEY }}
data/README.adoc CHANGED
@@ -58,6 +58,7 @@ Allowed document names are:
58
58
  - SI MEP Mol1
59
59
  - SI MEP S1
60
60
  - SI Brochure
61
+ - SI Brochure, Appendix 4
61
62
 
62
63
  ==== Reference structire for Metrologia documents
63
64
 
@@ -25,6 +25,7 @@ module RelatonBipm
25
25
  end
26
26
 
27
27
  warn("[relaton-bipm] (\"#{text}\") found #{item.docidentifier[0].id}")
28
+ item.fetched = Date.today.to_s
28
29
  item
29
30
  rescue Mechanize::ResponseCodeError => e
30
31
  raise RelatonBib::RequestError, e.message unless e.response_code == "404"
@@ -226,8 +227,8 @@ module RelatonBipm
226
227
  link = rsp.at("//div[@class='indexer'][.='#{art}']/../div/a")
227
228
  unless link
228
229
  arts = rsp.xpath("//div[@class='indexer']").map(&:text)
229
- warn "[relaton-bipm] Page #{art} not found in \"BIPM Metrologia #{vol} #{ish}\" issue."
230
- warn "[relaton-bipm] Availabe pages in the issue are: (#{arts.join(', ')})"
230
+ warn "[relaton-bipm] No article is available at the specified start page \"#{art}\" in issue \"BIPM Metrologia #{vol} #{ish}\"."
231
+ warn "[relaton-bipm] Available articles in the issue start at the following pages: (#{arts.join(', ')})"
231
232
  return
232
233
  end
233
234
 
@@ -239,7 +240,7 @@ module RelatonBipm
239
240
  # @param ish [String]
240
241
  # @param agent [Mechanize]
241
242
  # @return [RelatonBipm::BipmBibliographicItem]
242
- def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize
243
+ def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
243
244
  rsp = agent.get path
244
245
  check_response rsp
245
246
  url = rsp.uri
@@ -247,16 +248,19 @@ module RelatonBipm
247
248
  rsp = agent.get bib
248
249
  check_response rsp
249
250
  bt = BibTeX.parse(rsp.body).first
250
- bibitem(docid: btdocid(bt), title: titles(bt.title.to_s), abstract: btabstract(bt), doctype: bt.type.to_s,
251
- link: btlink(bt, url), date: btdate(bt), contributor: btcontrib(bt), series: series,
252
- extent: btextent(vol, ish, bt))
251
+ bibitem(
252
+ docid: btdocid(bt), title: titles(bt.title.to_s), date: btdate(bt),
253
+ abstract: btabstract(bt), doctype: bt.type.to_s, series: series,
254
+ link: btlink(bt, url), contributor: btcontrib(bt),
255
+ extent: btextent(vol, ish, bt.pages.to_s)
256
+ )
253
257
  end
254
258
 
255
259
  # @param args [Hash]
256
260
  # @return [RelatonBipm::BipmBibliographicItem]
257
261
  def bibitem(**args)
258
262
  BipmBibliographicItem.new(
259
- fetched: Date.today.to_s, type: "standard", language: ["en"], script: ["Latn"], **args,
263
+ fetched: Date.today.to_s, type: "article", language: ["en"], script: ["Latn"], **args,
260
264
  )
261
265
  end
262
266
 
@@ -269,7 +273,10 @@ module RelatonBipm
269
273
  # @return [Array<RelatonBib::DocumentIdentifier>]
270
274
  def btdocid(bibtex)
271
275
  id = "#{bibtex.journal} #{bibtex.volume} #{bibtex.number} #{bibtex.pages.match(/^\d+/)}"
272
- [RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id)]
276
+ [
277
+ RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id, primary: true),
278
+ RelatonBib::DocumentIdentifier.new(type: "DOI", id: bibtex.doi),
279
+ ]
273
280
  end
274
281
 
275
282
  # @param bibtex [BibTeX::Entry]
@@ -309,14 +316,17 @@ module RelatonBipm
309
316
  ]
310
317
  end
311
318
 
312
- # @param vol [String]
313
- # @param ish [String]
314
- # @param bibtex [BibTeX::Entry]
319
+ #
320
+ # @param vol [String] volume
321
+ # @param ish [String] issue
322
+ # @param pgs [String] pages
323
+ #
315
324
  # @return [Array<RelatonBib::BibItemLocality>]
316
- def btextent(vol, ish = nil, bibtex = nil)
317
- ext = [RelatonBib::BibItemLocality.new("volume", vol)]
318
- ext << RelatonBib::BibItemLocality.new("issue", ish) if ish
319
- ext << RelatonBib::BibItemLocality.new("page", *bibtex.pages.split("--")) if bibtex
325
+ #
326
+ def btextent(vol, ish = nil, pgs = nil)
327
+ ext = [RelatonBib::Locality.new("volume", vol)]
328
+ ext << RelatonBib::Locality.new("issue", ish) if ish
329
+ ext << RelatonBib::Locality.new("page", *pgs.split("--")) if pgs
320
330
  ext
321
331
  end
322
332
 
@@ -342,7 +352,7 @@ module RelatonBipm
342
352
  if rsp.code == "302"
343
353
  warn "[relaton-bipm] This source employs anti-DDoS measures that unfortunately affects automated requests."
344
354
  warn "[relaton-bipm] Please visit this link in your browser to resolve the CAPTCHA, then retry: #{rsp.uri}"
345
- warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
355
+ # warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
346
356
  raise RelatonBib::RequestError, "cannot access #{rsp.uri}"
347
357
  elsif rsp.code != "200"
348
358
  warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
@@ -68,7 +68,6 @@ module RelatonBipm
68
68
  doc = docstd.at "/bibdata"
69
69
  hash1 = RelatonBipm::XMLParser.from_xml(doc.to_xml).to_hash
70
70
  fix_si_brochure_id hash1
71
- hash1["fetched"] = Date.today.to_s
72
71
  outfile = File.join @output, File.basename(f).sub(/(?:-(?:en|fr))?\.rxl$/, ".yaml")
73
72
  @index[[hash1["docnumber"] || File.basename(outfile, ".yaml")]] = outfile
74
73
  hash = if File.exist? outfile
@@ -178,7 +177,7 @@ module RelatonBipm
178
177
  file = "#{num}.yaml"
179
178
  path = File.join dir, file
180
179
  link = "https://raw.githubusercontent.com/relaton/relaton-data-bipm/master/#{path}"
181
- hash = bibitem type: type, en: en_md, fr: fr_md, id: id, num: num, src: src, pdf: en["pdf"]
180
+ hash = bibitem body: body, type: type, en: en_md, fr: fr_md, id: id, num: num, src: src, pdf: en["pdf"]
182
181
  if @files.include?(path) && part
183
182
  add_part hash, part
184
183
  item = RelatonBipm::BipmBibliographicItem.new(**hash)
@@ -190,7 +189,7 @@ module RelatonBipm
190
189
  elsif part
191
190
  hash[:title].each { |t| t[:content] = t[:content].sub(/\s\(.+\)$/, "") }
192
191
  hash[:link] = [{ type: "src", content: link }]
193
- h = bibitem type: type, en: en_md, fr: fr_md, id: id, num: num, src: src, pdf: en["pdf"]
192
+ h = bibitem body: body, type: type, en: en_md, fr: fr_md, id: id, num: num, src: src, pdf: en["pdf"]
194
193
  add_part h, part
195
194
  part_item = RelatonBipm::BipmBibliographicItem.new(**h)
196
195
  part_item_path = File.join dir, "#{num}-#{part}.yaml"
@@ -218,7 +217,10 @@ module RelatonBipm
218
217
  #
219
218
  def fetch_resolution(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
220
219
  args[:en]["resolutions"].each.with_index do |r, i| # rubocop:disable Metrics/BlockLength
221
- hash = { fetched: Date.today.to_s, title: [], doctype: r["type"] }
220
+ hash = {
221
+ type: "proceedings", title: [],
222
+ doctype: r["type"], place: [RelatonBib::Place.new(city: "Paris")]
223
+ }
222
224
  hash[:title] << title(r["title"], "en") if r["title"]
223
225
  fr_resolution = args[:fr]["resolutions"].fetch(i, nil)
224
226
  if fr_resolution
@@ -249,10 +251,7 @@ module RelatonBipm
249
251
  hash[:link] << { type: "pdf", content: r["reference"] } if r["reference"]
250
252
  hash[:language] = %w[en fr]
251
253
  hash[:script] = ["Latn"]
252
- hash[:contributor] = [{
253
- entity: { url: "www.bipm.org", name: "Bureau International des Poids et Mesures", abbreviation: "BIPM" },
254
- role: [{ type: "publisher" }],
255
- }]
254
+ hash[:contributor] = contributors date, args[:body]
256
255
  hash[:structuredidentifier] = RelatonBipm::StructuredIdentifier.new docnumber: num
257
256
  item = RelatonBipm::BipmBibliographicItem.new(**hash)
258
257
  file = year
@@ -266,6 +265,39 @@ module RelatonBipm
266
265
  end
267
266
  end
268
267
 
268
+ def contributors(date, body) # rubocop:disable Metrics/MethodLength
269
+ if body == "CCTF" && Date.parse(date).year < 1999
270
+ authors = [{
271
+ name: [
272
+ { content: "Consultative Committee for the Definition of the Second",
273
+ language: "en", script: "Latn" },
274
+ { content: "Comité Consultatif pour la Définition de la Seconde",
275
+ language: "fr", script: "Latn" },
276
+ ],
277
+ abbreviation: { content: "CCDS", language: ["en", "fr"], script: "Latn" },
278
+ }]
279
+ elsif body == "CCTF"
280
+ authors = [{
281
+ name: [
282
+ { content: "Consultative Committee for Time and Frequency",
283
+ language: "en", script: "Latn" },
284
+ { content: "Comité consultatif du temps et des fréquences",
285
+ language: "fr", script: "Latn" },
286
+ ],
287
+ abbreviation: { content: body, language: ["en", "fr"], script: "Latn" },
288
+ }]
289
+ else authors = []
290
+ end
291
+ authors.reduce(
292
+ [{ entity: {
293
+ url: "www.bipm.org",
294
+ name: "Bureau International des Poids et Mesures",
295
+ abbreviation: "BIPM",
296
+ },
297
+ role: [{ type: "publisher" }] }],
298
+ ) { |a, e| a << { entity: e, role: [{ type: "author" }] } }
299
+ end
300
+
269
301
  def title(content, language)
270
302
  { content: content, language: language, script: "Latn" }
271
303
  end
@@ -300,7 +332,8 @@ module RelatonBipm
300
332
  # @return [Hash] Hash of BIPM meeting/resolution
301
333
  #
302
334
  def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
303
- hash = { title: [], doctype: args[:type], fetched: Date.today.to_s }
335
+ hash = { title: [], type: "proceedings", doctype: args[:type],
336
+ place: [RelatonBib::Place.new(city: "Paris")] }
304
337
  hash[:title] << title(args[:en]["title"], "en") if args[:en]["title"]
305
338
  hash[:title] << title(args[:fr]["title"], "fr") if args[:fr]["title"]
306
339
  hash[:date] = [{ type: "published", on: args[:en]["date"] }]
@@ -316,10 +349,7 @@ module RelatonBipm
316
349
  hash[:link] += args[:src] if args[:src]&.any?
317
350
  hash[:language] = %w[en fr]
318
351
  hash[:script] = ["Latn"]
319
- hash[:contributor] = [{
320
- entity: { url: "www.bipm.org", name: "Bureau International des Poids et Mesures", abbreviation: "BIPM" },
321
- role: [{ type: "publisher" }],
322
- }]
352
+ hash[:contributor] = contributors args[:en]["date"], args[:body]
323
353
  hash[:structuredidentifier] = RelatonBipm::StructuredIdentifier.new docnumber: args[:num]
324
354
  hash
325
355
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.13.2".freeze
2
+ VERSION = "1.13.5".freeze
3
3
  end
@@ -23,18 +23,18 @@ module RelatonBipm
23
23
  BipmBibliographicItem.new(**item_hash)
24
24
  end
25
25
 
26
- def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
27
- item.xpath("./date").reduce([]) do |a, d|
28
- type = d[:type].to_s.empty? ? "published" : d[:type]
29
- if (on = d.at("on"))
30
- a << BibliographicDate.new(type: type, on: on.text,
31
- to: d.at("to")&.text)
32
- elsif (from = d.at("from"))
33
- a << BibliographicDate.new(type: type, from: from.text,
34
- to: d.at("to")&.text)
35
- end
36
- end
37
- end
26
+ # def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
27
+ # item.xpath("./date").reduce([]) do |a, d|
28
+ # type = d[:type].to_s.empty? ? "published" : d[:type]
29
+ # if (on = d.at("on"))
30
+ # a << BibliographicDate.new(type: type, on: on.text,
31
+ # to: d.at("to")&.text)
32
+ # elsif (from = d.at("from"))
33
+ # a << BibliographicDate.new(type: type, from: from.text,
34
+ # to: d.at("to")&.text)
35
+ # end
36
+ # end
37
+ # end
38
38
 
39
39
  # @param item [Nokogiri::XML::Element]
40
40
  # @param klass [RelatonBipm::DocumentRelation.class]
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.2
4
+ version: 1.13.5
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-08-31 00:00:00.000000000 Z
11
+ date: 2022-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -187,6 +187,7 @@ extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
189
  - ".github/workflows/rake.yml"
190
+ - ".github/workflows/release.yml"
190
191
  - ".gitignore"
191
192
  - ".rspec"
192
193
  - ".rubocop.yml"