relaton-bipm 1.10.1 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +8 -8
- data/lib/relaton_bipm/bipm_bibliography.rb +28 -1
- data/lib/relaton_bipm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b2dba1f1f291abb29c9a90122c060265b1165ef5c8a667fe7aa3cc1bc28c367
|
4
|
+
data.tar.gz: 3782195ed79911afc17f0f235bb1bfb82484c06ca7fef87c869aa8d68017d6e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c5484395aeca285a53cf84ba9f50ca55db768cb7fbbe162fc8219424aa201af53423b34f5c9ecb8e6a25b776905447f5e987bc4a03e93b62dc808142d2b1501
|
7
|
+
data.tar.gz: f2a4039b7e63b4ab8b8e721042b109b9cd6abb3200254e004970a52c74b6593ae0954a39105eaaaff3ea21f47839c99c492d4fc8977f58e1257122e42d369582
|
data/README.adoc
CHANGED
@@ -53,17 +53,17 @@ bib = RelatonBipm::BipmBibliography.get "BIPM Metrologia 29 6 373"
|
|
53
53
|
...
|
54
54
|
|
55
55
|
# get CGPM resolutions
|
56
|
-
RelatonBipm::BipmBibliography.get "BIPM
|
57
|
-
[relaton-bipm] ("BIPM
|
58
|
-
[relaton-bipm] ("BIPM
|
59
|
-
=> #<RelatonBipm::BipmBibliographicItem:
|
56
|
+
RelatonBipm::BipmBibliography.get "BIPM CR 01"
|
57
|
+
[relaton-bipm] ("BIPM CR 01") fetching...
|
58
|
+
[relaton-bipm] ("BIPM CR 01") found BIPM CR 01
|
59
|
+
=> #<RelatonBipm::BipmBibliographicItem:0x00007fd4f7cba038
|
60
60
|
...
|
61
61
|
|
62
62
|
# get CIPM resolutions
|
63
|
-
RelatonBipm::BipmBibliography.get "BIPM
|
64
|
-
[relaton-bipm] ("BIPM
|
65
|
-
[relaton-bipm] ("BIPM
|
66
|
-
=> #<RelatonBipm::BipmBibliographicItem:
|
63
|
+
RelatonBipm::BipmBibliography.get "BIPM PV 101(I)"
|
64
|
+
[relaton-bipm] ("BIPM PV 101(I)") fetching...
|
65
|
+
[relaton-bipm] ("BIPM PV 101(I)") found BIPM PV 101(I)
|
66
|
+
=> #<RelatonBipm::BipmBibliographicItem:0x00007fd5072301c0
|
67
67
|
...
|
68
68
|
----
|
69
69
|
|
@@ -42,6 +42,7 @@ module RelatonBipm
|
|
42
42
|
def get_bipm(ref, agent)
|
43
43
|
url = "#{GH_ENDPOINT}#{ref.upcase.split.join '-'}.yaml"
|
44
44
|
resp = agent.get url
|
45
|
+
check_response resp
|
45
46
|
return unless resp.code == "200"
|
46
47
|
|
47
48
|
bib_hash = HashConverter.hash_to_bib YAML.safe_load(resp.body, [Date])
|
@@ -67,6 +68,7 @@ module RelatonBipm
|
|
67
68
|
def get_journal(agent)
|
68
69
|
url = "#{IOP_DOMAIN}/journal/0026-1394"
|
69
70
|
rsp = agent.get url
|
71
|
+
check_response rsp
|
70
72
|
rel = rsp.xpath('//select[@id="allVolumesSelector"]/option').map do |v|
|
71
73
|
{ type: "partOf", bibitem: journal_rel(v) }
|
72
74
|
end
|
@@ -88,6 +90,7 @@ module RelatonBipm
|
|
88
90
|
def get_volume(vol, agent)
|
89
91
|
url = "#{IOP_DOMAIN}/volume/0026-1394/#{vol}"
|
90
92
|
rsp = agent.get url
|
93
|
+
check_response rsp
|
91
94
|
rel = rsp.xpath('//li[@itemprop="hasPart"]').map do |i|
|
92
95
|
{ type: "partOf", bibitem: volume_rel(i, vol) }
|
93
96
|
end
|
@@ -116,9 +119,10 @@ module RelatonBipm
|
|
116
119
|
# @param ish [String]
|
117
120
|
# @param agent [Mechanize]
|
118
121
|
# @return [RelatonBipm::BipmBibliographicItem]
|
119
|
-
def get_issue(vol, ish, agent) # rubocop:disable Metrics/AbcSize
|
122
|
+
def get_issue(vol, ish, agent) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
120
123
|
url = issue_url vol, ish
|
121
124
|
rsp = agent.get url
|
125
|
+
check_response rsp
|
122
126
|
rel = rsp.xpath('//div[@class="art-list-item-body"]').map do |a|
|
123
127
|
{ type: "partOf", bibitem: issue_rel(a, vol, ish) }
|
124
128
|
end
|
@@ -199,6 +203,7 @@ module RelatonBipm
|
|
199
203
|
def get_article_from_issue(vol, ish, art, agent)
|
200
204
|
url = issue_url vol, ish
|
201
205
|
rsp = agent.get url
|
206
|
+
check_response rsp
|
202
207
|
get_article rsp.at("//div[@class='indexer'][.='#{art}']/../div/a")[:href], vol, ish, agent
|
203
208
|
end
|
204
209
|
|
@@ -209,9 +214,11 @@ module RelatonBipm
|
|
209
214
|
# @return [RelatonBipm::BipmBibliographicItem]
|
210
215
|
def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize
|
211
216
|
rsp = agent.get path
|
217
|
+
check_response rsp
|
212
218
|
url = rsp.uri
|
213
219
|
bib = rsp.link_with(text: "BibTeX").href
|
214
220
|
rsp = agent.get bib
|
221
|
+
check_response rsp
|
215
222
|
bt = BibTeX.parse(rsp.body).first
|
216
223
|
bibitem(docid: btdocid(bt), title: titles(bt.title.to_s), abstract: btabstract(bt), doctype: bt.type.to_s,
|
217
224
|
link: btlink(bt, url), date: btdate(bt), contributor: btcontrib(bt), series: series,
|
@@ -293,6 +300,26 @@ module RelatonBipm
|
|
293
300
|
def get(ref, year = nil, opts = {})
|
294
301
|
search(ref, year, opts)
|
295
302
|
end
|
303
|
+
|
304
|
+
private
|
305
|
+
|
306
|
+
#
|
307
|
+
# Check HTTP response. Warn and rise error if response is not 200
|
308
|
+
# or redirect to CAPTCHA.
|
309
|
+
#
|
310
|
+
# @param [Mechanize] rsp response
|
311
|
+
#
|
312
|
+
# @raise [RelatonBib::RequestError] if response is not 200
|
313
|
+
#
|
314
|
+
def check_response(rsp) # rubocop:disable Metrics/AbcSize
|
315
|
+
if rsp.code == "302"
|
316
|
+
warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
|
317
|
+
raise RelatonBib::RequestError, "redirected to #{rsp.header['location']}"
|
318
|
+
elsif rsp.code != "200"
|
319
|
+
warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
|
320
|
+
raise RelatonBib::RequestError, "can't acces #{rsp.uri} #{rsp.code}"
|
321
|
+
end
|
322
|
+
end
|
296
323
|
end
|
297
324
|
end
|
298
325
|
end
|
data/lib/relaton_bipm/version.rb
CHANGED
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.10.
|
4
|
+
version: 1.10.2
|
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-02-
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|