relaton-bipm 1.13.4 → 1.13.6
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 -0
- data/lib/relaton_bipm/bipm_bibliography.rb +17 -12
- data/lib/relaton_bipm/data_fetcher.rb +39 -13
- 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: aeddd651dcb48a277d10ad9351ba46351b7fe43eb8b136a359148d83a23ca7c0
|
4
|
+
data.tar.gz: 5b25f339d03c0278660b58a7b190e88e5a1c05ab0bcbec007fb8fdd6108efa7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b913ce825a85cb4e751bb149422427f6828f009fe6324b08c18c25ab6573c0e365f266d7954940a79e63bacd8fb52ee81d37aa983749d1d0403c3fee0c1dcd1
|
7
|
+
data.tar.gz: 202619fe86dde21f5bfe8efb221177ab3cd078c4fcd57078b1584baf6609fed489d1c16e0d84b4fe5aa63bd88f59dd53b8b5d36c4d10931c6f57702c0b909ad0
|
data/README.adoc
CHANGED
@@ -33,6 +33,14 @@ Or install it yourself as:
|
|
33
33
|
|
34
34
|
=== Search for a standard using keywords
|
35
35
|
|
36
|
+
The Metrologia website employs anti-DDoS protection, which may cause the search to fail. If this happens, open provided link in a browser and solve the captcha.
|
37
|
+
|
38
|
+
----
|
39
|
+
[relaton-bipm] ("BIPM Metrologia 50 4 385") fetching...
|
40
|
+
[relaton-bipm] This source employs anti-DDoS measures that unfortunately affects automated requests.
|
41
|
+
[relaton-bipm] Please visit this link in your browser to resolve the CAPTCHA, then retry: https://iopscience.iop.org/article/10.1088/0026-1394/50/4/385
|
42
|
+
----
|
43
|
+
|
36
44
|
==== References for Si-Brochure documents
|
37
45
|
|
38
46
|
`BIPM {DOCUMENT_NAME}`
|
@@ -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"
|
@@ -43,6 +44,7 @@ module RelatonBipm
|
|
43
44
|
"Upgrade-Insecure-Requests" => "1",
|
44
45
|
}
|
45
46
|
a.user_agent_alias = Mechanize::AGENT_ALIASES.map(&:first).shuffle.first
|
47
|
+
# a.user_agent_alias = "Mac Safari"
|
46
48
|
a
|
47
49
|
end
|
48
50
|
|
@@ -226,8 +228,8 @@ module RelatonBipm
|
|
226
228
|
link = rsp.at("//div[@class='indexer'][.='#{art}']/../div/a")
|
227
229
|
unless link
|
228
230
|
arts = rsp.xpath("//div[@class='indexer']").map(&:text)
|
229
|
-
warn "[relaton-bipm]
|
230
|
-
warn "[relaton-bipm]
|
231
|
+
warn "[relaton-bipm] No article is available at the specified start page \"#{art}\" in issue \"BIPM Metrologia #{vol} #{ish}\"."
|
232
|
+
warn "[relaton-bipm] Available articles in the issue start at the following pages: (#{arts.join(', ')})"
|
231
233
|
return
|
232
234
|
end
|
233
235
|
|
@@ -240,6 +242,7 @@ module RelatonBipm
|
|
240
242
|
# @param agent [Mechanize]
|
241
243
|
# @return [RelatonBipm::BipmBibliographicItem]
|
242
244
|
def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
245
|
+
agent.agent.allowed_error_codes = [403]
|
243
246
|
rsp = agent.get path
|
244
247
|
check_response rsp
|
245
248
|
url = rsp.uri
|
@@ -304,15 +307,17 @@ module RelatonBipm
|
|
304
307
|
# @param bibtex [BibTeX::Entry]
|
305
308
|
# @return [Array<Hash>]
|
306
309
|
def btcontrib(bibtex)
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
310
|
+
contribs = [{
|
311
|
+
entity: { name: bibtex.publisher.to_s }, role: [{ type: "publisher" }]
|
312
|
+
}]
|
313
|
+
return contribs unless bibtex.author
|
314
|
+
|
315
|
+
bibtex.author.split(" and ").inject(contribs) do |mem, name|
|
316
|
+
cname = RelatonBib::LocalizedString.new name, "en", "Latn"
|
317
|
+
name = RelatonBib::FullName.new completename: cname
|
318
|
+
author = RelatonBib::Person.new name: name
|
319
|
+
mem << { entity: author, role: [{ type: "author" }] }
|
320
|
+
end
|
316
321
|
end
|
317
322
|
|
318
323
|
#
|
@@ -353,7 +358,7 @@ module RelatonBipm
|
|
353
358
|
warn "[relaton-bipm] Please visit this link in your browser to resolve the CAPTCHA, then retry: #{rsp.uri}"
|
354
359
|
# warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
|
355
360
|
raise RelatonBib::RequestError, "cannot access #{rsp.uri}"
|
356
|
-
elsif rsp.code != "200"
|
361
|
+
elsif rsp.code != "200" && rsp.code != "403"
|
357
362
|
warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
|
358
363
|
raise RelatonBib::RequestError, "cannot acces #{rsp.uri} #{rsp.code}"
|
359
364
|
end
|
@@ -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"
|
@@ -219,7 +218,7 @@ module RelatonBipm
|
|
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
220
|
hash = {
|
222
|
-
type: "proceedings",
|
221
|
+
type: "proceedings", title: [],
|
223
222
|
doctype: r["type"], place: [RelatonBib::Place.new(city: "Paris")]
|
224
223
|
}
|
225
224
|
hash[:title] << title(r["title"], "en") if r["title"]
|
@@ -252,10 +251,7 @@ module RelatonBipm
|
|
252
251
|
hash[:link] << { type: "pdf", content: r["reference"] } if r["reference"]
|
253
252
|
hash[:language] = %w[en fr]
|
254
253
|
hash[:script] = ["Latn"]
|
255
|
-
hash[:contributor] = [
|
256
|
-
entity: { url: "www.bipm.org", name: "Bureau International des Poids et Mesures", abbreviation: "BIPM" },
|
257
|
-
role: [{ type: "publisher" }],
|
258
|
-
}]
|
254
|
+
hash[:contributor] = contributors date, args[:body]
|
259
255
|
hash[:structuredidentifier] = RelatonBipm::StructuredIdentifier.new docnumber: num
|
260
256
|
item = RelatonBipm::BipmBibliographicItem.new(**hash)
|
261
257
|
file = year
|
@@ -269,6 +265,39 @@ module RelatonBipm
|
|
269
265
|
end
|
270
266
|
end
|
271
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
|
+
|
272
301
|
def title(content, language)
|
273
302
|
{ content: content, language: language, script: "Latn" }
|
274
303
|
end
|
@@ -304,7 +333,7 @@ module RelatonBipm
|
|
304
333
|
#
|
305
334
|
def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
|
306
335
|
hash = { title: [], type: "proceedings", doctype: args[:type],
|
307
|
-
|
336
|
+
place: [RelatonBib::Place.new(city: "Paris")] }
|
308
337
|
hash[:title] << title(args[:en]["title"], "en") if args[:en]["title"]
|
309
338
|
hash[:title] << title(args[:fr]["title"], "fr") if args[:fr]["title"]
|
310
339
|
hash[:date] = [{ type: "published", on: args[:en]["date"] }]
|
@@ -320,10 +349,7 @@ module RelatonBipm
|
|
320
349
|
hash[:link] += args[:src] if args[:src]&.any?
|
321
350
|
hash[:language] = %w[en fr]
|
322
351
|
hash[:script] = ["Latn"]
|
323
|
-
hash[:contributor] = [
|
324
|
-
entity: { url: "www.bipm.org", name: "Bureau International des Poids et Mesures", abbreviation: "BIPM" },
|
325
|
-
role: [{ type: "publisher" }],
|
326
|
-
}]
|
352
|
+
hash[:contributor] = contributors args[:en]["date"], args[:body]
|
327
353
|
hash[:structuredidentifier] = RelatonBipm::StructuredIdentifier.new docnumber: args[:num]
|
328
354
|
hash
|
329
355
|
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.13.
|
4
|
+
version: 1.13.6
|
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-09-
|
11
|
+
date: 2022-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|