relaton 1.9.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/docs/README.adoc +7 -6
  3. data/lib/relaton/db.rb +7 -3
  4. data/lib/relaton/version.rb +1 -1
  5. data/spec/relaton/db_spec.rb +4 -2
  6. data/spec/relaton_spec.rb +7 -7
  7. data/spec/vcr_cassetes/async_fetch.yml +1604 -1560
  8. data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +15 -19
  9. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +12 -12
  10. data/spec/vcr_cassetes/cen_en_10160_1999.yml +41 -41
  11. data/spec/vcr_cassetes/cie_001_1980.yml +8 -8
  12. data/spec/vcr_cassetes/ecma_6.yml +8 -8
  13. data/spec/vcr_cassetes/fisp_140.yml +6 -6
  14. data/spec/vcr_cassetes/gb_t_20223_2006.yml +6 -6
  15. data/spec/vcr_cassetes/iec_60050_102_2007.yml +28 -28
  16. data/spec/vcr_cassetes/iec_combined_included.yml +93 -93
  17. data/spec/vcr_cassetes/ieee_528_2019.yml +17 -17
  18. data/spec/vcr_cassetes/iho_b_11.yml +8 -8
  19. data/spec/vcr_cassetes/iso_111111119115_1.yml +4 -4
  20. data/spec/vcr_cassetes/iso_19115_1.yml +16 -16
  21. data/spec/vcr_cassetes/iso_19115_1_2.yml +32 -32
  22. data/spec/vcr_cassetes/iso_19115_all_parts.yml +17 -17
  23. data/spec/vcr_cassetes/iso_19133_2005.yml +16 -16
  24. data/spec/vcr_cassetes/iso_cd_14093.yml +17 -17
  25. data/spec/vcr_cassetes/iso_combined_applied.yml +33 -33
  26. data/spec/vcr_cassetes/iso_combined_included.yml +32 -32
  27. data/spec/vcr_cassetes/itu_combined_included.yml +302 -186
  28. data/spec/vcr_cassetes/ogc_19_025r1.yml +17 -13159
  29. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +4 -4
  30. data/spec/vcr_cassetes/rfc_8341.yml +8 -8
  31. data/spec/vcr_cassetes/sp_800_38b.yml +6 -6
  32. data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +34 -34
  33. data/spec/vcr_cassetes/w3c_json_ld11.yml +12 -12
  34. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d217d10128648eabc4dbeed414e931b6bb4bfcb9f51f74a11e49fdc0af513c6e
4
- data.tar.gz: 8eb975a6ebbbee9176de5b8f20e928cd6512b04c29c412f9b3dbe8006a6383f8
3
+ metadata.gz: 00617ed8db3b679a9c44d7b8854b17c16d48f10b84a30bbc2e175113d02e9025
4
+ data.tar.gz: 198a87943ebe8f2ffdeabfc0c1ec12a9499ec9642d90ca393a8c26440f3acf3f
5
5
  SHA512:
6
- metadata.gz: '09009418c348753e9ef2222c8887120dc12e467e83c30cc2053d711ff53726cd57885ea07cd8bc21d15bd7174415cd977e2f225db13c1451444e97cffa49ebfd'
7
- data.tar.gz: d6da61ac6052d8bd15fde15cd03916e6521f7ebc11e62ff4a51600316b2d058eb1ccd2a4378fbc6403625599e484d372bf077abbe27a6ebb169b4272add17aa5
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 ot fetch
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 << [ref, doc]
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 documets fetching
195
+ # wait until all the documents fetching
196
196
  refs.size.times do
197
- ref, doc = results.pop
198
- # do thatever you need with result x
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) { |args| yield fetch(*args) }
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
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.9.1".freeze
2
+ VERSION = "1.9.2".freeze
3
3
  end
@@ -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) { |r| queue << r }
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
- expect(File).to receive(:exist?).with(cc_fr).and_return false
209
- expect(File).to receive(:exist?).with(/etag\.txt/).and_return false
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
- expect(File).to receive(:write).and_call_original.at_least :once
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:2014"
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:2014/Amd 1:2018"
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:2014"
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:2014/Amd 1:2018"
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