relaton-bipm 1.13.0 → 1.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +29 -29
- data/lib/relaton_bipm/bipm_bibliography.rb +19 -6
- data/lib/relaton_bipm/data_fetcher.rb +12 -1
- data/lib/relaton_bipm/index.rb +1 -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: edb89c4c5c98e541ba6c2b6dceb5e3c0133679d3058c88a28a873ef24a4b132d
|
4
|
+
data.tar.gz: f73db142b9080babed9748cb846e803dd2b8fbe76764d644ce072f2d614be704
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
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} {
|
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
|
-
- `{
|
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
|
98
|
-
[relaton-bipm] ("BIPM
|
99
|
-
[relaton-bipm] ("BIPM
|
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
|
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="
|
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
|
-
<
|
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">
|
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
|
-
|
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
|
-
|
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, "
|
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, "
|
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
|
#
|
data/lib/relaton_bipm/index.rb
CHANGED
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.13.
|
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-
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|