relaton-bipm 1.16.0 → 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 +4 -4
- data/lib/relaton_bipm/bipm_bibliography.rb +24 -22
- data/lib/relaton_bipm/committee.rb +2 -2
- data/lib/relaton_bipm/config.rb +10 -0
- data/lib/relaton_bipm/id_parser.rb +1 -1
- data/lib/relaton_bipm/util.rb +9 -0
- data/lib/relaton_bipm/version.rb +1 -1
- data/lib/relaton_bipm.rb +6 -4
- metadata +4 -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,13 +27,13 @@ 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
|
-
warn "
|
31
|
-
|
30
|
+
Util.warn "WARNING: invalid docstatus: `#{args[:docstatus].stage.value}`. " \
|
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
|
-
warn "
|
36
|
-
|
35
|
+
Util.warn "WARNING: invalid si_aspect: `#{args[:si_aspect]}``. " \
|
36
|
+
"It should be one of: `#{SI_ASPECTS.join('`, `')}`"
|
37
37
|
end
|
38
38
|
|
39
39
|
@comment_period = args.delete :comment_period
|
@@ -9,47 +9,49 @@ 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
|
-
warn "
|
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
|
-
warn "
|
16
|
+
Util.warn "(#{text}) not found."
|
17
17
|
return
|
18
18
|
end
|
19
19
|
|
20
|
-
warn("
|
20
|
+
Util.warn("(#{text}) found `#{item.docidentifier[0].id}`")
|
21
21
|
item
|
22
22
|
rescue Mechanize::ResponseCodeError => e
|
23
23
|
raise RelatonBib::RequestError, e.message unless e.response_code == "404"
|
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]
|
@@ -11,8 +11,8 @@ module RelatonBipm
|
|
11
11
|
def initialize(acronym:, content: nil)
|
12
12
|
acronyms = YAML.load_file File.join(__dir__, "acronyms.yaml")
|
13
13
|
unless acronyms[acronym]
|
14
|
-
warn "
|
15
|
-
|
14
|
+
Util.warn "WARNING: invalid acronym: `#{acronym}`. Allowed " \
|
15
|
+
"values: `#{acronyms.map { |k, _v| k }.join '`, `'}`"
|
16
16
|
end
|
17
17
|
|
18
18
|
@acronym = acronym
|
@@ -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
|
-
warn "
|
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
data/lib/relaton_bipm.rb
CHANGED
@@ -3,6 +3,8 @@ require "fileutils"
|
|
3
3
|
require "parslet"
|
4
4
|
require "relaton_bib"
|
5
5
|
require "relaton/index"
|
6
|
+
require "relaton_bipm/config"
|
7
|
+
require "relaton_bipm/util"
|
6
8
|
require "relaton_bipm/id_parser"
|
7
9
|
require "relaton_bipm/version"
|
8
10
|
require "relaton_bipm/editorial_group"
|
@@ -28,10 +30,10 @@ module RelatonBipm
|
|
28
30
|
# Returns hash of XML reammar
|
29
31
|
# @return [String]
|
30
32
|
def grammar_hash
|
31
|
-
gem_path = File.expand_path "..", __dir__
|
32
|
-
grammars_path = File.join gem_path, "grammars", "*"
|
33
|
-
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
34
|
-
Digest::MD5.hexdigest grammars
|
33
|
+
# gem_path = File.expand_path "..", __dir__
|
34
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
35
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
36
|
+
Digest::MD5.hexdigest RelatonBipm::VERSION + RelatonBib::VERSION # grammars
|
35
37
|
end
|
36
38
|
|
37
39
|
extend self
|
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
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/relaton_bipm/bipm_si_brochure_parser.rb
|
128
128
|
- lib/relaton_bipm/comment_periond.rb
|
129
129
|
- lib/relaton_bipm/committee.rb
|
130
|
+
- lib/relaton_bipm/config.rb
|
130
131
|
- lib/relaton_bipm/data_fetcher.rb
|
131
132
|
- lib/relaton_bipm/data_outcomes_parser.rb
|
132
133
|
- lib/relaton_bipm/document_relation.rb
|
@@ -137,6 +138,7 @@ files:
|
|
137
138
|
- lib/relaton_bipm/rawdata_bipm_metrologia/article_parser.rb
|
138
139
|
- lib/relaton_bipm/rawdata_bipm_metrologia/fetcher.rb
|
139
140
|
- lib/relaton_bipm/structured_identifier.rb
|
141
|
+
- lib/relaton_bipm/util.rb
|
140
142
|
- lib/relaton_bipm/version.rb
|
141
143
|
- lib/relaton_bipm/workgroup.rb
|
142
144
|
- lib/relaton_bipm/xml_parser.rb
|