relaton-bipm 1.13.0 → 1.13.3

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: 60cc8b3979fffe05b9bc5d554e7bc6b486867a5a32f332b30c8fb30601b49b18
4
- data.tar.gz: 3e20d99bb7d1055b6bedc2ab42a8c9eb074738ee8ebd8d26aba67f824a4935d0
3
+ metadata.gz: 5f3d34a19f9952368e46e0287dc3121b14b2bf2524613caa67e8810b17c0ad44
4
+ data.tar.gz: 024e1fa96b0082b61bc80ddd49fe9e2d906607d538badbb8df5a4e58c5603236
5
5
  SHA512:
6
- metadata.gz: 5a59447492ae98160a67ed7a5f2843f211edbca658a452e685f521a5a940d102ee47d2b7d39265077407ff5a0cf9892f9d9c19e0719ad7c46e304b9f797e4709
7
- data.tar.gz: d0c55fe5d12003e400cc660c6561bcf5878741b955785951089405ee64b4e94bc3067b8181f72b88ec7bb04a27dd93163cf19b289bdd3c3c1ccfff68b85579a1
6
+ metadata.gz: 8948a30ac51fbc1626ad445ffba402a781b7fe931ea0305ed50b1cd82b4d807ed6cfe4cbbbdd28cd133284e14ea5e616cb66160cbef251690b9f657181cc175a
7
+ data.tar.gz: efad783da2ee6f69c42384b7d1b2c198783ddb44e19a95547a6a3d4574bca0af87bb545c130f3835e8fd36e603112fa6ae79c0fb30dd9b3ae36bbf98ba136dbb
@@ -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
@@ -39,35 +39,35 @@ Or install it yourself as:
39
39
 
40
40
  Allowed document names are:
41
41
 
42
- - guide-ccem-ampere-realization
43
- - guide-ccl-metre-realization-1
44
- - guide-ccl-metre-realization-2
45
- - guide-ccl-metre-realization-3
46
- - guide-ccm-kilogram-calibration
47
- - guide-ccm-kilogram-dissemination
48
- - mep-ampere-definition
49
- - mep-candela-definition
50
- - mep-candela-rapport
51
- - mep-kelvin-absolute-uncertainty
52
- - mep-kelvin-absolute
53
- - mep-kelvin-definition
54
- - mep-kelvin-lt-johnson-noise
55
- - mep-kelvin-relative
56
- - mep-kilogram-definition
57
- - mep-metre-definition
58
- - mep-mole-definition
59
- - mep-second-definition
60
- - si-brochure
61
- - sib-a4
42
+ - CCEM-GD-RSI-1
43
+ - CCL-GD-MeP-1
44
+ - CCL-GD-MeP-2
45
+ - CCL-GD-MeP-3
46
+ - CCM-GD-RSI-1
47
+ - CCM-GD-RSI-2
48
+ - SI MEP A1
49
+ - SI MEP Cd1
50
+ - Rapport BIPM-2019/05
51
+ - SI MEP KUPRTM
52
+ - SI MEP KAPRT
53
+ - SI MEP K1
54
+ - SI MEP KLJNT
55
+ - SI MEP KRPRT
56
+ - SI MEP Kg1
57
+ - SI MEP M1
58
+ - SI MEP Mol1
59
+ - SI MEP S1
60
+ - SI Brochure
61
+ - SI Brochure, Appendix 4
62
62
 
63
63
  ==== Reference structire for Metrologia documents
64
64
 
65
- `BIPM Metrologia {JOURNAL} {VOLUME} {ISSUE} {ARTICLE}`
65
+ `BIPM Metrologia {JOURNAL} {VOLUME} {ISSUE} {PAGE}`
66
66
 
67
67
  - `{JOURNAL}` - number of journal, required
68
68
  - `{VOLUME}` - number of volume, optional
69
69
  - `{ISSUE}` - number of issue, optional
70
- - `{ARTICLE}` - number of article, optional
70
+ - `{PAGE}` - number of page, optional
71
71
 
72
72
  ==== Reference structures for CCTF (CCDS), CGMP, CIPM documents
73
73
 
@@ -94,13 +94,13 @@ require 'relaton_bipm'
94
94
  => true
95
95
 
96
96
  # get BIPM brochure
97
- item = RelatonBipm::BipmBibliography.get "BIPM si-brochure"
98
- [relaton-bipm] ("BIPM si-brochure") fetching...
99
- [relaton-bipm] ("BIPM si-brochure") found si-brochure
97
+ item = RelatonBipm::BipmBibliography.get "BIPM SI Brochure"
98
+ [relaton-bipm] ("BIPM SI Brochure") fetching...
99
+ [relaton-bipm] ("BIPM SI Brochure") found BIPM SI Brochure
100
100
  => #<RelatonBipm::BipmBibliographicItem:0x007ffb83982fe8
