relaton 1.11.5 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/relaton/db.rb +51 -28
- data/lib/relaton/db_cache.rb +7 -1
- data/lib/relaton/version.rb +1 -1
- data/relaton.gemspec +21 -21
- data/spec/relaton/db_spec.rb +35 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +7 -7
- data/spec/vcr_cassetes/async_fetch.yml +1402 -1402
- data/spec/vcr_cassetes/bipm_i18n_async_fetch.yml +51 -259
- data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +11 -11
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +10 -10
- data/spec/vcr_cassetes/cie_001_1980.yml +10 -9
- data/spec/vcr_cassetes/ecma_6.yml +47 -15
- data/spec/vcr_cassetes/en_10160_1999.yml +27 -27
- data/spec/vcr_cassetes/fisp_140.yml +6 -6
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +6 -6
- data/spec/vcr_cassetes/iana_service_names_port_numbers.yml +10 -13
- data/spec/vcr_cassetes/iec_60050_102_2007.yml +28 -28
- data/spec/vcr_cassetes/iec_combined_included.yml +88 -88
- data/spec/vcr_cassetes/ieee_528_2019.yml +823 -1133
- data/spec/vcr_cassetes/iho_b_11.yml +7 -7
- data/spec/vcr_cassetes/iso_111111119115_1.yml +2 -2
- data/spec/vcr_cassetes/iso_19115_1.yml +16 -16
- data/spec/vcr_cassetes/iso_19115_1_2.yml +29 -29
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +15 -15
- data/spec/vcr_cassetes/iso_19133_2005.yml +15 -15
- data/spec/vcr_cassetes/iso_combined_applied.yml +30 -30
- data/spec/vcr_cassetes/iso_combined_included.yml +31 -31
- data/spec/vcr_cassetes/iso_dis_14093.yml +14 -14
- data/spec/vcr_cassetes/itu_combined_included.yml +168 -168
- data/spec/vcr_cassetes/oasis_amqp_core_types_v1_0_pt1.yml +9 -9
- data/spec/vcr_cassetes/ogc_19_025r1.yml +7 -7
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +4 -4
- data/spec/vcr_cassetes/rfc_8341.yml +10 -10
- data/spec/vcr_cassetes/sp_800_38b.yml +6 -6
- data/spec/vcr_cassetes/threads_from_env.yml +56 -56
- data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +31 -29
- data/spec/vcr_cassetes/w3c_json_ld11.yml +20 -20
- metadata +44 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d1245a5e26b3bf22fef51b47397cf229876b56e026e1342a80e3da129c44fad
|
4
|
+
data.tar.gz: d13c8549f75408f841ed17f6781d7b33b6cd94586b6e8775928481a045b5c0c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bcdd489f5db390837007665cac0e796ca37e3791b42c9d4eae575b04b30555882b0ad07bb0b9f8cf1c2dec03d9a51a61374a4a9b7c1cc907c9cc6f988ec7a8b
|
7
|
+
data.tar.gz: 821809065cd6837638ae14a029f9a6eaad48f9d4cfd1a4d90470e6acd3dbaffa9bc8590fdbb81ed8f9193e91bfe3e7f46bbbb1eee941e7bc8decd7406d3dab54
|
data/lib/relaton/db.rb
CHANGED
@@ -208,7 +208,7 @@ module Relaton
|
|
208
208
|
end
|
209
209
|
|
210
210
|
# @param file [String] file path
|
211
|
-
# @param content [String] content in XML or
|
211
|
+
# @param content [String] content in XML or YAML format
|
212
212
|
# @param edition [String, nil] edition to filter
|
213
213
|
# @param year [Integer, nil] year to filter
|
214
214
|
# @return [BibliographicItem, nil]
|
@@ -217,7 +217,7 @@ module Relaton
|
|
217
217
|
item = if file.match?(/xml$/) then processor.from_xml(content)
|
218
218
|
else processor.hash_to_bib(YAML.safe_load(content))
|
219
219
|
end
|
220
|
-
item if (edition.nil? || item.edition == edition) && (year.nil? ||
|
220
|
+
item if (edition.nil? || item.edition.content == edition) && (year.nil? ||
|
221
221
|
item.date.detect { |d| d.type == "published" && d.on(:year).to_s == year.to_s })
|
222
222
|
end
|
223
223
|
|
@@ -305,8 +305,10 @@ module Relaton
|
|
305
305
|
[prefix, code]
|
306
306
|
end
|
307
307
|
|
308
|
-
#
|
308
|
+
#
|
309
|
+
# @param entry [String, nil] XML string
|
309
310
|
# @param stdclass [Symbol]
|
311
|
+
#
|
310
312
|
# @return [nil, RelatonBib::BibliographicItem,
|
311
313
|
# RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
|
312
314
|
# RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
|
@@ -316,8 +318,8 @@ module Relaton
|
|
316
318
|
# RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
|
317
319
|
# RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
|
318
320
|
def bib_retval(entry, stdclass)
|
319
|
-
if entry
|
320
|
-
|
321
|
+
if entry && !entry.match?(/^not_found/)
|
322
|
+
@registry.processors[stdclass].from_xml(entry)
|
321
323
|
end
|
322
324
|
end
|
323
325
|
|
@@ -346,8 +348,7 @@ module Relaton
|
|
346
348
|
if db.nil?
|
347
349
|
return if opts[:fetch_db]
|
348
350
|
|
349
|
-
bibentry = new_bib_entry(searchcode, year, opts, stdclass
|
350
|
-
id: id)
|
351
|
+
bibentry = new_bib_entry(searchcode, year, opts, stdclass)
|
351
352
|
return bib_retval(bibentry, stdclass)
|
352
353
|
end
|
353
354
|
|
@@ -360,45 +361,61 @@ module Relaton
|
|
360
361
|
@semaphore.synchronize do
|
361
362
|
db.clone_entry id, altdb if altdb.valid_entry? id, year
|
362
363
|
end
|
363
|
-
|
364
|
+
new_bib_entry(searchcode, year, opts, stdclass, db: db, id: id)
|
364
365
|
@semaphore.synchronize do
|
365
|
-
db[id] ||= entry
|
366
366
|
altdb.clone_entry(id, db) if !altdb.valid_entry?(id, year)
|
367
367
|
end
|
368
368
|
else
|
369
369
|
return bib_retval(db[id], stdclass) if opts[:fetch_db]
|
370
370
|
|
371
|
-
|
372
|
-
@semaphore.synchronize { db[id] ||= entry }
|
371
|
+
new_bib_entry(searchcode, year, opts, stdclass, db: db, id: id)
|
373
372
|
end
|
374
373
|
bib_retval(db[id], stdclass)
|
375
374
|
end
|
376
375
|
|
376
|
+
#
|
377
|
+
# Create new bibliographic entry if it doesn't exist in database
|
378
|
+
#
|
377
379
|
# @param code [String]
|
378
380
|
# @param year [String]
|
379
381
|
#
|
380
382
|
# @param opts [Hash]
|
381
|
-
# @option opts [Boolean] :all_parts If all-parts reference is
|
382
|
-
#
|
383
|
-
#
|
383
|
+
# @option opts [Boolean, nil] :all_parts If true then all-parts reference is
|
384
|
+
# requested
|
385
|
+
# @option opts [Boolean, nil] :keep_year If true then undated reference
|
386
|
+
# should return actual reference with year
|
384
387
|
# @option opts [Integer] :retries (1) Number of network retries
|
385
388
|
#
|
386
389
|
# @param stdclass [Symbol]
|
387
|
-
# @param db [Relaton::DbCache,`
|
388
|
-
# @param id [String] docid
|
389
|
-
#
|
390
|
-
|
390
|
+
# @param db [Relaton::DbCache,`nil]
|
391
|
+
# @param id [String, nil] docid
|
392
|
+
#
|
393
|
+
# @return [String] bibliographic entry
|
394
|
+
# XML or "redirection ID" or "not_found YYYY-MM-DD" string
|
395
|
+
#
|
396
|
+
def new_bib_entry(code, year, opts, stdclass, **args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
397
|
+
entry = @semaphore.synchronize { args[:db] && args[:db][args[:id]] }
|
398
|
+
if entry
|
399
|
+
if entry&.match?(/^not_found/)
|
400
|
+
Util.log "[relaton] (#{code}) not found."
|
401
|
+
return
|
402
|
+
end
|
403
|
+
return entry
|
404
|
+
end
|
405
|
+
|
391
406
|
bib = net_retry(code, year, opts, stdclass, opts.fetch(:retries, 1))
|
392
407
|
bib_id = bib&.docidentifier&.first&.id
|
393
408
|
|
394
409
|
# when docid doesn't match bib's id then return a reference to bib's id
|
395
|
-
if args[:db] && args[:id] &&
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
410
|
+
entry = if args[:db] && args[:id] && bib_id && args[:id] !~ %r{#{Regexp.quote("(#{bib_id})")}}
|
411
|
+
bid = std_id(bib.docidentifier.first.id, nil, {}, stdclass).first
|
412
|
+
@semaphore.synchronize { args[:db][bid] ||= bib_entry bib }
|
413
|
+
"redirection #{bid}"
|
414
|
+
else bib_entry bib
|
415
|
+
end
|
416
|
+
return entry if args[:db].nil? || args[:id].nil?
|
417
|
+
|
418
|
+
@semaphore.synchronize { args[:db][args[:id]] ||= entry }
|
402
419
|
end
|
403
420
|
|
404
421
|
# @raise [RelatonBib::RequestError]
|
@@ -454,10 +471,16 @@ module Relaton
|
|
454
471
|
end
|
455
472
|
|
456
473
|
class << self
|
474
|
+
#
|
457
475
|
# Initialse and return relaton instance, with local and global cache names
|
458
|
-
#
|
459
|
-
#
|
460
|
-
#
|
476
|
+
#
|
477
|
+
# @param local_cache [String, nil] local cache name;
|
478
|
+
# "relaton" created if empty or nil
|
479
|
+
# @param global_cache [Boolean, nil] create global_cache if true
|
480
|
+
# @param flush_caches [Boolean, nil] flush caches if true
|
481
|
+
#
|
482
|
+
# @return [Relaton::Db] relaton DB instance
|
483
|
+
#
|
461
484
|
def init_bib_caches(**opts) # rubocop:disable Metrics/CyclomaticComplexity
|
462
485
|
globalname = global_bibliocache_name if opts[:global_cache]
|
463
486
|
localname = local_bibliocache_name(opts[:local_cache])
|
data/lib/relaton/db_cache.rb
CHANGED
@@ -45,7 +45,7 @@ module Relaton
|
|
45
45
|
end
|
46
46
|
|
47
47
|
prefix_dir = "#{@dir}/#{prefix(key)}"
|
48
|
-
FileUtils::mkdir_p prefix_dir
|
48
|
+
FileUtils::mkdir_p prefix_dir
|
49
49
|
set_version prefix_dir
|
50
50
|
file_safe_write "#{filename(key)}.#{ext(value)}", value
|
51
51
|
end
|
@@ -72,6 +72,12 @@ module Relaton
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
#
|
76
|
+
# Save entry from cache of `db` to this cache.
|
77
|
+
#
|
78
|
+
# @param [String] key key of the entry
|
79
|
+
# @param [Relaton::Db] db database
|
80
|
+
#
|
75
81
|
def clone_entry(key, db)
|
76
82
|
self[key] ||= db.get(key)
|
77
83
|
if (code = redirect? get(key))
|
data/lib/relaton/version.rb
CHANGED
data/relaton.gemspec
CHANGED
@@ -29,27 +29,27 @@ 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-cen", "~> 1.
|
37
|
-
spec.add_dependency "relaton-cie", "~> 1.
|
38
|
-
spec.add_dependency "relaton-ecma", "~> 1.
|
39
|
-
spec.add_dependency "relaton-gb", "~> 1.
|
40
|
-
spec.add_dependency "relaton-iana", "~> 1.
|
41
|
-
spec.add_dependency "relaton-iec", "~> 1.
|
42
|
-
spec.add_dependency "relaton-ieee", "~> 1.
|
43
|
-
spec.add_dependency "relaton-ietf", "~> 1.
|
44
|
-
spec.add_dependency "relaton-iho", "~> 1.
|
45
|
-
spec.add_dependency "relaton-iso", "~> 1.
|
46
|
-
spec.add_dependency "relaton-itu", "~> 1.
|
47
|
-
spec.add_dependency "relaton-nist", "~> 1.
|
48
|
-
spec.add_dependency "relaton-oasis", "~> 1.
|
49
|
-
spec.add_dependency "relaton-ogc", "~> 1.
|
50
|
-
spec.add_dependency "relaton-omg", "~> 1.
|
51
|
-
spec.add_dependency "relaton-un", "~> 1.
|
52
|
-
spec.add_dependency "relaton-w3c", "~> 1.
|
32
|
+
spec.add_dependency "relaton-3gpp", "~> 1.12.0"
|
33
|
+
spec.add_dependency "relaton-bipm", "~> 1.12.0"
|
34
|
+
spec.add_dependency "relaton-bsi", "~> 1.12.0"
|
35
|
+
spec.add_dependency "relaton-calconnect", "~> 1.12.0"
|
36
|
+
spec.add_dependency "relaton-cen", "~> 1.12.0"
|
37
|
+
spec.add_dependency "relaton-cie", "~> 1.12.0"
|
38
|
+
spec.add_dependency "relaton-ecma", "~> 1.12.0"
|
39
|
+
spec.add_dependency "relaton-gb", "~> 1.12.0"
|
40
|
+
spec.add_dependency "relaton-iana", "~> 1.12.0"
|
41
|
+
spec.add_dependency "relaton-iec", "~> 1.12.0"
|
42
|
+
spec.add_dependency "relaton-ieee", "~> 1.12.0"
|
43
|
+
spec.add_dependency "relaton-ietf", "~> 1.12.0"
|
44
|
+
spec.add_dependency "relaton-iho", "~> 1.12.0"
|
45
|
+
spec.add_dependency "relaton-iso", "~> 1.12.0"
|
46
|
+
spec.add_dependency "relaton-itu", "~> 1.12.0"
|
47
|
+
spec.add_dependency "relaton-nist", "~> 1.12.0"
|
48
|
+
spec.add_dependency "relaton-oasis", "~> 1.12.0"
|
49
|
+
spec.add_dependency "relaton-ogc", "~> 1.12.0"
|
50
|
+
spec.add_dependency "relaton-omg", "~> 1.12.0"
|
51
|
+
spec.add_dependency "relaton-un", "~> 1.12.0"
|
52
|
+
spec.add_dependency "relaton-w3c", "~> 1.12.0"
|
53
53
|
|
54
54
|
spec.add_development_dependency "byebug", "~> 11.0"
|
55
55
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
data/spec/relaton/db_spec.rb
CHANGED
@@ -1,6 +1,40 @@
|
|
1
1
|
RSpec.describe Relaton::Db do
|
2
2
|
before(:each) { FileUtils.rm_rf %w[testcache testcache2] }
|
3
3
|
|
4
|
+
context "instance methods" do
|
5
|
+
subject { Relaton::Db.new nil, nil }
|
6
|
+
|
7
|
+
context "#search_edition_year" do
|
8
|
+
it "create bibitem from YAML content" do
|
9
|
+
h = { "docid" => [{ "id" => "ISO 123", type: "ISO", "primary" => true }] }
|
10
|
+
expect(YAML).to receive(:safe_load).with(:content).and_return h
|
11
|
+
item = subject.send :search_edition_year, "iso/item.yaml", :content, nil, nil
|
12
|
+
expect(item).to be_instance_of RelatonIsoBib::IsoBibliographicItem
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "#new_bib_entry" do
|
17
|
+
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
|
+
expect do
|
22
|
+
entry = subject.send :new_bib_entry, "ISO 123", nil, {}, :relaton_iso, db: db, id: id
|
23
|
+
expect(entry).to be_nil
|
24
|
+
end.to output("[relaton] (ISO 123) not found.\n").to_stderr
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "class methods" do
|
30
|
+
it "::init_bib_caches" do
|
31
|
+
expect(FileUtils).to receive(:rm_rf).with(/\/\.relaton\/cache$/)
|
32
|
+
expect(FileUtils).to receive(:rm_rf).with(/testcache\/cache$/)
|
33
|
+
expect(Relaton::Db).to receive(:new).with(/\/\.relaton\/cache$/, /testcache\/cache$/)
|
34
|
+
Relaton::Db.init_bib_caches(global_cache: true, local_cache: "testcache", flush_caches: true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
4
38
|
context "modifing database" do
|
5
39
|
let(:db) { Relaton::Db.new "testcache", "testcache2" }
|
6
40
|
|
@@ -178,7 +212,7 @@ RSpec.describe Relaton::Db do
|
|
178
212
|
refs = ["CGPM Resolution 1889-00", "CGPM Résolution 1889-00",
|
179
213
|
"CGPM Réunion 9", "CGPM Meeting 9"]
|
180
214
|
results = []
|
181
|
-
VCR.use_cassette "bipm_i18n_async_fetch" do
|
215
|
+
VCR.use_cassette "bipm_i18n_async_fetch", match_requests_on: %i[method uri body] do
|
182
216
|
refs.each do |ref|
|
183
217
|
db.fetch_async(ref) { |r| queue << [r, ref] }
|
184
218
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -41,29 +41,29 @@ http_interactions:
|
|
41
41
|
X-Xss-Protection:
|
42
42
|
- 1; mode=block
|
43
43
|
X-Github-Request-Id:
|
44
|
-
-
|
44
|
+
- 7D28:10C50:1BF854C:1DDFC0B:62BDDA6B
|
45
45
|
Accept-Ranges:
|
46
46
|
- bytes
|
47
47
|
Date:
|
48
|
-
- Thu,
|
48
|
+
- Thu, 30 Jun 2022 17:16:27 GMT
|
49
49
|
Via:
|
50
50
|
- 1.1 varnish
|
51
51
|
X-Served-By:
|
52
|
-
- cache-
|
52
|
+
- cache-vie6348-VIE
|
53
53
|
X-Cache:
|
54
54
|
- MISS
|
55
55
|
X-Cache-Hits:
|
56
56
|
- '0'
|
57
57
|
X-Timer:
|
58
|
-
-
|
58
|
+
- S1656609387.047148,VS0,VE235
|
59
59
|
Vary:
|
60
60
|
- Authorization,Accept-Encoding,Origin
|
61
61
|
Access-Control-Allow-Origin:
|
62
62
|
- "*"
|
63
63
|
X-Fastly-Request-Id:
|
64
|
-
-
|
64
|
+
- 93a267346ed97c52087b05f16495084f70b848e8
|
65
65
|
Expires:
|
66
|
-
- Thu,
|
66
|
+
- Thu, 30 Jun 2022 17:21:27 GMT
|
67
67
|
Source-Age:
|
68
68
|
- '0'
|
69
69
|
body:
|
@@ -143,5 +143,5 @@ http_interactions:
|
|
143
143
|
freeze_stage3_meeting: SMG-28
|
144
144
|
close_meeting: SP-28
|
145
145
|
project_end: '1999-02-12'
|
146
|
-
recorded_at: Thu,
|
146
|
+
recorded_at: Thu, 30 Jun 2022 17:16:27 GMT
|
147
147
|
recorded_with: VCR 6.1.0
|