relaton-bipm 1.13.1 → 1.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +22 -0
- data/README.adoc +1 -0
- data/lib/relaton_bipm/bipm_bibliography.rb +23 -14
- data/lib/relaton_bipm/data_fetcher.rb +25 -8
- data/lib/relaton_bipm/version.rb +1 -1
- data/lib/relaton_bipm/xml_parser.rb +12 -23
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 163a9f60eeb667aff478312eb3325fa8d89ac00f4ed11dda2d24be353c7dee38
|
4
|
+
data.tar.gz: 5cc2a287138fe56e118ec4d3ef10b13d2da5568e69f186c9d303fa99fbe33b69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e585b21ae150bda7dc70203d696f4bfd9e9903a3d0b7e66b1f73b0b86312a59c171b35ab0cfe1b9ab3bcf9bce6a02f496354d5df0c95d0aab4e1258e89936e77
|
7
|
+
data.tar.gz: 425b7ff50a80c6e6971c1bccc42330f5785cdad5afff6632a08f4eec1271b7416514c9ed5c4a5468c15790d13138c43fe27e4dde03c1c688166bcaec6fc1da4f
|
@@ -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
@@ -239,7 +239,7 @@ module RelatonBipm
|
|
239
239
|
# @param ish [String]
|
240
240
|
# @param agent [Mechanize]
|
241
241
|
# @return [RelatonBipm::BipmBibliographicItem]
|
242
|
-
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
|
243
243
|
rsp = agent.get path
|
244
244
|
check_response rsp
|
245
245
|
url = rsp.uri
|
@@ -247,16 +247,19 @@ module RelatonBipm
|
|
247
247
|
rsp = agent.get bib
|
248
248
|
check_response rsp
|
249
249
|
bt = BibTeX.parse(rsp.body).first
|
250
|
-
bibitem(
|
251
|
-
|
252
|
-
|
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
|
+
)
|
253
256
|
end
|
254
257
|
|
255
258
|
# @param args [Hash]
|
256
259
|
# @return [RelatonBipm::BipmBibliographicItem]
|
257
260
|
def bibitem(**args)
|
258
261
|
BipmBibliographicItem.new(
|
259
|
-
fetched: Date.today.to_s, type: "
|
262
|
+
fetched: Date.today.to_s, type: "article", language: ["en"], script: ["Latn"], **args,
|
260
263
|
)
|
261
264
|
end
|
262
265
|
|
@@ -269,7 +272,10 @@ module RelatonBipm
|
|
269
272
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
270
273
|
def btdocid(bibtex)
|
271
274
|
id = "#{bibtex.journal} #{bibtex.volume} #{bibtex.number} #{bibtex.pages.match(/^\d+/)}"
|
272
|
-
[
|
275
|
+
[
|
276
|
+
RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id, primary: true),
|
277
|
+
RelatonBib::DocumentIdentifier.new(type: "DOI", id: bibtex.doi),
|
278
|
+
]
|
273
279
|
end
|
274
280
|
|
275
281
|
# @param bibtex [BibTeX::Entry]
|
@@ -309,14 +315,17 @@ module RelatonBipm
|
|
309
315
|
]
|
310
316
|
end
|
311
317
|
|
312
|
-
#
|
313
|
-
# @param
|
314
|
-
# @param
|
318
|
+
#
|
319
|
+
# @param vol [String] volume
|
320
|
+
# @param ish [String] issue
|
321
|
+
# @param pgs [String] pages
|
322
|
+
#
|
315
323
|
# @return [Array<RelatonBib::BibItemLocality>]
|
316
|
-
|
317
|
-
|
318
|
-
ext
|
319
|
-
ext << RelatonBib::
|
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
|
320
329
|
ext
|
321
330
|
end
|
322
331
|
|
@@ -342,7 +351,7 @@ module RelatonBipm
|
|
342
351
|
if rsp.code == "302"
|
343
352
|
warn "[relaton-bipm] This source employs anti-DDoS measures that unfortunately affects automated requests."
|
344
353
|
warn "[relaton-bipm] Please visit this link in your browser to resolve the CAPTCHA, then retry: #{rsp.uri}"
|
345
|
-
warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
|
354
|
+
# warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
|
346
355
|
raise RelatonBib::RequestError, "cannot access #{rsp.uri}"
|
347
356
|
elsif rsp.code != "200"
|
348
357
|
warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
|
@@ -63,8 +63,6 @@ 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
|
-
|
68
66
|
puts "Parsing #{f}"
|
69
67
|
docstd = Nokogiri::XML File.read f
|
70
68
|
doc = docstd.at "/bibdata"
|
@@ -88,12 +86,27 @@ module RelatonBipm
|
|
88
86
|
end
|
89
87
|
end
|
90
88
|
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
94
97
|
did = hash["docid"].detect { |id| id["type"] == "BIPM" }
|
95
98
|
did["primary"] = true
|
96
|
-
|
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)
|
97
110
|
end
|
98
111
|
|
99
112
|
#
|
@@ -205,7 +218,10 @@ module RelatonBipm
|
|
205
218
|
#
|
206
219
|
def fetch_resolution(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
207
220
|
args[:en]["resolutions"].each.with_index do |r, i| # rubocop:disable Metrics/BlockLength
|
208
|
-
hash = {
|
221
|
+
hash = {
|
222
|
+
type: "proceedings", fetched: Date.today.to_s, title: [],
|
223
|
+
doctype: r["type"], place: [RelatonBib::Place.new(city: "Paris")]
|
224
|
+
}
|
209
225
|
hash[:title] << title(r["title"], "en") if r["title"]
|
210
226
|
fr_resolution = args[:fr]["resolutions"].fetch(i, nil)
|
211
227
|
if fr_resolution
|
@@ -287,7 +303,8 @@ module RelatonBipm
|
|
287
303
|
# @return [Hash] Hash of BIPM meeting/resolution
|
288
304
|
#
|
289
305
|
def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
|
290
|
-
hash = { title: [], doctype: args[:type],
|
306
|
+
hash = { title: [], type: "proceedings", doctype: args[:type],
|
307
|
+
fetched: Date.today.to_s, place: [RelatonBib::Place.new(city: "Paris")] }
|
291
308
|
hash[:title] << title(args[:en]["title"], "en") if args[:en]["title"]
|
292
309
|
hash[:title] << title(args[:fr]["title"], "fr") if args[:fr]["title"]
|
293
310
|
hash[:date] = [{ type: "published", on: args[:en]["date"] }]
|
data/lib/relaton_bipm/version.rb
CHANGED
@@ -23,29 +23,18 @@ module RelatonBipm
|
|
23
23
|
BipmBibliographicItem.new(**item_hash)
|
24
24
|
end
|
25
25
|
|
26
|
-
#
|
27
|
-
#
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
|
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.
|
4
|
+
version: 1.13.4
|
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-
|
11
|
+
date: 2022-09-04 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"
|