101
101
  ...
102
102
 
103
- # get BIPM Metrologia article
103
+ # get BIPM Metrologia page
104
104
  bib = RelatonBipm::BipmBibliography.get "BIPM Metrologia 29 6 373"
105
105
  [relaton-bipm] ("BIPM Metrologia 29 6 373") fetching...
106
106
  [relaton-bipm] ("BIPM Metrologia 29 6 373") found Metrologia 29 6 373
@@ -172,11 +172,12 @@ RelatonBipm::BipmBibliography.get "CIPM Recommendation 1948"
172
172
  [source,ruby]
173
173
  ----
174
174
  item.to_xml
175
- => "<bibitem id="si-brochure" type="standard">
175
+ => "<bibitem id="BIPMSIBrochure" type="standard">
176
176
  <fetched>2021-01-10</fetched>
177
177
  <title format="text/plain" language="en" script="Latn">The International System of Units (SI)</title>
178
178
  <title format="text/plain" language="fr" script="Latn">Le Système international d’unités (SI)</title>
179
- <docidentifier type="BIPM">si-brochure</docidentifier>
179
+ <uri type="src">https://www.bipm.org/en/publications/si-brochure</uri>
180
+ <docidentifier type="BIPM">BIPM SI Brochure</docidentifier>
180
181
  <date type="updated">
181
182
  <on>2019-05-20</on>
182
183
  </date>
@@ -205,7 +206,7 @@ item.to_xml bibdata: true
205
206
  <title format="text/plain" language="en" script="Latn">The International System of Units (SI)</title>
206
207
  <title format="text/plain" language="fr" script="Latn">Le Système international d’unités (SI)</title>
207
208
  <uri type="src">https://www.bipm.org/en/publications/si-brochure</uri>
208
- <docidentifier type="BIPM">si-brochure</docidentifier>
209
+ <docidentifier type="BIPM">BIPM SI Brochure</docidentifier>
209
210
  <date type="updated">
210
211
  <on>2019-05-20</on>
211
212
  </date>
@@ -15,11 +15,14 @@ module RelatonBipm
15
15
  class << self
16
16
  # @param text [String]
17
17
  # @return [RelatonBipm::BipmBibliographicItem]
18
- def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize
18
+ def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
19
19
  warn "[relaton-bipm] (\"#{text}\") fetching..."
20
20
  ref = text.sub(/^BIPM\s/, "")
21
21
  item = ref.match?(/^Metrologia/i) ? get_metrologia(ref, magent) : get_bipm(ref, magent)
22
- return unless item
22
+ unless item
23
+ warn "[relaton-bipm] (\"#{text}\") not found."
24
+ return
25
+ end
23
26
 
24
27
  warn("[relaton-bipm] (\"#{text}\") found #{item.docidentifier[0].id}")
25
28
  item
@@ -216,11 +219,19 @@ module RelatonBipm
216
219
  # @param art [String]
217
220
  # @param agent [Mechanize]
218
221
  # @return [RelatonBipm::BipmBibliographicItem]
219
- def get_article_from_issue(vol, ish, art, agent)
222
+ def get_article_from_issue(vol, ish, art, agent) # rubocop:disable Metrics/MethodLength
220
223
  url = issue_url vol, ish
221
224
  rsp = agent.get url
222
225
  check_response rsp
223
- get_article rsp.at("//div[@class='indexer'][.='#{art}']/../div/a")[:href], vol, ish, agent
226
+ link = rsp.at("//div[@class='indexer'][.='#{art}']/../div/a")
227
+ unless link
228
+ 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(', ')})"
231
+ return
232
+ end
233
+
234
+ get_article link[:href], vol, ish, agent
224
235
  end
225
236
 
226
237
  # @param path [String]
@@ -228,7 +239,7 @@ module RelatonBipm
228
239
  # @param ish [String]
229
240
  # @param agent [Mechanize]
230
241
  # @return [RelatonBipm::BipmBibliographicItem]
231
- def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize
242
+ def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
232
243
  rsp = agent.get path
233
244
  check_response rsp
234
245
  url = rsp.uri
@@ -236,16 +247,19 @@ module RelatonBipm
236
247
  rsp = agent.get bib
237
248
  check_response rsp
238
249
  bt = BibTeX.parse(rsp.body).first
