relaton 1.15.6 → 1.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/README.adoc +25 -24
- data/lib/relaton/config.rb +7 -16
- data/lib/relaton/db.rb +27 -20
- data/lib/relaton/db_cache.rb +1 -1
- data/lib/relaton/registry.rb +7 -8
- data/lib/relaton/util.rb +3 -7
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton.rb +1 -0
- data/relaton.gemspec +25 -25
- data/spec/relaton/config_spec.rb +6 -18
- data/spec/relaton/db_spec.rb +30 -13
- data/spec/relaton/registry_spec.rb +2 -0
- data/spec/relaton/util_spec.rb +3 -5
- data/spec/relaton_spec.rb +1 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +19 -19
- data/spec/vcr_cassetes/api_relaton_org.yml +7 -7
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +2984 -2128
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +24 -24
- data/spec/vcr_cassetes/cie_001_1980.yml +184 -184
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +8 -8
- data/spec/vcr_cassetes/ecma_6.yml +21 -21
- data/spec/vcr_cassetes/en_10160_1999.yml +9715 -9701
- data/spec/vcr_cassetes/ieee_528_2019.yml +2731 -2738
- data/spec/vcr_cassetes/iso_111111119115_1.yml +3 -3
- data/spec/vcr_cassetes/iso_19115_1.yml +3148 -2293
- data/spec/vcr_cassetes/iso_19115_1_2.yml +6196 -4483
- data/spec/vcr_cassetes/iso_19115_1_std.yml +3147 -2292
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +3144 -2288
- data/spec/vcr_cassetes/iso_19133_2005.yml +3173 -2316
- data/spec/vcr_cassetes/iso_combined_applied.yml +6015 -4302
- data/spec/vcr_cassetes/iso_combined_included.yml +6009 -4296
- data/spec/vcr_cassetes/iso_dis.yml +2864 -2010
- data/spec/vcr_cassetes/ogc_19_025r1.yml +188 -187
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +874 -843
- data/spec/vcr_cassetes/rfc_8341.yml +121 -119
- metadata +52 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7be94378a2b5db79e7d691b60adecffc374cca416925cc5a04468d983487c30
|
4
|
+
data.tar.gz: c720f3b6d60d1515267c9b2b7936f2585dc1c72095688f06ce3060b0dd13fcb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19abb6e8fcd9a2580ca2f421b96d0b0476fec2e2b62123f5d7d91df6da276d33d172fb935199a6c40e6e8878f2b036760b9ccc68dd5b698d13c60f3b388c6cb9
|
7
|
+
data.tar.gz: 84cf9a0feaba73525ac77ea313bc2a74098788156b6920649a32994abe8e9f795536e2fbe368bf4c86e1cee75021d8ea6693d535e5f9853c1fa5047fed4c04b7
|
data/docs/README.adoc
CHANGED
@@ -75,16 +75,16 @@ e.g. `get("ISO 19115-1", "2014", all_parts: true)` is transformed into a referen
|
|
75
75
|
* If an ISO entry has no date, the latest version available for the entry is retrieved.
|
76
76
|
* If a cached ISO entry has no date, and was last retrieved more than 60 days ago, the gem fetches it again, in case there is a newer edition of the standard available.
|
77
77
|
* Entries are always saved to the cache with a scope-wrapped identifier; e.g. under `ISO(ISO 639-1)`, and not `ISO 639-1`.
|
78
|
-
* Note that the gem does not currently support the totality of the Relaton model; it will only support the information available
|
78
|
+
* Note that the gem does not currently support the totality of the Relaton model; it will only support the information available on the source websites. We do not expect to support cartographic information, for example.
|
79
79
|
* Document identifiers are returned with a scope indication (`@idtype`); for example, `<docidentifier type="IETF">RFC 8000</docidentifier>`. It is up to the client whether to render this with the scope indication (_IETF RFC 8000_) or without (_RFC 8000_).
|
80
80
|
|
81
81
|
== Usage
|
82
82
|
|
83
83
|
=== Configuration
|
84
84
|
|
85
|
-
* `
|
86
|
-
* `use_api` - `true` if it needs to use an online cache, `false`
|
87
|
-
* `api_host` -
|
85
|
+
* `logger` - `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level.
|
86
|
+
* `use_api` - `true` if it needs to use an online cache, `false` if not. The default value is `true`.
|
87
|
+
* `api_host` - URL of an online cache. The default value is https://api.relaton.org.
|
88
88
|
|
89
89
|
[source,ruby]
|
90
90
|
----
|
@@ -92,7 +92,7 @@ require "relaton"
|
|
92
92
|
=> true
|
93
93
|
|
94
94
|
Relaton.configure do |conf|
|
95
|
-
conf.
|
95
|
+
conf.logger.level = Logger::DEBUG
|
96
96
|
conf.use_api = true
|
97
97
|
conf.api_host = "https://api.relaton.org"
|
98
98
|
end
|
@@ -173,31 +173,32 @@ Arguments:
|
|
173
173
|
* `year` - (String or nil) year to filter relult (optional)
|
174
174
|
* `options` - (Hash) hash of options. Alloved options:
|
175
175
|
- `:all_parts` - (Boolean) should be `true` if all-parts reference is required
|
176
|
-
- `:keep_yer` - (Boolean) should be `true` if undated reference should return actual reference with year
|
176
|
+
- `:keep_yer` - (Boolean) should be `true` if undated reference should return an actual reference with the year
|
177
177
|
- `:retries` - (Number) number of network retries. Default 1
|
178
|
+
- `:no_cache` - (Boolean) should be `true` if cache should be ignored
|
178
179
|
|
179
180
|
[source,ruby]
|
180
181
|
----
|
181
182
|
x = db.fetch("IEEE 19011")
|
182
|
-
[relaton-ieee] (
|
183
|
-
[relaton-ieee] WARNING: no match found online for IEEE 19011
|
183
|
+
[relaton-ieee] (IEEE 19011) fetching...
|
184
|
+
[relaton-ieee] WARNING: no match found online for `IEEE 19011`. The code must be exactly like it is on the standards website.
|
184
185
|
=> nil
|
185
186
|
|
186
187
|
x = db.fetch("ISO 19011")
|
187
|
-
[relaton-iso] (
|
188
|
-
[relaton-iso] (
|
188
|
+
[relaton-iso] (ISO 19011) fetching...
|
189
|
+
[relaton-iso] (ISO 19011) found `ISO 19011 (all parts)`
|
189
190
|
=> #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d0ab2f00
|
190
191
|
...
|
191
192
|
|
192
193
|
x = db.fetch("ISO 19011", "2011", retries: 3)
|
193
|
-
[relaton-iso] (
|
194
|
-
[relaton-iso] (
|
194
|
+
[relaton-iso] (ISO 19011) fetching...
|
195
|
+
[relaton-iso] (ISO 19011) found `ISO 19011:2011`
|
195
196
|
=> #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d2593068
|
196
197
|
...
|
197
198
|
|
198
199
|
x = db.fetch("ISO 19115", nil, all_parts: true)
|
199
|
-
[relaton-iso] (
|
200
|
-
[relaton-iso] (
|
200
|
+
[relaton-iso] (ISO 19115) fetching...
|
201
|
+
[relaton-iso] (ISO 19115) found `ISO 19115 (all parts)`
|
201
202
|
=> #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d0ae8bf0
|
202
203
|
...
|
203
204
|
|
@@ -241,8 +242,8 @@ This functionality works only for IEC documents.
|
|
241
242
|
[source,ruby]
|
242
243
|
----
|
243
244
|
x = db.fetch "urn:iec:std:iec:60050-102:2007:::"
|
244
|
-
[relaton-iec] (
|
245
|
-
[relaton-iec] (
|
245
|
+
[relaton-iec] (IEC 60050-102) fetching...
|
246
|
+
[relaton-iec] (IEC 60050-102) found `IEC 60050-102:2007`
|
246
247
|
=> #<RelatonIec::IecBibliographicItem:0x007fbd6c3790e8
|
247
248
|
...
|
248
249
|
----
|
@@ -255,10 +256,10 @@ This functionality works only for ISO, IEC, ITU, and NIST documents.
|
|
255
256
|
[source,ruby]
|
256
257
|
----
|
257
258
|
bib = db.fetch "ISO 19115-1 + Amd 1"
|
258
|
-
[relaton-iso] (
|
259
|
-
[relaton-iso] (
|
260
|
-
[relaton-iso] (
|
261
|
-
[relaton-iso] (
|
259
|
+
[relaton-iso] (ISO 19115-1) fetching...
|
260
|
+
[relaton-iso] (ISO 19115-1) found `ISO 19115-1:2014`
|
261
|
+
[relaton-iso] (ISO 19115-1/Amd 1) fetching...
|
262
|
+
[relaton-iso] (ISO 19115-1/Amd 1) found ISO `19115-1:2014/Amd 1:2018`
|
262
263
|
=> #<RelatonIsoBib::IsoBibliographicItem:0x007f95a929a748
|
263
264
|
|
264
265
|
bib.docidentifier[0].id
|
@@ -300,10 +301,10 @@ bib.relation[1].bibitem.docidentifier[0].id
|
|
300
301
|
----
|
301
302
|
bib = db.fetch "ISO 19115-1, Amd 1"
|
302
303
|
=> ["Chinese Standard", "GB/T 1.1"]
|
303
|
-
[relaton-iso] (
|
304
|
-
[relaton-iso] (
|
305
|
-
[relaton-iso] (
|
306
|
-
[relaton-iso] (
|
304
|
+
[relaton-iso] (ISO 19115-1) fetching...
|
305
|
+
[relaton-iso] (ISO 19115-1) found ISO `19115-1:2014`
|
306
|
+
[relaton-iso] (ISO 19115-1/Amd 1) fetching...
|
307
|
+
[relaton-iso] (ISO 19115-1/Amd 1) found ISO `19115-1:2014/Amd 1:2018`
|
307
308
|
=> #<RelatonIsoBib::IsoBibliographicItem:0x007fb09b36d1b8
|
308
309
|
...
|
309
310
|
----
|
data/lib/relaton/config.rb
CHANGED
@@ -1,27 +1,18 @@
|
|
1
1
|
module Relaton
|
2
2
|
module Config
|
3
|
-
|
4
|
-
if block_given?
|
5
|
-
yield configuration
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def configuration
|
10
|
-
@configuration ||= Configuration.new
|
11
|
-
end
|
3
|
+
include RelatonBib::Config
|
12
4
|
end
|
5
|
+
extend Config
|
13
6
|
|
14
|
-
class Configuration
|
15
|
-
|
7
|
+
class Configuration < RelatonBib::Configuration
|
8
|
+
PROGNAME = "relaton".freeze
|
16
9
|
|
17
|
-
|
18
|
-
@logs = %i(info error) # allowed values: :info, :warning, :error, :debug
|
10
|
+
attr_accessor :use_api, :api_host
|
19
11
|
|
20
|
-
|
12
|
+
def initialize
|
13
|
+
super
|
21
14
|
@use_api = false
|
22
15
|
@api_host = "https://api.relaton.org"
|
23
16
|
end
|
24
17
|
end
|
25
|
-
|
26
|
-
extend Config
|
27
18
|
end
|
data/lib/relaton/db.rb
CHANGED
@@ -45,6 +45,7 @@ module Relaton
|
|
45
45
|
# @option opts [Boolean] :keep_year If undated reference should return
|
46
46
|
# actual reference with year
|
47
47
|
# @option opts [Integer] :retries (1) Number of network retries
|
48
|
+
# @option opts [Boolean] :no_cache If true then don't use cache
|
48
49
|
#
|
49
50
|
# @return [nil, RelatonBib::BibliographicItem,
|
50
51
|
# RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
|
@@ -111,7 +112,7 @@ module Relaton
|
|
111
112
|
rescue RelatonBib::RequestError => e
|
112
113
|
args[3].call e
|
113
114
|
rescue StandardError => e
|
114
|
-
Util.
|
115
|
+
Util.error "ERROR: `#{args[0]}` -- #{e.message}"
|
115
116
|
args[3].call nil
|
116
117
|
end
|
117
118
|
@queues[stdclass] = { queue: SizedQueue.new(threads * 2), workers_pool: wp }
|
@@ -420,6 +421,7 @@ module Relaton
|
|
420
421
|
# @option opts [Boolean, nil] :keep_year If true then undated reference
|
421
422
|
# should return actual reference with year
|
422
423
|
# @option opts [Integer] :retries (1) Number of network retries
|
424
|
+
# @option opts [Boolean] :no_cache If true then don't use cache
|
423
425
|
#
|
424
426
|
# @param stdclass [Symbol]
|
425
427
|
# @param db [Relaton::DbCache,`nil]
|
@@ -428,32 +430,40 @@ module Relaton
|
|
428
430
|
# @return [String] bibliographic entry
|
429
431
|
# XML or "redirection ID" or "not_found YYYY-MM-DD" string
|
430
432
|
#
|
431
|
-
def new_bib_entry(code, year, opts, stdclass, **args)
|
433
|
+
def new_bib_entry(code, year, opts, stdclass, **args)
|
432
434
|
entry = @semaphore.synchronize { args[:db] && args[:db][args[:id]] }
|
433
|
-
if entry
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
return
|
435
|
+
return fetch_entry(code, year, opts, stdclass, **args) if !entry || opts[:no_cache]
|
436
|
+
|
437
|
+
if entry&.match?(/^not_found/)
|
438
|
+
Util.warn "(#{code}) not found in cache, if you wish to " \
|
439
|
+
"ignore cache please use `no-cache` option."
|
440
|
+
return
|
439
441
|
end
|
442
|
+
entry
|
443
|
+
end
|
440
444
|
|
445
|
+
def fetch_entry(code, year, opts, stdclass, **args)
|
441
446
|
processor = @registry.processors[stdclass]
|
442
447
|
bib = net_retry(code, year, opts, processor, opts.fetch(:retries, 1))
|
443
|
-
bib_id = bib&.docidentifier&.first&.id
|
444
448
|
|
445
|
-
|
446
|
-
entry = if args[:db] && args[:id] && bib_id && args[:id] !~ %r{#{Regexp.quote("(#{bib_id})")}}
|
447
|
-
bid = std_id(bib.docidentifier.first.id, nil, {}, stdclass).first
|
448
|
-
@semaphore.synchronize { args[:db][bid] ||= bib_entry bib }
|
449
|
-
"redirection #{bid}"
|
450
|
-
else bib_entry bib
|
451
|
-
end
|
449
|
+
entry = check_entry(bib, stdclass, **args)
|
452
450
|
return entry if args[:db].nil? || args[:id].nil?
|
453
451
|
|
454
452
|
@semaphore.synchronize { args[:db][args[:id]] ||= entry }
|
455
453
|
end
|
456
454
|
|
455
|
+
def check_entry(bib, stdclass, **args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
456
|
+
bib_id = bib&.docidentifier&.first&.id
|
457
|
+
|
458
|
+
# when docid doesn't match bib's id then return a reference to bib's id
|
459
|
+
if args[:db] && args[:id] && bib_id && args[:id] !~ %r{#{Regexp.quote("(#{bib_id})")}}
|
460
|
+
bid = std_id(bib.docidentifier.first.id, nil, {}, stdclass).first
|
461
|
+
@semaphore.synchronize { args[:db][bid] ||= bib_entry bib }
|
462
|
+
"redirection #{bid}"
|
463
|
+
else bib_entry bib
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
457
467
|
#
|
458
468
|
# @param code [String]
|
459
469
|
# @param year [String]
|
@@ -501,10 +511,7 @@ module Relaton
|
|
501
511
|
next if db.check_version?(fdir)
|
502
512
|
|
503
513
|
FileUtils.rm_rf(fdir, secure: true)
|
504
|
-
Util.
|
505
|
-
"[relaton] WARNING: cache #{fdir}: version is obsolete and cache is "\
|
506
|
-
"cleared.", :warning
|
507
|
-
)
|
514
|
+
Util.warn "WARNING: cache #{fdir}: version is obsolete and cache is cleared."
|
508
515
|
end
|
509
516
|
db
|
510
517
|
end
|
data/lib/relaton/db_cache.rb
CHANGED
data/lib/relaton/registry.rb
CHANGED
@@ -23,16 +23,16 @@ module Relaton
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def register_gems
|
26
|
-
# Util.
|
26
|
+
# Util.info("Info: detecting backends:")
|
27
27
|
|
28
28
|
SUPPORTED_GEMS.each do |b|
|
29
29
|
require b
|
30
30
|
require "#{b}/processor"
|
31
31
|
register Kernel.const_get "#{camel_case(b)}::Processor"
|
32
32
|
rescue LoadError => e
|
33
|
-
Util.
|
34
|
-
Util.
|
35
|
-
Util.
|
33
|
+
Util.error("Error: backend #{b} not present")
|
34
|
+
Util.error("Error: #{e.message}")
|
35
|
+
Util.error("Error: #{e.backtrace.join "\n"}")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -42,7 +42,7 @@ module Relaton
|
|
42
42
|
p = processor.new
|
43
43
|
return if processors[p.short]
|
44
44
|
|
45
|
-
Util.
|
45
|
+
Util.debug("processor \"#{p.short}\" registered")
|
46
46
|
processors[p.short] = p
|
47
47
|
end
|
48
48
|
|
@@ -101,9 +101,8 @@ module Relaton
|
|
101
101
|
return class_name if /^(urn:)?#{processor.prefix}(?!\w)/i.match?(ref) ||
|
102
102
|
processor.defaultprefix.match(ref)
|
103
103
|
end
|
104
|
-
Util.
|
105
|
-
|
106
|
-
WARN
|
104
|
+
Util.warn "`#{ref}` does not have a recognised prefix"
|
105
|
+
nil
|
107
106
|
end
|
108
107
|
|
109
108
|
private
|
data/lib/relaton/util.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
module Relaton
|
2
2
|
module Util
|
3
|
-
|
4
|
-
# @param type [Symbol] default :info
|
5
|
-
def self.log(message, type = :info)
|
6
|
-
log_types = Relaton.configuration.logs.map(&:to_s) || []
|
3
|
+
extend RelatonBib::Util
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
5
|
+
def self.logger
|
6
|
+
Relaton.configuration.logger
|
11
7
|
end
|
12
8
|
end
|
13
9
|
end
|
data/lib/relaton/version.rb
CHANGED
data/lib/relaton.rb
CHANGED
data/relaton.gemspec
CHANGED
@@ -29,29 +29,29 @@ Gem::Specification.new do |spec|
|
|
29
29
|
# spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
30
30
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
31
31
|
|
32
|
-
spec.add_dependency "relaton-3gpp", "~> 1.
|
33
|
-
spec.add_dependency "relaton-bipm", "~> 1.
|
34
|
-
spec.add_dependency "relaton-bsi", "~> 1.
|
35
|
-
spec.add_dependency "relaton-calconnect", "~> 1.
|
36
|
-
spec.add_dependency "relaton-ccsds", "~> 1.
|
37
|
-
spec.add_dependency "relaton-cen", "~> 1.
|
38
|
-
spec.add_dependency "relaton-cie", "~> 1.
|
39
|
-
spec.add_dependency "relaton-doi", "~> 1.
|
40
|
-
spec.add_dependency "relaton-ecma", "~> 1.
|
41
|
-
spec.add_dependency "relaton-gb", "~> 1.
|
42
|
-
spec.add_dependency "relaton-iana", "~> 1.
|
43
|
-
spec.add_dependency "relaton-iec", "~> 1.
|
44
|
-
spec.add_dependency "relaton-ieee", "~> 1.
|
45
|
-
spec.add_dependency "relaton-ietf", "~> 1.
|
46
|
-
spec.add_dependency "relaton-iho", "~> 1.
|
47
|
-
spec.add_dependency "relaton-iso", "~> 1.
|
48
|
-
spec.add_dependency "relaton-itu", "~> 1.
|
49
|
-
spec.add_dependency "relaton-jis", "~> 1.
|
50
|
-
spec.add_dependency "relaton-nist", "~> 1.
|
51
|
-
spec.add_dependency "relaton-oasis", "~> 1.
|
52
|
-
spec.add_dependency "relaton-ogc", "~> 1.
|
53
|
-
spec.add_dependency "relaton-omg", "~> 1.
|
54
|
-
spec.add_dependency "relaton-un", "~> 1.
|
55
|
-
spec.add_dependency "relaton-w3c", "~> 1.
|
56
|
-
spec.add_dependency "relaton-xsf", "~> 1.
|
32
|
+
spec.add_dependency "relaton-3gpp", "~> 1.16.0"
|
33
|
+
spec.add_dependency "relaton-bipm", "~> 1.16.0"
|
34
|
+
spec.add_dependency "relaton-bsi", "~> 1.16.0"
|
35
|
+
spec.add_dependency "relaton-calconnect", "~> 1.16.0"
|
36
|
+
spec.add_dependency "relaton-ccsds", "~> 1.16.0"
|
37
|
+
spec.add_dependency "relaton-cen", "~> 1.16.0"
|
38
|
+
spec.add_dependency "relaton-cie", "~> 1.16.0"
|
39
|
+
spec.add_dependency "relaton-doi", "~> 1.16.0"
|
40
|
+
spec.add_dependency "relaton-ecma", "~> 1.16.0"
|
41
|
+
spec.add_dependency "relaton-gb", "~> 1.16.0"
|
42
|
+
spec.add_dependency "relaton-iana", "~> 1.16.0"
|
43
|
+
spec.add_dependency "relaton-iec", "~> 1.16.0"
|
44
|
+
spec.add_dependency "relaton-ieee", "~> 1.16.0"
|
45
|
+
spec.add_dependency "relaton-ietf", "~> 1.16.0"
|
46
|
+
spec.add_dependency "relaton-iho", "~> 1.16.0"
|
47
|
+
spec.add_dependency "relaton-iso", "~> 1.16.0"
|
48
|
+
spec.add_dependency "relaton-itu", "~> 1.16.0"
|
49
|
+
spec.add_dependency "relaton-jis", "~> 1.16.0"
|
50
|
+
spec.add_dependency "relaton-nist", "~> 1.16.0"
|
51
|
+
spec.add_dependency "relaton-oasis", "~> 1.16.0"
|
52
|
+
spec.add_dependency "relaton-ogc", "~> 1.16.0"
|
53
|
+
spec.add_dependency "relaton-omg", "~> 1.16.0"
|
54
|
+
spec.add_dependency "relaton-un", "~> 1.16.0"
|
55
|
+
spec.add_dependency "relaton-w3c", "~> 1.16.0"
|
56
|
+
spec.add_dependency "relaton-xsf", "~> 1.16.0"
|
57
57
|
end
|
data/spec/relaton/config_spec.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
|
-
|
1
|
+
describe Relaton do
|
2
|
+
after { described_class.instance_variable_set :@configuration, nil }
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe ".configure" do
|
8
|
-
it "allows user to set custom configuration" do
|
9
|
-
log_types = ["info", :warning, :error]
|
10
|
-
|
11
|
-
Relaton.configure do |config|
|
12
|
-
config.logs = log_types
|
13
|
-
end
|
14
|
-
|
15
|
-
expect(Relaton.configuration.logs).to eq(log_types)
|
4
|
+
it "configure" do
|
5
|
+
described_class.configure do |conf|
|
6
|
+
conf.logger = :logger
|
16
7
|
end
|
17
|
-
|
18
|
-
|
19
|
-
def restore_to_default_config
|
20
|
-
Relaton.configuration.logs = %i(info error)
|
8
|
+
expect(described_class.configuration.logger).to eq :logger
|
21
9
|
end
|
22
10
|
end
|
data/spec/relaton/db_spec.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
RSpec.describe Relaton::Db do
|
2
|
-
before(:each)
|
2
|
+
before(:each) do
|
3
|
+
Relaton.instance_variable_set :@configuration, nil
|
4
|
+
FileUtils.rm_rf %w[testcache testcache2]
|
5
|
+
end
|
6
|
+
|
3
7
|
subject { Relaton::Db.new nil, nil }
|
4
8
|
|
5
9
|
context "instance methods" do
|
@@ -14,14 +18,28 @@ RSpec.describe Relaton::Db do
|
|
14
18
|
end
|
15
19
|
|
16
20
|
context "#new_bib_entry" do
|
21
|
+
let(:db) { double "db" }
|
22
|
+
before do
|
23
|
+
expect(db).to receive(:[]).with("ISO(ISO 123)").and_return "not_found"
|
24
|
+
end
|
25
|
+
|
17
26
|
it "warn if cached entry is not_found" do
|
18
|
-
id = "ISO(ISO 123)"
|
19
|
-
db = double "db"
|
20
|
-
expect(db).to receive(:[]).with(id).and_return "not_found"
|
21
27
|
expect do
|
22
|
-
|
28
|
+
expect(subject).to_not receive(:fetch_entry)
|
29
|
+
entry = subject.send :new_bib_entry, "ISO 123", nil, {}, :relaton_iso, db: db, id: "ISO(ISO 123)"
|
23
30
|
expect(entry).to be_nil
|
24
|
-
end.to output("[relaton] (ISO 123) not found
|
31
|
+
end.to output("[relaton] (ISO 123) not found in cache, if you wish " \
|
32
|
+
"to ignore cache please use `no-cache` option.\n").to_stderr
|
33
|
+
end
|
34
|
+
|
35
|
+
it "ignore cache" do
|
36
|
+
expect(subject).to receive(:fetch_entry).with(
|
37
|
+
"ISO 123", nil, { no_cache: true }, :relaton_iso, db: db, id: "ISO(ISO 123)",
|
38
|
+
).and_return :entry
|
39
|
+
entry = subject.send(
|
40
|
+
:new_bib_entry, "ISO 123", nil, { no_cache: true }, :relaton_iso, db: db, id: "ISO(ISO 123)"
|
41
|
+
)
|
42
|
+
expect(entry).to be :entry
|
25
43
|
end
|
26
44
|
end
|
27
45
|
|
@@ -74,8 +92,7 @@ RSpec.describe Relaton::Db do
|
|
74
92
|
end
|
75
93
|
|
76
94
|
it "warn if moving in existed dir" do
|
77
|
-
expect(File).to receive(:exist?).with("new_cache_dir")
|
78
|
-
.and_return true
|
95
|
+
expect(File).to receive(:exist?).with("new_cache_dir").and_return true
|
79
96
|
expect do
|
80
97
|
expect(db.mv("new_cache_dir")).to be_nil
|
81
98
|
end.to output(/\[relaton\] WARNING: target directory exists/).to_stderr
|
@@ -250,11 +267,11 @@ RSpec.describe Relaton::Db do
|
|
250
267
|
|
251
268
|
it "handle other errors" do
|
252
269
|
expect(subject).to receive(:fetch).and_raise Errno::EACCES
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
270
|
+
log_io = Relaton.configuration.logger.instance_variable_get(:@logdev)
|
271
|
+
expect(log_io).to receive(:write).with("[relaton] ERROR: `ISO REF` -- Permission denied\n")
|
272
|
+
subject.fetch_async("ISO REF") { |r| queue << r }
|
273
|
+
result = Timeout.timeout(5) { queue.pop }
|
274
|
+
expect(result).to be_nil
|
258
275
|
end
|
259
276
|
|
260
277
|
it "use threads number from RELATON_FETCH_PARALLEL" do
|
data/spec/relaton/util_spec.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
it "
|
3
|
-
expect
|
4
|
-
Relaton::Util.log("Kolbe & Gröger 2003")
|
5
|
-
end.to output("Kolbe & Gröger 2003\n").to_stderr
|
1
|
+
describe Relaton::Util do
|
2
|
+
it "#respond_to_missing?" do
|
3
|
+
expect(described_class.respond_to?(:warn)).to be true
|
6
4
|
end
|
7
5
|
end
|
data/spec/relaton_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -29,7 +29,7 @@ http_interactions:
|
|
29
29
|
Content-Type:
|
30
30
|
- application/zip
|
31
31
|
Etag:
|
32
|
-
- W/"
|
32
|
+
- W/"412e4200abff37f56f5d0d54fc88e9b34250281dadc34cec531c3fafd5be5e31"
|
33
33
|
Strict-Transport-Security:
|
34
34
|
- max-age=31536000
|
35
35
|
X-Content-Type-Options:
|
@@ -39,21 +39,21 @@ http_interactions:
|
|
39
39
|
X-Xss-Protection:
|
40
40
|
- 1; mode=block
|
41
41
|
X-Github-Request-Id:
|
42
|
-
-
|
42
|
+
- CD9A:2000:A02E34:C8AACE:65103ACB
|
43
43
|
Accept-Ranges:
|
44
44
|
- bytes
|
45
45
|
Date:
|
46
|
-
-
|
46
|
+
- Sun, 24 Sep 2023 13:34:05 GMT
|
47
47
|
Via:
|
48
48
|
- 1.1 varnish
|
49
49
|
X-Served-By:
|
50
|
-
- cache-
|
50
|
+
- cache-pdk-kpdk1780097-PDK
|
51
51
|
X-Cache:
|
52
52
|
- MISS
|
53
53
|
X-Cache-Hits:
|
54
54
|
- '0'
|
55
55
|
X-Timer:
|
56
|
-
-
|
56
|
+
- S1695562446.735257,VS0,VE250
|
57
57
|
Vary:
|
58
58
|
- Authorization,Accept-Encoding,Origin
|
59
59
|
Access-Control-Allow-Origin:
|
@@ -61,16 +61,16 @@ http_interactions:
|
|
61
61
|
Cross-Origin-Resource-Policy:
|
62
62
|
- cross-origin
|
63
63
|
X-Fastly-Request-Id:
|
64
|
-
-
|
64
|
+
- 45d49ca1c15e12a68b44f6719551e045ba6a2164
|
65
65
|
Expires:
|
66
|
-
-
|
66
|
+
- Sun, 24 Sep 2023 13:39:05 GMT
|
67
67
|
Source-Age:
|
68
68
|
- '0'
|
69
69
|
body:
|
70
70
|
encoding: UTF-8
|
71
71
|
base64_string: |
|
72
|
-
|
73
|
-
|
72
|
+
UEsDBBQAAAAIABJyNldm2jZFNLUHABZeUAANABwAaW5kZXgtdjEueWFtbFVU
|
73
|
+
CQADxKENZYmiDWV1eAsAAQTpAwAABH8AAACM/cGuLTuOJArO31fkD0TeLblc
|
74
74
|
Lt1pVQI96AQebkQANTt4qMyHfkD1qGpQ/fd9li+XRK1FM+PoIuJssyWXKJIi
|
75
75
|
Kepvf/vb//G3f/nz//mPP//lH3/9y8/Pv/6kf/75z3//x9//OP719//4P/7l
|
76
76
|
X/78v/+f//Gff/7Lf/xf/+v/+uMff/16/8mv15/8uv/kX/9//9f/939AjqQ5
|
@@ -11296,10 +11296,10 @@ http_interactions:
|
|
11296
11296
|
rrxmUhWRmbSOyEyqIjKT1hGZSVVEZtI6IjOpishMWkdkJlURmUkqIv8ru70S
|
11297
11297
|
Z9ntlShFt1eiLLu9EqWomSbKsmb6RtFjvKxTflAWU9AH5WMG+qAsJo4Pyse8
|
11298
11298
|
saB8TGMLykYoRc00UZY10w+KGpdlz1iiFJXXRFlWXhOlqLwmSqq8/h9QSwEC
|
11299
|
-
|
11300
|
-
|
11299
|
+
HgMUAAAACAAScjZXZto2RTS1BwAWXlAADQAYAAAAAAABAAAApIEAAAAAaW5k
|
11300
|
+
ZXgtdjEueWFtbFVUBQADxKENZXV4CwABBOkDAAAEfwAAAFBLBQYAAAAAAQAB
|
11301
11301
|
AFMAAAB7tQcAAAA=
|
11302
|
-
recorded_at:
|
11302
|
+
recorded_at: Sun, 24 Sep 2023 13:34:06 GMT
|
11303
11303
|
- request:
|
11304
11304
|
method: get
|
11305
11305
|
uri: https://raw.githubusercontent.com/relaton/relaton-data-3gpp/main/data/TR_00.01U_UMTS_3.0.0.yaml
|
@@ -11341,21 +11341,21 @@ http_interactions:
|
|
11341
11341
|
X-Xss-Protection:
|
11342
11342
|
- 1; mode=block
|
11343
11343
|
X-Github-Request-Id:
|
11344
|
-
-
|
11344
|
+
- B68A:1CA3:A85674:D0D6EB:65103ACE
|
11345
11345
|
Accept-Ranges:
|
11346
11346
|
- bytes
|
11347
11347
|
Date:
|
11348
|
-
-
|
11348
|
+
- Sun, 24 Sep 2023 13:34:09 GMT
|
11349
11349
|
Via:
|
11350
11350
|
- 1.1 varnish
|
11351
11351
|
X-Served-By:
|
11352
|
-
- cache-
|
11352
|
+
- cache-pdk-kpdk1780141-PDK
|
11353
11353
|
X-Cache:
|
11354
11354
|
- MISS
|
11355
11355
|
X-Cache-Hits:
|
11356
11356
|
- '0'
|
11357
11357
|
X-Timer:
|
11358
|
-
-
|
11358
|
+
- S1695562449.997647,VS0,VE147
|
11359
11359
|
Vary:
|
11360
11360
|
- Authorization,Accept-Encoding,Origin
|
11361
11361
|
Access-Control-Allow-Origin:
|
@@ -11363,9 +11363,9 @@ http_interactions:
|
|
11363
11363
|
Cross-Origin-Resource-Policy:
|
11364
11364
|
- cross-origin
|
11365
11365
|
X-Fastly-Request-Id:
|
11366
|
-
-
|
11366
|
+
- 6db14bf6dacd022648c2c54d19a2cdcd67ecf039
|
11367
11367
|
Expires:
|
11368
|
-
-
|
11368
|
+
- Sun, 24 Sep 2023 13:39:09 GMT
|
11369
11369
|
Source-Age:
|
11370
11370
|
- '0'
|
11371
11371
|
body:
|
@@ -11406,5 +11406,5 @@ http_interactions:
|
|
11406
11406
|
bWVldGluZzogU01HLTI4CiAgZnJlZXplX3N0YWdlMl9tZWV0aW5nOiBTTUct
|
11407
11407
|
MjgKICBmcmVlemVfc3RhZ2UzX21lZXRpbmc6IFNNRy0yOAogIGNsb3NlX21l
|
11408
11408
|
ZXRpbmc6IFNQLTI4CiAgcHJvamVjdF9lbmQ6ICcxOTk5LTAyLTEyJwo=
|
11409
|
-
recorded_at:
|
11409
|
+
recorded_at: Sun, 24 Sep 2023 13:34:09 GMT
|
11410
11410
|
recorded_with: VCR 6.2.0
|