relaton-bipm 1.16.1 → 1.16.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 +32 -21
- data/lib/relaton_bipm/bipm_bibliographic_item.rb +2 -2
- data/lib/relaton_bipm/bipm_bibliography.rb +22 -20
- data/lib/relaton_bipm/id_parser.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: ced155bf740bb8a1bb34fffc1c58bb864b753236abeb8a406aef9a2a509835c2
|
4
|
+
data.tar.gz: 7111b47d1617da91a47919336d2bc665de041e3ae109d06e0182ea9ad01ff140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d48462fd26483e16041580591fd0b3b5e0f58bdea4058dab03210606e1f49f6ddaddfe0b69a9e4c1e930496b56580315f2ad14644a1fb04abae4d991009c0004
|
7
|
+
data.tar.gz: 2e8ac7afb0fda2c8f8f1acf1beb00c3870ab8941250f124e718e3b6f251d67dfc69442251c4ec6965c4e5a895d90d7da8e5354976152a87691e11980e832da0a
|
data/README.adoc
CHANGED
@@ -187,76 +187,87 @@ Recommendation JCRB/43-1 (2021) / Recommandation JCRB/43-1 (2021)
|
|
187
187
|
JCRB REC JCRB/43-1 (2021)
|
188
188
|
----
|
189
189
|
|
190
|
-
|
190
|
+
=== Configuration
|
191
|
+
|
192
|
+
Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonBipm.configure` block.
|
191
193
|
|
192
194
|
[source,ruby]
|
193
195
|
----
|
194
196
|
require 'relaton_bipm'
|
195
197
|
=> true
|
196
198
|
|
199
|
+
RelatonBipm.configure do |config|
|
200
|
+
config.logger.level = Logger::DEBUG
|
201
|
+
end
|
202
|
+
----
|
203
|
+
|
204
|
+
==== Examples
|
205
|
+
|
206
|
+
[source,ruby]
|
207
|
+
----
|
197
208
|
# get BIPM brochure
|
198
209
|
item = RelatonBipm::BipmBibliography.get "BIPM SI Brochure"
|
199
|
-
[relaton-bipm] (
|
200
|
-
[relaton-bipm] (
|
210
|
+
[relaton-bipm] (BIPM SI Brochure) fetching...
|
211
|
+
[relaton-bipm] (BIPM SI Brochure) found `BIPM SI Brochure`
|
201
212
|
=> #<RelatonBipm::BipmBibliographicItem:0x007ffb83982fe8
|
202
213
|
...
|
203
214
|
|
204
215
|
# get BIPM Metrologia page
|
205
216
|
bib = RelatonBipm::BipmBibliography.get "BIPM Metrologia 29 6 001"
|
206
|
-
[relaton-bipm] (
|
207
|
-
[relaton-bipm] (
|
217
|
+
[relaton-bipm] (BIPM Metrologia 29 6 001) fetching...
|
218
|
+
[relaton-bipm] (BIPM Metrologia 29 6 001) found `Metrologia 29 6 001`
|
208
219
|
=> #<RelatonBipm::BipmBibliographicItem:0x007f8857f94d40
|
209
220
|
...
|
210
221
|
|
211
222
|
# get CGPM meetings
|
212
223
|
RelatonBipm::BipmBibliography.get "CGPM 1st Meeting (1889)"
|
213
|
-
[relaton-bipm] (
|
214
|
-
[relaton-bipm] (
|
224
|
+
[relaton-bipm] (CGPM 1st Meeting (1889)) fetching...
|
225
|
+
[relaton-bipm] (CGPM 1st Meeting (1889)) found `CGPM 1th meeting (1889)`
|
215
226
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f7fd02aba28
|
216
227
|
...
|
217
228
|
|
218
229
|
# get CGPM resolutions
|
219
230
|
RelatonBipm::BipmBibliography.get "CGPM RES (1889, E)"
|
220
|
-
[relaton-bipm] (
|
221
|
-
[relaton-bipm] (
|
231
|
+
[relaton-bipm] (CGPM RES (1889, E)) fetching...
|
232
|
+
[relaton-bipm] (CGPM RES (1889, E)) found `CGPM RES (1889)`
|
222
233
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f80421f93d8
|
223
234
|
...
|
224
235
|
|
225
236
|
RelatonBipm::BipmBibliography.get "CGPM Resolution (1889)"
|
226
|
-
[relaton-bipm] (
|
227
|
-
[relaton-bipm] (
|
237
|
+
[relaton-bipm] (CGPM Resolution (1889)) fetching...
|
238
|
+
[relaton-bipm] (CGPM Resolution (1889)) found `CGPM RES (1889)`
|
228
239
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f60c18
|
229
240
|
...
|
230
241
|
|
231
242
|
RelatonBipm::BipmBibliography.get "CGPM Résolution (1889)"
|
232
|
-
[relaton-bipm] (
|
233
|
-
[relaton-bipm] (
|
243
|
+
[relaton-bipm] (CGPM Résolution (1889)) fetching...
|
244
|
+
[relaton-bipm] (CGPM Résolution (1889)) found `CGPM RES (1889)`
|
234
245
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f492e8
|
235
246
|
...
|
236
247
|
|
237
248
|
# get CIPM decision by year and decision number
|
238
249
|
RelatonBipm::BipmBibliography.get "BIPM Decision CIPM/101-1 (2012)"
|
239
|
-
[relaton-bipm] (
|
240
|
-
[relaton-bipm] (
|
250
|
+
[relaton-bipm] (BIPM Decision CIPM/101-1 (2012)) fetching...
|
251
|
+
[relaton-bipm] (BIPM Decision CIPM/101-1 (2012)) found `CIPM DECN 101-1 (2012)`
|
241
252
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f2bd88
|
242
253
|
...
|
243
254
|
|
244
255
|
RelatonBipm::BipmBibliography.get "BIPM DECN CIPM/101-1 (2012, E)"
|
245
|
-
[relaton-bipm] (
|
246
|
-
[relaton-bipm] (
|
256
|
+
[relaton-bipm] (BIPM DECN CIPM/101-1 (2012, E)) fetching...
|
257
|
+
[relaton-bipm] (BIPM DECN CIPM/101-1 (2012, E)) found `CIPM DECN 101-1 (2012)`
|
247
258
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f39438
|
248
259
|
...
|
249
260
|
|
250
261
|
# get CIPM recommendation
|
251
262
|
RelatonBipm::BipmBibliography.get "CIPM Recommendation 1 (2005)"
|
252
|
-
[relaton-bipm] (
|
253
|
-
[relaton-bipm] (
|
263
|
+
[relaton-bipm] (CIPM Recommendation 1 (2005)) fetching...
|
264
|
+
[relaton-bipm] (CIPM Recommendation 1 (2005)) found `CIPM REC 1 (2005)`
|
254
265
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f8017f31da0
|
255
266
|
...
|
256
267
|
|
257
268
|
RelatonBipm::BipmBibliography.get "CIPM REC 1 (2005, FR)"
|
258
|
-
[relaton-bipm] (
|
259
|
-
[relaton-bipm] (
|
269
|
+
[relaton-bipm] (CIPM REC 1 (2005, FR)) fetching...
|
270
|
+
[relaton-bipm] (CIPM REC 1 (2005, FR)) found `CIPM REC 1 (2005)`
|
260
271
|
=> #<RelatonBipm::BipmBibliographicItem:0x00007f80422100d8
|
261
272
|
...
|
262
273
|
----
|
@@ -27,12 +27,12 @@ module RelatonBipm
|
|
27
27
|
# @param structuredidentifier [RelatonBipm::StructuredIdentifier]
|
28
28
|
def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
29
29
|
if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage.value)
|
30
|
-
Util.warn "
|
30
|
+
Util.warn "WARNING: invalid docstatus: `#{args[:docstatus].stage.value}`. " \
|
31
31
|
"It should be one of: `#{STATUSES.join('`, `')}`"
|
32
32
|
end
|
33
33
|
|
34
34
|
if args[:si_aspect] && !SI_ASPECTS.include?(args[:si_aspect])
|
35
|
-
Util.warn "
|
35
|
+
Util.warn "WARNING: invalid si_aspect: `#{args[:si_aspect]}``. " \
|
36
36
|
"It should be one of: `#{SI_ASPECTS.join('`, `')}`"
|
37
37
|
end
|
38
38
|
|
@@ -9,9 +9,9 @@ module RelatonBipm
|
|
9
9
|
# @param text [String]
|
10
10
|
# @return [RelatonBipm::BipmBibliographicItem]
|
11
11
|
def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
12
|
-
Util.warn "(#{text}) fetching..."
|
12
|
+
Util.warn "(#{text}) fetching from Relaton repository ..."
|
13
13
|
ref = text.sub(/^BIPM\s/, "")
|
14
|
-
item = get_bipm
|
14
|
+
item = get_bipm ref
|
15
15
|
unless item
|
16
16
|
Util.warn "(#{text}) not found."
|
17
17
|
return
|
@@ -24,32 +24,34 @@ module RelatonBipm
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# @return [Mechanize]
|
27
|
-
def magent # rubocop:disable Metrics/MethodLength
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
27
|
+
# def magent # rubocop:disable Metrics/MethodLength
|
28
|
+
# a = Mechanize.new
|
29
|
+
# a.request_headers = {
|
30
|
+
# "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9," \
|
31
|
+
# "image/avif,image/webp,image/apng," \
|
32
|
+
# "*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
33
|
+
# "Accept-Encoding" => "gzip, deflate, br",
|
34
|
+
# "Accept-Language" => "en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7",
|
35
|
+
# "Cache-Control" => "max-age=0",
|
36
|
+
# "Upgrade-Insecure-Requests" => "1",
|
37
|
+
# }
|
38
|
+
# a.user_agent_alias = Mechanize::AGENT_ALIASES.map(&:first).shuffle.first
|
39
|
+
# # a.user_agent_alias = "Mac Safari"
|
40
|
+
# a
|
41
|
+
# end
|
42
42
|
|
43
|
+
#
|
43
44
|
# @param reference [String]
|
44
|
-
#
|
45
|
+
#
|
45
46
|
# @return [RelatonBipm::BipmBibliographicItem]
|
46
|
-
|
47
|
+
#
|
48
|
+
def get_bipm(reference) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
47
49
|
ref_id = Id.new reference
|
48
50
|
rows = index.search { |r| ref_id == r[:id] }
|
49
51
|
return unless rows.any?
|
50
52
|
|
51
53
|
url = "#{GH_ENDPOINT}#{rows.first[:file]}"
|
52
|
-
resp =
|
54
|
+
resp = Mechanize.new.get url
|
53
55
|
return unless resp.code == "200"
|
54
56
|
|
55
57
|
yaml = RelatonBib.parse_yaml resp.body, [Date]
|
@@ -76,7 +76,7 @@ module RelatonBipm
|
|
76
76
|
def initialize(id)
|
77
77
|
@id = Parser.new.parse(id)
|
78
78
|
rescue Parslet::ParseFailed => e
|
79
|
-
Util.warn "Incorrect reference: `#{id}`"
|
79
|
+
Util.warn "WARNING: Incorrect reference: `#{id}`"
|
80
80
|
# warn "[relaton-bipm] #{e.parse_failure_cause.ascii_tree}"
|
81
81
|
raise RelatonBib::RequestError, e
|
82
82
|
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.16.
|
4
|
+
version: 1.16.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: 2023-
|
11
|
+
date: 2023-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|