239
- bibitem(docid: btdocid(bt), title: titles(bt.title.to_s), abstract: btabstract(bt), doctype: bt.type.to_s,
240
- link: btlink(bt, url), date: btdate(bt), contributor: btcontrib(bt), series: series,
241
- extent: btextent(vol, ish, bt))
250
+ bibitem(
251
+ docid: btdocid(bt), title: titles(bt.title.to_s), date: btdate(bt),
252
+ abstract: btabstract(bt), doctype: bt.type.to_s, series: series,
253
+ link: btlink(bt, url), contributor: btcontrib(bt),
254
+ extent: btextent(vol, ish, bt.pages.to_s)
255
+ )
242
256
  end
243
257
 
244
258
  # @param args [Hash]
245
259
  # @return [RelatonBipm::BipmBibliographicItem]
246
260
  def bibitem(**args)
247
261
  BipmBibliographicItem.new(
248
- fetched: Date.today.to_s, type: "standard", language: ["en"], script: ["Latn"], **args,
262
+ fetched: Date.today.to_s, type: "article", language: ["en"], script: ["Latn"], **args,
249
263
  )
250
264
  end
251
265
 
@@ -258,7 +272,10 @@ module RelatonBipm
258
272
  # @return [Array<RelatonBib::DocumentIdentifier>]
259
273
  def btdocid(bibtex)
260
274
  id = "#{bibtex.journal} #{bibtex.volume} #{bibtex.number} #{bibtex.pages.match(/^\d+/)}"
261
- [RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id)]
275
+ [
276
+ RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id, primary: true),
277
+ RelatonBib::DocumentIdentifier.new(type: "DOI", id: bibtex.doi),
278
+ ]
262
279
  end
263
280
 
264
281
  # @param bibtex [BibTeX::Entry]
@@ -298,14 +315,17 @@ module RelatonBipm
298
315
  ]
299
316
  end
300
317
 
301
- # @param vol [String]
302
- # @param ish [String]
303
- # @param bibtex [BibTeX::Entry]
318
+ #
319
+ # @param vol [String] volume
320
+ # @param ish [String] issue
321
+ # @param pgs [String] pages
322
+ #
304
323
  # @return [Array<RelatonBib::BibItemLocality>]
305
- def btextent(vol, ish = nil, bibtex = nil)
306
- ext = [RelatonBib::BibItemLocality.new("volume", vol)]
307
- ext << RelatonBib::BibItemLocality.new("issue", ish) if ish
308
- ext << RelatonBib::BibItemLocality.new("page", *bibtex.pages.split("--")) if bibtex
324
+ #
325
+ def btextent(vol, ish = nil, pgs = nil)
326
+ ext = [RelatonBib::Locality.new("volume", vol)]
327
+ ext << RelatonBib::Locality.new("issue", ish) if ish
328
+ ext << RelatonBib::Locality.new("page", *pgs.split("--")) if pgs
309
329
  ext
310
330
  end
311
331
 
@@ -329,11 +349,13 @@ module RelatonBipm
329
349
  #
330
350
  def check_response(rsp) # rubocop:disable Metrics/AbcSize
331
351
  if rsp.code == "302"
332
- warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
333
- raise RelatonBib::RequestError, "redirected to #{rsp.header['location']}"
352
+ warn "[relaton-bipm] This source employs anti-DDoS measures that unfortunately affects automated requests."
353
+ warn "[relaton-bipm] Please visit this link in your browser to resolve the CAPTCHA, then retry: #{rsp.uri}"
354
+ # warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
355
+ raise RelatonBib::RequestError, "cannot access #{rsp.uri}"
334
356
  elsif rsp.code != "200"
335
357
  warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
336
- raise RelatonBib::RequestError, "can't acces #{rsp.uri} #{rsp.code}"
358
+ raise RelatonBib::RequestError, "cannot acces #{rsp.uri} #{rsp.code}"
337
359
  end
338
360
  end
339
361
  end
@@ -67,13 +67,14 @@ module RelatonBipm
67
67
  docstd = Nokogiri::XML File.read f
68
68
  doc = docstd.at "/bibdata"
69
69
  hash1 = RelatonBipm::XMLParser.from_xml(doc.to_xml).to_hash
70
+ fix_si_brochure_id hash1
70
71
  hash1["fetched"] = Date.today.to_s
71
- hash1["docid"].detect { |id| id["type"] == "BIPM" }["primary"] = true
72
72
  outfile = File.join @output, File.basename(f).sub(/(?:-(?:en|fr))?\.rxl$/, ".yaml")
73
73
  @index[[hash1["docnumber"] || File.basename(outfile, ".yaml")]] = outfile
