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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24d544bd3daad314cd7af5b723c53765c4dfaedc5fe1cd56bfd4352dd9901a72
4
- data.tar.gz: '0309c87fe248963a2fec6d1a9fd1eadfc99158a55e8e6a8e9fdf7cc00f3e6add'
3
+ metadata.gz: ced155bf740bb8a1bb34fffc1c58bb864b753236abeb8a406aef9a2a509835c2
4
+ data.tar.gz: 7111b47d1617da91a47919336d2bc665de041e3ae109d06e0182ea9ad01ff140
5
5
  SHA512:
6
- metadata.gz: a125b70df0a8cfaafb3acb4adc7fbf8dc429c05208def6658927302e9880009bc6a9d471c24ca7c0cf5257484297c75ad020d282eafa99cad1230e9048957eba
7
- data.tar.gz: b7041bf466e72998494a9ebeeec12b7d26ca504a47125e2b47e4903a996a4756c6f04926fc5818f9cffb61601be2ef2e91b6e8a25b20b2c294cd7e45996cc6ff
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
- ==== Examples
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] ("BIPM SI Brochure") fetching...
200
- [relaton-bipm] ("BIPM SI Brochure") found BIPM SI Brochure
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] ("BIPM Metrologia 29 6 001") fetching...
207
- [relaton-bipm] ("BIPM Metrologia 29 6 001") found Metrologia 29 6 001
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] ("CGPM 1st Meeting (1889)") fetching...
214
- [relaton-bipm] ("CGPM 1st Meeting (1889)") found CGPM 1th meeting (1889)
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] ("CGPM RES (1889, E)") fetching...
221
- [relaton-bipm] ("CGPM RES (1889, E)") found CGPM RES (1889)
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] ("CGPM Resolution (1889)") fetching...
227
- [relaton-bipm] ("CGPM Resolution (1889)") found CGPM RES (1889)
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] ("CGPM Résolution (1889)") fetching...
233
- [relaton-bipm] ("CGPM Résolution (1889)") found CGPM RES (1889)
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] ("BIPM Decision CIPM/101-1 (2012)") fetching...
240
- [relaton-bipm] ("BIPM Decision CIPM/101-1 (2012)") found CIPM DECN 101-1 (2012)
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] ("BIPM DECN CIPM/101-1 (2012, E)") fetching...
246
- [relaton-bipm] ("BIPM DECN CIPM/101-1 (2012, E)") found CIPM DECN 101-1 (2012)
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] ("CIPM Recommendation 1 (2005)") fetching...
253
- [relaton-bipm] ("CIPM Recommendation 1 (2005)") found CIPM REC 1 (2005)
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] ("CIPM REC 1 (2005, FR)") fetching...
259
- [relaton-bipm] ("CIPM REC 1 (2005, FR)") found CIPM REC 1 (2005)
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 "Warning: invalid docstatus: `#{args[:docstatus].stage.value}`. " \
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 "Warning: invalid si_aspect: `#{args[:si_aspect]}``. " \
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(ref, magent)
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
- 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
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
- # @param agent [Mechanize]
45
+ #
45
46
  # @return [RelatonBipm::BipmBibliographicItem]
46
- def get_bipm(reference, agent) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 = agent.get url
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
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.16.1".freeze
2
+ VERSION = "1.16.2".freeze
3
3
  end
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.1
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-09-20 00:00:00.000000000 Z
11
+ date: 2023-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday