relaton-bipm 1.13.0 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60cc8b3979fffe05b9bc5d554e7bc6b486867a5a32f332b30c8fb30601b49b18
4
- data.tar.gz: 3e20d99bb7d1055b6bedc2ab42a8c9eb074738ee8ebd8d26aba67f824a4935d0
3
+ metadata.gz: edb89c4c5c98e541ba6c2b6dceb5e3c0133679d3058c88a28a873ef24a4b132d
4
+ data.tar.gz: f73db142b9080babed9748cb846e803dd2b8fbe76764d644ce072f2d614be704
5
5
  SHA512:
6
- metadata.gz: 5a59447492ae98160a67ed7a5f2843f211edbca658a452e685f521a5a940d102ee47d2b7d39265077407ff5a0cf9892f9d9c19e0719ad7c46e304b9f797e4709
7
- data.tar.gz: d0c55fe5d12003e400cc660c6561bcf5878741b955785951089405ee64b4e94bc3067b8181f72b88ec7bb04a27dd93163cf19b289bdd3c3c1ccfff68b85579a1
6
+ metadata.gz: 9252968e4aafe5721c843620e3515046f5360f6e1b492f341fe951314ed7de7894941052959a6c9c4a0bda18eba4cdbac47857fa58a4c0065199540128215253
7
+ data.tar.gz: 434e30bc8487085bf50d69b3be05443e53e235e813ba0a14937531a46b635a2eaa6fd919db4b1d21a2f96943c97a981b7704409963c8b77dd14f540b384dacc7
data/README.adoc CHANGED
@@ -39,35 +39,34 @@ 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
62
61
 
63
62
  ==== Reference structire for Metrologia documents
64
63
 
65
- `BIPM Metrologia {JOURNAL} {VOLUME} {ISSUE} {ARTICLE}`
64
+ `BIPM Metrologia {JOURNAL} {VOLUME} {ISSUE} {PAGE}`
66
65
 
67
66
  - `{JOURNAL}` - number of journal, required
68
67
  - `{VOLUME}` - number of volume, optional
69
68
  - `{ISSUE}` - number of issue, optional
70
- - `{ARTICLE}` - number of article, optional
69
+ - `{PAGE}` - number of page, optional
71
70
 
72
71
  ==== Reference structures for CCTF (CCDS), CGMP, CIPM documents
73
72
 
@@ -94,13 +93,13 @@ require 'relaton_bipm'
94
93
  => true
95
94
 
96
95
  # 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
96
+ item = RelatonBipm::BipmBibliography.get "BIPM SI Brochure"
97
+ [relaton-bipm] ("BIPM SI Brochure") fetching...
98
+ [relaton-bipm] ("BIPM SI Brochure") found BIPM SI Brochure
100
99
  => #<RelatonBipm::BipmBibliographicItem:0x007ffb83982fe8
101
100
  ...
102
101
 
103
- # get BIPM Metrologia article
102
+ # get BIPM Metrologia page
104
103
  bib = RelatonBipm::BipmBibliography.get "BIPM Metrologia 29 6 373"
105
104
  [relaton-bipm] ("BIPM Metrologia 29 6 373") fetching...
106
105
  [relaton-bipm] ("BIPM Metrologia 29 6 373") found Metrologia 29 6 373
@@ -172,11 +171,12 @@ RelatonBipm::BipmBibliography.get "CIPM Recommendation 1948"
172
171
  [source,ruby]
173
172
  ----
174
173
  item.to_xml
175
- => "<bibitem id="si-brochure" type="standard">
174
+ => "<bibitem id="BIPMSIBrochure" type="standard">
176
175
  <fetched>2021-01-10</fetched>
177
176
  <title format="text/plain" language="en" script="Latn">The International System of Units (SI)</title>
178
177
  <title format="text/plain" language="fr" script="Latn">Le Système international d’unités (SI)</title>
179
- <docidentifier type="BIPM">si-brochure</docidentifier>
178
+ <uri type="src">https://www.bipm.org/en/publications/si-brochure</uri>
179
+ <docidentifier type="BIPM">BIPM SI Brochure</docidentifier>
180
180
  <date type="updated">
