relaton 1.9.1 → 1.9.2
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 +7 -6
- data/lib/relaton/db.rb +7 -3
- data/lib/relaton/version.rb +1 -1
- data/spec/relaton/db_spec.rb +4 -2
- data/spec/relaton_spec.rb +7 -7
- data/spec/vcr_cassetes/async_fetch.yml +1604 -1560
- data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +15 -19
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +12 -12
- data/spec/vcr_cassetes/cen_en_10160_1999.yml +41 -41
- 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/iec_60050_102_2007.yml +28 -28
- data/spec/vcr_cassetes/iec_combined_included.yml +93 -93
- data/spec/vcr_cassetes/ieee_528_2019.yml +17 -17
- 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 +16 -16
- data/spec/vcr_cassetes/iso_19115_1_2.yml +32 -32
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +17 -17
- data/spec/vcr_cassetes/iso_19133_2005.yml +16 -16
- data/spec/vcr_cassetes/iso_cd_14093.yml +17 -17
- data/spec/vcr_cassetes/iso_combined_applied.yml +33 -33
- data/spec/vcr_cassetes/iso_combined_included.yml +32 -32
- 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 +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00617ed8db3b679a9c44d7b8854b17c16d48f10b84a30bbc2e175113d02e9025
|
4
|
+
data.tar.gz: 198a87943ebe8f2ffdeabfc0c1ec12a9499ec9642d90ca393a8c26440f3acf3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf33ca669f3b719eea8e9add8a107e9f54e86ffcfda53d3845fe5dd109f08cde651b08024dda622f5d3438f8dce51d142c8b1f886e5b45b7ef481242b9212ea
|
7
|
+
data.tar.gz: bf242855dfb87ff3920907cf69616b2831c8ce35e65342327d0cfee3182b252bbceca244fbd30cdb097f09befc90769c9c4b72847b52cea852ddd3dc9c2d7441
|
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
|
-
db.fetch_async(ref) do |doc|
|
191
|
-
results << [
|
190
|
+
db.fetch_async(ref, ref: ref) do |doc, other_args|
|
191
|
+
results << [doc, other_args[: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
@@ -99,16 +99,20 @@ module Relaton
|
|
99
99
|
end
|
100
100
|
|
101
101
|
# Fetch asynchronously
|
102
|
-
def fetch_async(code, year = nil, opts = {}, &_block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
102
|
+
def fetch_async(code, year = nil, opts = {}, **others, &_block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
103
103
|
stdclass = standard_class code
|
104
104
|
if stdclass
|
105
105
|
unless @queues[stdclass]
|
106
106
|
processor = @registry.processors[stdclass]
|
107
|
-
wp = WorkersPool.new(processor.threads)
|
107
|
+
wp = WorkersPool.new(processor.threads) do |args|
|
108
|
+
yield fetch(*args[0..2]), **args[3]
|
109
|
+
rescue RelatonBib::RequestError => e
|
110
|
+
yield e, **args[3]
|
111
|
+
end
|
108
112
|
@queues[stdclass] = { queue: Queue.new, workers_pool: wp }
|
109
113
|
Thread.new { process_queue @queues[stdclass] }
|
110
114
|
end
|
111
|
-
@queues[stdclass][:queue] << [code, year, opts]
|
115
|
+
@queues[stdclass][:queue] << [code, year, opts, others]
|
112
116
|
else yield nil
|
113
117
|
end
|
114
118
|
end
|
data/lib/relaton/version.rb
CHANGED
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, ref: ref) do |r, otherargs|
|
167
|
+
queue << [r, otherargs[: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
|
|
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
|
@@ -306,10 +306,10 @@ RSpec.describe Relaton::Db do
|
|
306
306
|
bib = @db.fetch "ISO 19115-1 + Amd 1"
|
307
307
|
expect(bib.docidentifier[0].id).to eq "ISO 19115-1 + Amd 1"
|
308
308
|
expect(bib.relation[0].type).to eq "updates"
|
309
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1
|
309
|
+
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1"
|
310
310
|
expect(bib.relation[1].type).to eq "derivedFrom"
|
311
311
|
expect(bib.relation[1].description).to be_nil
|
312
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1
|
312
|
+
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1/Amd 1:2018"
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
@@ -318,10 +318,10 @@ RSpec.describe Relaton::Db do
|
|
318
318
|
bib = @db.fetch "ISO 19115-1, Amd 1"
|
319
319
|
expect(bib.docidentifier[0].id).to eq "ISO 19115-1, Amd 1"
|
320
320
|
expect(bib.relation[0].type).to eq "updates"
|
321
|
-
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1
|
321
|
+
expect(bib.relation[0].bibitem.docidentifier[0].id).to eq "ISO 19115-1"
|
322
322
|
expect(bib.relation[1].type).to eq "complements"
|
323
323
|
expect(bib.relation[1].description.content).to eq "amendment"
|
324
|
-
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1
|
324
|
+
expect(bib.relation[1].bibitem.docidentifier[0].id).to eq "ISO 19115-1/Amd 1:2018"
|
325
325
|
end
|
326
326
|
end
|
327
327
|
end
|