74
74
  hash = if File.exist? outfile
75
75
  warn_duplicate = false
76
76
  hash2 = YAML.load_file outfile
77
+ fix_si_brochure_id hash2
77
78
  deep_merge hash1, hash2
78
79
  else
79
80
  warn_duplicate = true
@@ -85,6 +86,29 @@ module RelatonBipm
85
86
  end
86
87
  end
87
88
 
89
+ #
90
+ # Update ID of SI brochure
91
+ #
92
+ # @param [Hash] hash hash of bibitem
93
+ #
94
+ # @return [void]
95
+ #
96
+ def fix_si_brochure_id(hash) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
97
+ did = hash["docid"].detect { |id| id["type"] == "BIPM" }
98
+ did["primary"] = true
99
+ return unless did["id"] == "BIPM Brochure"
100
+
101
+ isbn = hash["docid"].detect { |id| id["type"] == "ISBN" }
102
+ num = if isbn && isbn["id"] == "978-92-822-2272-0"
103
+ "SI Brochure"
104
+ else
105
+ "SI Brochure, Appendix 4"
106
+ end
107
+ hash["id"] = hash["id"].sub(/(?<=^BIPM)Brochure$/i, num.gsub(/[,\s]/, ""))
108
+ hash["docnumber"] = hash["docnumber"].sub(/^Brochure$/i, num)
109
+ did["id"] = did["id"].sub(/(?<=^BIPM\s)Brochure$/i, num)
110
+ end
111
+
88
112
  #
89
113
  # Deep merge two hashes
90
114
  #
@@ -194,7 +218,7 @@ module RelatonBipm
194
218
  #
195
219
  def fetch_resolution(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
196
220
  args[:en]["resolutions"].each.with_index do |r, i| # rubocop:disable Metrics/BlockLength
197
- hash = { fetched: Date.today.to_s, title: [], doctype: r["type"] }
221
+ hash = { type: "proceedings", fetched: Date.today.to_s, title: [], doctype: r["type"] }
198
222
  hash[:title] << title(r["title"], "en") if r["title"]
199
223
  fr_resolution = args[:fr]["resolutions"].fetch(i, nil)
200
224
  if fr_resolution
@@ -276,7 +300,8 @@ module RelatonBipm
276
300
  # @return [Hash] Hash of BIPM meeting/resolution
277
301
  #
278
302
  def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
279
- hash = { title: [], doctype: args[:type], fetched: Date.today.to_s }
303
+ hash = { title: [], type: "proceedings", doctype: args[:type],
304
+ fetched: Date.today.to_s }
280
305
  hash[:title] << title(args[:en]["title"], "en") if args[:en]["title"]
281
306
  hash[:title] << title(args[:fr]["title"], "fr") if args[:fr]["title"]
282
307
  hash[:date] = [{ type: "published", on: args[:en]["date"] }]
@@ -28,7 +28,7 @@ module RelatonBipm
28
28
  def path
29
29
  @path ||= begin
30
30
  dir = File.join Dir.home, ".relaton", "bipm"
31
- FileUtils.mkdir_p dir unless Dir.exist? dir
31
+ FileUtils.mkdir_p dir
32
32
  File.join dir, "index.yaml"
33
33
  end
34
34
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.13.0".freeze
2
+ VERSION = "1.13.3".freeze
3
3
  end
@@ -23,29 +23,18 @@ module RelatonBipm
23
23
  BipmBibliographicItem.new(**item_hash)
24
24
  end
25
25
 
26
- # @param item [Nokogiri::XML::Element]
27
- # @return [Array<RelatonBib::FormattedString>]
28
- def fetch_titles(item)
29
- item.xpath("./title").map do |t|
30
- RelatonBib::TypedTitleString.new(
31
- content: t.text, language: t[:language], script: t[:script],
32
- format: t[:format]
33
- )
34
- end
35
- end
36
-
37
- def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
38
- item.xpath("./date").reduce([]) do |a, d|
39
- type = d[:type].to_s.empty? ? "published" : d[:type]
40
- if (on = d.at("on"))
41
- a << BibliographicDate.new(type: type, on: on.text,
42
- to: d.at("to")&.text)
43
- elsif (from = d.at("from"))
44
- a << BibliographicDate.new(type: type, from: from.text,
45
- to: d.at("to")&.text)
46
- end
47
- end
48
- 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
49
38
 
50
39
  # @param item [Nokogiri::XML::Element]
51
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.0
4
+ version: 1.13.3
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-21 00:00:00.000000000 Z
11
+ date: 2022-09-03 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"