181
181
  <on>2019-05-20</on>
182
182
  </date>
@@ -205,7 +205,7 @@ item.to_xml bibdata: true
205
205
  <title format="text/plain" language="en" script="Latn">The International System of Units (SI)</title>
206
206
  <title format="text/plain" language="fr" script="Latn">Le Système international d’unités (SI)</title>
207
207
  <uri type="src">https://www.bipm.org/en/publications/si-brochure</uri>
208
- <docidentifier type="BIPM">si-brochure</docidentifier>
208
+ <docidentifier type="BIPM">BIPM SI Brochure</docidentifier>
209
209
  <date type="updated">
210
210
  <on>2019-05-20</on>
211
211
  </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]
@@ -329,11 +340,13 @@ module RelatonBipm
329
340
  #
330
341
  def check_response(rsp) # rubocop:disable Metrics/AbcSize
331
342
  if rsp.code == "302"
343
+ warn "[relaton-bipm] This source employs anti-DDoS measures that unfortunately affects automated requests."
344
+ warn "[relaton-bipm] Please visit this link in your browser to resolve the CAPTCHA, then retry: #{rsp.uri}"
332
345
  warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
333
- raise RelatonBib::RequestError, "redirected to #{rsp.header['location']}"
346
+ raise RelatonBib::RequestError, "cannot access #{rsp.uri}"
334
347
  elsif rsp.code != "200"
335
348
  warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
336
- raise RelatonBib::RequestError, "can't acces #{rsp.uri} #{rsp.code}"
349
+ raise RelatonBib::RequestError, "cannot acces #{rsp.uri} #{rsp.code}"
337
350
  end
338
351
  end
339
352
  end
@@ -63,17 +63,20 @@ module RelatonBipm
63
63
  # puts "Ls #{Dir['bipm-si-brochure/site/*']}"
64
64
  # puts "Ls #{Dir['bipm-si-brochure/site/documents/*']}"
65
65
  Dir["bipm-si-brochure/site/documents/*.rxl"].each do |f|
66
+ next if f.include?("sib-a4")
67
+
66
68
  puts "Parsing #{f}"
67
69
  docstd = Nokogiri::XML File.read f
68
70
  doc = docstd.at "/bibdata"
69
71
  hash1 = RelatonBipm::XMLParser.from_xml(doc.to_xml).to_hash
72
+ fix_si_brochure_id hash1
70
73
  hash1["fetched"] = Date.today.to_s
71
- hash1["docid"].detect { |id| id["type"] == "BIPM" }["primary"] = true
72
74
  outfile = File.join @output, File.basename(f).sub(/(?:-(?:en|fr))?\.rxl$/, ".yaml")
73
75
  @index[[hash1["docnumber"] || File.basename(outfile, ".yaml")]] = outfile
74
76
  hash = if File.exist? outfile
75
77
  warn_duplicate = false
76
78
  hash2 = YAML.load_file outfile
79
+ fix_si_brochure_id hash2
77
80
  deep_merge hash1, hash2
78
81
  else
79
82
  warn_duplicate = true
@@ -85,6 +88,14 @@ module RelatonBipm
85
88
  end
86
89
  end
87
90
 
91
+ def fix_si_brochure_id(hash)
92
+ hash["id"] = hash["id"].sub(/^BIPMBrochure$/, "BIPMSIBrochure")
93
+ hash["docnumber"] = hash["docnumber"].sub(/^Brochure$/i, "SI Brochure")
94
+ did = hash["docid"].detect { |id| id["type"] == "BIPM" }
95
+ did["primary"] = true
96
+ did["id"] = did["id"].sub(/^BIPM Brochure$/, "BIPM SI Brochure")
97
+ end
98
+
88
99
  #
89
100
  # Deep merge two hashes
90
101
  #
@@ -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.1".freeze
3
3
  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.0
4
+ version: 1.13.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: 2022-08-21 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug