relaton 1.9.1 → 1.9.5
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 +6 -5
- data/lib/relaton/db.rb +20 -9
- data/lib/relaton/registry.rb +1 -1
- data/lib/relaton/version.rb +1 -1
- data/relaton.gemspec +1 -0
- data/spec/relaton/db_spec.rb +4 -2
- data/spec/relaton/registry_spec.rb +4 -0
- data/spec/relaton_spec.rb +19 -12
- data/spec/vcr_cassetes/async_fetch.yml +1298 -1301
- data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +16 -20
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +12 -12
- data/spec/vcr_cassetes/cen_en_10160_1999.yml +38 -38
- data/spec/vcr_cassetes/cie_001_1980.yml +8 -8
- data/spec/vcr_cassetes/ecma_6.yml +8 -8
- 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 +98 -0
- data/spec/vcr_cassetes/iec_60050_102_2007.yml +28 -28
- data/spec/vcr_cassetes/iec_combined_included.yml +94 -94
- data/spec/vcr_cassetes/ieee_528_2019.yml +19 -19
- data/spec/vcr_cassetes/iho_b_11.yml +8 -8
- data/spec/vcr_cassetes/iso_111111119115_1.yml +4 -4
- data/spec/vcr_cassetes/iso_19115_1.yml +17 -17
- data/spec/vcr_cassetes/iso_19115_1_2.yml +31 -31
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +16 -16
- data/spec/vcr_cassetes/iso_19133_2005.yml +15 -15
- data/spec/vcr_cassetes/iso_cd_14093.yml +17 -17
- data/spec/vcr_cassetes/iso_combined_applied.yml +30 -30
- data/spec/vcr_cassetes/iso_combined_included.yml +33 -33
- data/spec/vcr_cassetes/itu_combined_included.yml +302 -186
- data/spec/vcr_cassetes/ogc_19_025r1.yml +17 -13159
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +4 -4
- data/spec/vcr_cassetes/rfc_8341.yml +8 -8
- data/spec/vcr_cassetes/sp_800_38b.yml +6 -6
- data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +34 -34
- data/spec/vcr_cassetes/w3c_json_ld11.yml +93 -138
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d130b4485dbbf753e79494a4d586acf8fd85df120d4e2f1f35aa5c7380e05811
|
4
|
+
data.tar.gz: 1872fc4d88f29de709f81dfca39132d1c7fb244b9069661d8c7c4bca70a80977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1209e92a74b33acc54fcc1f391ec4beb1833cb2886375188f16ff8feb6c7c12c6f2e56978b3a77b442599fafa5bfbc4b4edfec6305e422afdb97cbc3e07190a0
|
7
|
+
data.tar.gz: f5a8c37e80afa5b80d7779735d54f685e9ba85a2bea6acd2ad3a4608b4e74d75c76248b6989af7df05df1f50f975b0ab85397355c90c2c2f50bc00159fc7d5fe
|
data/docs/README.adoc
CHANGED
@@ -182,20 +182,21 @@ x = db.fetch_db("ISO 5749")
|
|
182
182
|
# prepare queue for results
|
183
183
|
results = Queue.new
|
184
184
|
|
185
|
-
# references
|
185
|
+
# references to fetch
|
186
186
|
refs = ["ISO 19011", "ISO 19115"]
|
187
187
|
|
188
188
|
# fetch documents
|
189
189
|
refs.each do |ref|
|
190
190
|
db.fetch_async(ref) do |doc|
|
191
|
-
results << [
|
191
|
+
results << [doc, ref]
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
# wait until
|
195
|
+
# wait until all the documents fetching
|
196
196
|
refs.size.times do
|
197
|
-
|
198
|
-
# do
|
197
|
+
doc, ref = results.pop
|
198
|
+
# do whatever you need with the result
|
199
|
+
# in case request error doc will be instance of Relaton::RequestError
|
199
200
|
end
|
200
201
|
----
|
201
202
|
|
data/lib/relaton/db.rb
CHANGED
@@ -17,6 +17,7 @@ module Relaton
|
|
17
17
|
@static_db = open_cache_biblio File.expand_path("../relaton/static_cache",
|
18
18
|
__dir__)
|
19
19
|
@queues = {}
|
20
|
+
@semaphore = Mutex.new
|
20
21
|
end
|
21
22
|
|
22
23
|
# Move global or local caches to anothe dirs
|
@@ -99,16 +100,20 @@ module Relaton
|
|
99
100
|
end
|
100
101
|
|
101
102
|
# Fetch asynchronously
|
102
|
-
def fetch_async(code, year = nil, opts = {}, &
|
103
|
+
def fetch_async(code, year = nil, opts = {}, &block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
103
104
|
stdclass = standard_class code
|
104
105
|
if stdclass
|
105
106
|
unless @queues[stdclass]
|
106
107
|
processor = @registry.processors[stdclass]
|
107
|
-
wp = WorkersPool.new(processor.threads)
|
108
|
+
wp = WorkersPool.new(processor.threads) do |args|
|
109
|
+
args[3].call fetch(*args[0..2])
|
110
|
+
rescue RelatonBib::RequestError => e
|
111
|
+
args[3].call e
|
112
|
+
end
|
108
113
|
@queues[stdclass] = { queue: Queue.new, workers_pool: wp }
|
109
114
|
Thread.new { process_queue @queues[stdclass] }
|
110
115
|
end
|
111
|
-
@queues[stdclass][:queue] << [code, year, opts]
|
116
|
+
@queues[stdclass][:queue] << [code, year, opts, block]
|
112
117
|
else yield nil
|
113
118
|
end
|
114
119
|
end
|
@@ -371,14 +376,20 @@ module Relaton
|
|
371
376
|
return bib_retval(bibentry, stdclass)
|
372
377
|
end
|
373
378
|
|
374
|
-
|
379
|
+
@semaphore.synchronize do
|
380
|
+
db.delete(id) unless db.valid_entry?(id, year)
|
381
|
+
end
|
375
382
|
if altdb
|
376
383
|
return bib_retval(altdb[id], stdclass) if opts[:fetch_db]
|
377
384
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
385
|
+
@semaphore.synchronize do
|
386
|
+
db.clone_entry id, altdb if altdb.valid_entry? id, year
|
387
|
+
end
|
388
|
+
entry = new_bib_entry(searchcode, year, opts, stdclass, db: db, id: id) unless db[id]
|
389
|
+
@semaphore.synchronize do
|
390
|
+
db[id] ||= entry
|
391
|
+
altdb.clone_entry(id, db) if !altdb.valid_entry?(id, year)
|
392
|
+
end
|
382
393
|
else
|
383
394
|
return bib_retval(db[id], stdclass) if opts[:fetch_db]
|
384
395
|
|
@@ -409,7 +420,7 @@ module Relaton
|
|
409
420
|
if args[:db] && args[:id] &&
|
410
421
|
bib_id && args[:id] !~ %r{#{Regexp.quote("(#{bib_id})")}}
|
411
422
|
bid = std_id(bib.docidentifier.first.id, nil, {}, stdclass).first
|
412
|
-
args[:db][bid] ||= bib_entry bib
|
423
|
+
@semaphore.synchronize { args[:db][bid] ||= bib_entry bib }
|
413
424
|
"redirection #{bid}"
|
414
425
|
else bib_entry bib
|
415
426
|
end
|
data/lib/relaton/registry.rb
CHANGED
@@ -9,7 +9,7 @@ module Relaton
|
|
9
9
|
relaton_gb relaton_iec relaton_ietf relaton_iso relaton_itu relaton_nist
|
10
10
|
relaton_ogc relaton_calconnect relaton_omg relaton_un relaton_w3c
|
11
11
|
relaton_ieee relaton_iho relaton_bipm relaton_ecma relaton_cie relaton_bsi
|
12
|
-
relaton_cen
|
12
|
+
relaton_cen relaton_iana
|
13
13
|
].freeze
|
14
14
|
|
15
15
|
include Singleton
|
data/lib/relaton/version.rb
CHANGED
data/relaton.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency "relaton-cie", "~> 1.9.0"
|
37
37
|
spec.add_dependency "relaton-ecma", "~> 1.9.0"
|
38
38
|
spec.add_dependency "relaton-gb", "~> 1.9.0"
|
39
|
+
spec.add_dependency "relaton-iana", "~> 1.9.0"
|
39
40
|
spec.add_dependency "relaton-iec", "~> 1.9.0"
|
40
41
|
spec.add_dependency "relaton-ieee", "~> 1.9.0"
|
41
42
|
spec.add_dependency "relaton-ietf", "~> 1.9.0"
|
data/spec/relaton/db_spec.rb
CHANGED
@@ -163,14 +163,16 @@ RSpec.describe Relaton::Db do
|
|
163
163
|
results = []
|
164
164
|
VCR.use_cassette "async_fetch", match_requests_on: %i[method uri body] do
|
165
165
|
refs.each do |ref|
|
166
|
-
db.fetch_async(ref)
|
166
|
+
db.fetch_async(ref) do |r|
|
167
|
+
queue << [r, ref]
|
168
|
+
end
|
167
169
|
end
|
168
170
|
Timeout.timeout(60) do
|
169
171
|
refs.size.times { results << queue.pop }
|
170
172
|
end
|
171
173
|
end
|
172
174
|
results.each do |result|
|
173
|
-
expect(result).to be_instance_of RelatonItu::ItuBibliographicItem
|
175
|
+
expect(result[0]).to be_instance_of RelatonItu::ItuBibliographicItem
|
174
176
|
end
|
175
177
|
end
|
176
178
|
|
@@ -87,6 +87,10 @@ RSpec.describe Relaton::Registry do
|
|
87
87
|
it "CEN" do
|
88
88
|
expect(Relaton::Registry.instance.by_type("CEN")).to be_instance_of RelatonCen::Processor
|
89
89
|
end
|
90
|
+
|
91
|
+
it "IANA" do
|
92
|
+
expect(Relaton::Registry.instance.by_type("IANA")).to be_instance_of RelatonIana::Processor
|
93
|
+
end
|
90
94
|
end
|
91
95
|
|
92
96
|
it "find processot by dataset" do
|
data/spec/relaton_spec.rb
CHANGED
@@ -205,12 +205,12 @@ RSpec.describe Relaton::Db do
|
|
205
205
|
|
206
206
|
it "get OGC refrence and cache it" do
|
207
207
|
cc_fr = /\.relaton\/ogc\/bibliography\.json/
|
208
|
-
|
209
|
-
|
208
|
+
allow(File).to receive(:exist?).with(cc_fr).and_return false
|
209
|
+
allow(File).to receive(:exist?).with(/etag\.txt/).and_return false
|
210
210
|
expect(File).to receive(:exist?).and_call_original.at_least :once
|
211
211
|
expect(File).to receive(:write).with(cc_fr, kind_of(String), kind_of(Hash))
|
212
212
|
.at_most :once
|
213
|
-
|
213
|
+
allow(File).to receive(:write).and_call_original
|
214
214
|
VCR.use_cassette "ogc_19_025r1" do
|
215
215
|
bib = @db.fetch "OGC 19-025r1", nil, {}
|
216
216
|
expect(bib).to be_instance_of RelatonOgc::OgcBibliographicItem
|
@@ -246,13 +246,13 @@ RSpec.describe Relaton::Db do
|
|
246
246
|
end
|
247
247
|
|
248
248
|
it "get W3C reference" do
|
249
|
-
w3c_fr = /\.relaton\/w3c\/bibliography\.yml/
|
250
|
-
expect(File).to receive(:exist?).with(w3c_fr).and_return false
|
251
|
-
expect(File).to receive(:exist?).and_call_original.at_least :once
|
252
|
-
expect(File).to receive(:write).with w3c_fr, kind_of(String), kind_of(Hash)
|
249
|
+
# w3c_fr = /\.relaton\/w3c\/bibliography\.yml/
|
250
|
+
# expect(File).to receive(:exist?).with(w3c_fr).and_return false
|
251
|
+
# expect(File).to receive(:exist?).and_call_original.at_least :once
|
252
|
+
# expect(File).to receive(:write).with w3c_fr, kind_of(String), kind_of(Hash)
|
253
253
|
# expect(File).to receive(:write).and_call_original.at_least :once
|
254
254
|
VCR.use_cassette "w3c_json_ld11" do
|
255
|
-
bib = @db.fetch "W3C
|
255
|
+
bib = @db.fetch "W3C REC-json-ld11-20200716", nil, {}
|
256
256
|
expect(bib).to be_instance_of RelatonW3c::W3cBibliographicItem
|
257
257
|
end
|
258
258
|
end
|
@@ -299,6 +299,13 @@ RSpec.describe Relaton::Db do
|
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
|
+
it "get IANA reference" do
|
303
|
+
VCR.use_cassette "iana_service_names_port_numbers" do
|
304
|
+
bib = @db.fetch "IANA service-names-port-numbers"
|
305
|
+
expect(bib).to be_instance_of RelatonBib::BibliographicItem
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
302
309
|
context "get combined documents" do
|
303
310
|
context "ISO" do
|
304
311
|
it "included" do
|
@@ -306,10 +313,10 @@ RSpec.describe Relaton::Db do
|
|
306
313
|
bib = @db.fetch "ISO 19115-1 + Amd 1"
|
307
314
|
expect(bib.docidentifier[0].id).to eq "ISO 19115-1 + Amd 1"
|
308
315
|
expect(bib.relation[0].type).to eq "updates"
|
309
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1
|
316
|
+
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1"
|
310
317
|
expect(bib.relation[1].type).to eq "derivedFrom"
|
311
318
|
expect(bib.relation[1].description).to be_nil
|
312
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1
|
319
|
+
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1/Amd 1:2018"
|
313
320
|
end
|
314
321
|
end
|
315
322
|
|
@@ -318,10 +325,10 @@ RSpec.describe Relaton::Db do
|
|
318
325
|
bib = @db.fetch "ISO 19115-1, Amd 1"
|
319
326
|
expect(bib.docidentifier[0].id).to eq "ISO 19115-1, Amd 1"
|
320
327
|
expect(bib.relation[0].type).to eq "updates"
|
321
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1
|
328
|
+
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1"
|
322
329
|
expect(bib.relation[1].type).to eq "complements"
|
323
330
|
expect(bib.relation[1].description.content).to eq "amendment"
|
324
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1
|
331
|
+
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1/Amd 1:2018"
|
325
332
|
end
|
326
333
|
end
|
327
334
|
end
|