relaton 1.15.4 → 1.15.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8fa98a0ea566742e2821f059c138d8406580d9a3d6503038b136dacf3099b9a
4
- data.tar.gz: 6a18b2bdcf7940ef4e31c8852c5cc4fd8aaa85c44ab301978b2f0fb4e63548cd
3
+ metadata.gz: 660a04548bc776f45c6675c93929f092b9b09bf787f9c5327a0e77c4657396d6
4
+ data.tar.gz: 524d02188fb9b718b051a9278f367b5ba96b1cc9b7e3f22e0ef289dc2e637104
5
5
  SHA512:
6
- metadata.gz: 92339583a34c6ba9e0f9a8adffc3cc61f17bd8eb6e5f117a3d297eb1215c1f93e5e641f99e0b0780ff8dc0a682ae29d7044d49faf1de86ac140d56f706b383cc
7
- data.tar.gz: a3cbcc6781710a5cca884bbf8bac41406d934d15d58f6eccdcf44e10e9b2a0330265419ff3ce167e4b16e35a539c29c6af3b5ed5014e8e5dc590dc130ac59239
6
+ metadata.gz: a888ab93816385d62c1a16e75dfdeeced6138793f89bd37b4b9570642c9ba6ab9fe2046185f514f0083e3a3293af4644b4e3232ef32c3786a58cc1c8afdb872a
7
+ data.tar.gz: 715fdef1a7536b2cb8e42f89bb0aaa32ff11684e38787acc58afbebd94ff93c8c017166af1b518b92e53af2fbb9375ae7907d672081aa25694d9c77d0e111744
data/lib/relaton/db.rb CHANGED
@@ -33,11 +33,11 @@ module Relaton
33
33
  end
34
34
 
35
35
  ##
36
- # The class of reference requested is determined by the prefix of the code:
36
+ # The class of reference requested is determined by the prefix of the reference:
37
37
  # GB Standard for gbbib, IETF for ietfbib, ISO for isobib, IEC or IEV for
38
38
  # iecbib,
39
39
  #
40
- # @param code [String] the ISO standard Code to look up (e.g. "ISO 9000")
40
+ # @param text [String] the standard reference to look up (e.g. "ISO 9000")
41
41
  # @param year [String] the year the standard was published (optional)
42
42
  #
43
43
  # @param opts [Hash] options
@@ -55,14 +55,15 @@ module Relaton
55
55
  # RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
56
56
  # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
57
57
  ##
58
- def fetch(code, year = nil, opts = {})
59
- stdclass = @registry.class_by_ref(code) || return
58
+ def fetch(text, year = nil, opts = {})
59
+ reference = text.strip
60
+ stdclass = @registry.class_by_ref(reference) || return
60
61
  processor = @registry.processors[stdclass]
61
62
  ref = if processor.respond_to?(:urn_to_code)
62
- processor.urn_to_code(code)&.first
63
- else code
63
+ processor.urn_to_code(reference)&.first
64
+ else reference
64
65
  end
65
- ref ||= code
66
+ ref ||= reference
66
67
  result = combine_doc ref, year, opts, stdclass
67
68
  result || check_bibliocache(ref, year, opts, stdclass)
68
69
  end
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.15.4".freeze
2
+ VERSION = "1.15.5".freeze
3
3
  end
@@ -1,9 +1,8 @@
1
1
  RSpec.describe Relaton::Db do
2
2
  before(:each) { FileUtils.rm_rf %w[testcache testcache2] }
3
+ subject { Relaton::Db.new nil, nil }
3
4
 
4
5
  context "instance methods" do
5
- subject { Relaton::Db.new nil, nil }
6
-
7
6
  context "#search_edition_year" do
8
7
  it "create bibitem from YAML content" do
9
8
  h = { "docid" => [{ "id" => "ISO 123", type: "ISO", "primary" => true }] }
@@ -164,21 +163,33 @@ RSpec.describe Relaton::Db do
164
163
  expect(db.docid_type("CN(GB/T 1.1)")).to eq ["Chinese Standard", "GB/T 1.1"]
165
164
  end
166
165
 
167
- it "doesn't use cache" do
168
- db = Relaton::Db.new nil, nil
169
- docid = RelatonBib::DocumentIdentifier.new id: "ISO 19115-1", type: "ISO"
170
- item = RelatonIsoBib::IsoBibliographicItem.new docid: [docid]
171
- expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 19115-1", nil, {}).and_return item
172
- bib = db.fetch("ISO 19115-1", nil, {})
173
- expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
174
- end
175
-
176
- it "fetch when no local db" do
177
- db = Relaton::Db.new "testcache", nil
178
- VCR.use_cassette "iso_19115_1" do
179
- bib = db.fetch("ISO 19115-1", nil, {})
166
+ context "#fetch" do
167
+ it "doesn't use cache" do
168
+ docid = RelatonBib::DocumentIdentifier.new id: "ISO 19115-1", type: "ISO"
169
+ item = RelatonIsoBib::IsoBibliographicItem.new docid: [docid]
170
+ expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 19115-1", nil, {}).and_return item
171
+ bib = subject.fetch("ISO 19115-1", nil, {})
180
172
  expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
181
173
  end
174
+
175
+ it "when no local db" do
176
+ db = Relaton::Db.new "testcache", nil
177
+ VCR.use_cassette "iso_19115_1" do
178
+ bib = db.fetch("ISO 19115-1", nil, {})
179
+ expect(bib).to be_instance_of RelatonIsoBib::IsoBibliographicItem
180
+ end
181
+ end
182
+
183
+ it "document with net retries" do
184
+ expect(subject.instance_variable_get(:@registry).processors[:relaton_ietf]).to receive(:get)
185
+ .and_raise(RelatonBib::RequestError).exactly(3).times
186
+ expect { subject.fetch "RFC 8341", nil, retries: 3 }.to raise_error RelatonBib::RequestError
187
+ end
188
+
189
+ it "strip reference" do
190
+ expect(subject).to receive(:combine_doc).with("ISO 19115-1", nil, {}, :relaton_iso).and_return :doc
191
+ expect(subject.fetch(" ISO 19115-1 ", nil, {})).to be :doc
192
+ end
182
193
  end
183
194
 
184
195
  it "fetch std" do
@@ -189,15 +200,7 @@ RSpec.describe Relaton::Db do
189
200
  end
190
201
  end
191
202
 
192
- it "fetch document with net retries" do
193
- db = Relaton::Db.new nil, nil
194
- expect(db.instance_variable_get(:@registry).processors[:relaton_ietf]).to receive(:get)
195
- .and_raise(RelatonBib::RequestError).exactly(3).times
196
- expect { db.fetch "RFC 8341", nil, retries: 3 }.to raise_error RelatonBib::RequestError
197
- end
198
-
199
203
  context "async fetch" do
200
- let(:db) { Relaton::Db.new nil, nil }
201
204
  let(:queue) { Queue.new }
202
205
 
203
206
  it "success" do
@@ -206,8 +209,8 @@ RSpec.describe Relaton::Db do
206
209
  "ITU-T G.780/Y.1351", "ITU-T G.711", "ITU-T G.1011"]
207
210
  results = []
208
211
  refs.each do |ref|
209
- expect(db).to receive(:fetch).with(ref, nil, {}).and_return :result
210
- db.fetch_async(ref) { |r| queue << [r, ref] }
212
+ expect(subject).to receive(:fetch).with(ref, nil, {}).and_return :result
213
+ subject.fetch_async(ref) { |r| queue << [r, ref] }
211
214
  end
212
215
  Timeout.timeout(60) { refs.size.times { results << queue.pop } }
213
216
  results.each do |result|
@@ -220,8 +223,8 @@ RSpec.describe Relaton::Db do
220
223
  "CGPM -- Réunion 9 (1948)", "CGPM -- Meeting 9 (1948)"]
221
224
  results = []
222
225
  refs.each do |ref|
223
- expect(db).to receive(:fetch).with(ref, nil, {}).and_return :result
224
- db.fetch_async(ref) { |r| queue << [r, ref] }
226
+ expect(subject).to receive(:fetch).with(ref, nil, {}).and_return :result
227
+ subject.fetch_async(ref) { |r| queue << [r, ref] }
225
228
  end
226
229
  Timeout.timeout(60) { refs.size.times { results << queue.pop } }
227
230
  results.each do |result|
@@ -232,23 +235,23 @@ RSpec.describe Relaton::Db do
232
235
  it "prefix not found" do
233
236
  result = ""
234
237
  VCR.use_cassette "rfc_unsuccess" do
235
- db.fetch_async("ABC 123456") { |r| queue << r }
238
+ subject.fetch_async("ABC 123456") { |r| queue << r }
236
239
  Timeout.timeout(5) { result = queue.pop }
237
240
  end
238
241
  expect(result).to be_nil
239
242
  end
240
243
 
241
244
  it "handle HTTP request error" do
242
- expect(db).to receive(:fetch).and_raise RelatonBib::RequestError
243
- db.fetch_async("ISO REF") { |r| queue << r }
245
+ expect(subject).to receive(:fetch).and_raise RelatonBib::RequestError
246
+ subject.fetch_async("ISO REF") { |r| queue << r }
244
247
  result = Timeout.timeout(5) { queue.pop }
245
248
  expect(result).to be_instance_of RelatonBib::RequestError
246
249
  end
247
250
 
248
251
  it "handle other errors" do
249
- expect(db).to receive(:fetch).and_raise Errno::EACCES
252
+ expect(subject).to receive(:fetch).and_raise Errno::EACCES
250
253
  expect do
251
- db.fetch_async("ISO REF") { |r| queue << r }
254
+ subject.fetch_async("ISO REF") { |r| queue << r }
252
255
  result = Timeout.timeout(5) { queue.pop }
253
256
  expect(result).to be_nil
254
257
  end.to output("[relaton] ERROR: ISO REF -- Permission denied\n").to_stderr
@@ -258,8 +261,8 @@ RSpec.describe Relaton::Db do
258
261
  expect(ENV).to receive(:[]).with("RELATON_FETCH_PARALLEL").and_return(1)
259
262
  allow(ENV).to receive(:[]).and_call_original
260
263
  expect(Relaton::WorkersPool).to receive(:new).with(1).and_call_original
261
- expect(db).to receive(:fetch).with("ITU-T G.993.5", nil, {})
262
- db.fetch_async("ITU-T G.993.5") { |r| queue << r }
264
+ expect(subject).to receive(:fetch).with("ITU-T G.993.5", nil, {})
265
+ subject.fetch_async("ITU-T G.993.5") { |r| queue << r }
263
266
  Timeout.timeout(50) { queue.pop }
264
267
  end
265
268
  end
@@ -29,7 +29,7 @@ http_interactions:
29
29
  Content-Type:
30
30
  - application/zip
31
31
  Etag:
32
- - W/"31b8f0fe0cac93e4664952a8fa9f226d5cfc3e7868f73e89adaec83faf68edea"
32
+ - W/"15c57459dcf3d700d40495db041ca9831bea6bb240d07bb5a9508489f4231a7f"
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
- - D594:0F1C:2A65ED:30C110:64B73CAE
42
+ - C69A:69C7:AED261:C6DC63:64C53486
43
43
  Accept-Ranges:
44
44
  - bytes
45
45
  Date:
46
- - Wed, 19 Jul 2023 01:30:23 GMT
46
+ - Sat, 29 Jul 2023 15:47:19 GMT
47
47
  Via:
48
48
  - 1.1 varnish
49
49
  X-Served-By:
50
- - cache-atl18463-ATL
50
+ - cache-iad-kcgs7200022-IAD
51
51
  X-Cache:
52
52
  - MISS
53
53
  X-Cache-Hits:
54
54
  - '0'
55
55
  X-Timer:
56
- - S1689730223.962476,VS0,VE160
56
+ - S1690645640.757024,VS0,VE152
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
- - 2076c270463a55fded43aba88a3a78ba61a2bcd9
64
+ - 76f4c465d73b6bb64ca9e85a06690e6d0e6b4c6a
65
65
  Expires:
66
- - Wed, 19 Jul 2023 01:35:23 GMT
66
+ - Sat, 29 Jul 2023 15:52:19 GMT
67
67
  Source-Age:
68
68
  - '0'
69
69
  body:
70
70
  encoding: UTF-8
71
71
  base64_string: |
72
- UEsDBBQAAAAIAG9y8VZm2jZFNLUHABZeUAANABwAaW5kZXgtdjEueWFtbFVU
73
- CQAD8k21ZHJOtWR1eAsAAQTpAwAABHsAAACM/cGuLTuOJArO31fkD0TeLblc
72
+ UEsDBBQAAAAIAO5x/FZm2jZFNLUHABZeUAANABwAaW5kZXgtdjEueWFtbFVU
73
+ CQADgM3DZPDNw2R1eAsAAQTpAwAABHsAAACM/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
- HgMUAAAACABvcvFWZto2RTS1BwAWXlAADQAYAAAAAAABAAAApIEAAAAAaW5k
11300
- ZXgtdjEueWFtbFVUBQAD8k21ZHV4CwABBOkDAAAEewAAAFBLBQYAAAAAAQAB
11299
+ HgMUAAAACADucfxWZto2RTS1BwAWXlAADQAYAAAAAAABAAAApIEAAAAAaW5k
11300
+ ZXgtdjEueWFtbFVUBQADgM3DZHV4CwABBOkDAAAEewAAAFBLBQYAAAAAAQAB
11301
11301
  AFMAAAB7tQcAAAA=
11302
- recorded_at: Wed, 19 Jul 2023 01:30:23 GMT
11302
+ recorded_at: Sat, 29 Jul 2023 15:47:20 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
- - 617A:0272:2B42D5:319CAB:64B73CB2
11344
+ - 3588:4477:9C13AD:B41D5C:64C5348B
11345
11345
  Accept-Ranges:
11346
11346
  - bytes
11347
11347
  Date:
11348
- - Wed, 19 Jul 2023 01:30:26 GMT
11348
+ - Sat, 29 Jul 2023 15:47:23 GMT
11349
11349
  Via:
11350
11350
  - 1.1 varnish
11351
11351
  X-Served-By:
11352
- - cache-atl18458-ATL
11352
+ - cache-iad-kcgs7200034-IAD
11353
11353
  X-Cache:
11354
11354
  - MISS
11355
11355
  X-Cache-Hits:
11356
11356
  - '0'
11357
11357
  X-Timer:
11358
- - S1689730226.423000,VS0,VE149
11358
+ - S1690645643.136097,VS0,VE135
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
- - ae1b6ac3a5afa888156b194b082a136833a34376
11366
+ - 6afc467a2227ed85c58ed42c0bb25df92ab8027e
11367
11367
  Expires:
11368
- - Wed, 19 Jul 2023 01:35:26 GMT
11368
+ - Sat, 29 Jul 2023 15:52:23 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: Wed, 19 Jul 2023 01:30:26 GMT
11409
+ recorded_at: Sat, 29 Jul 2023 15:47:23 GMT
11410
11410
  recorded_with: VCR 6.2.0
@@ -27,27 +27,27 @@ http_interactions:
27
27
  Connection:
28
28
  - keep-alive
29
29
  Date:
30
- - Wed, 19 Jul 2023 01:31:14 GMT
30
+ - Sat, 29 Jul 2023 15:48:02 GMT
31
31
  X-Amzn-Requestid:
32
- - a25e4af7-908c-41da-973b-65767742bb34
32
+ - 330853d3-ec28-4588-9aa2-372ef02c4a70
33
33
  Access-Control-Allow-Origin:
34
34
  - "*"
35
35
  Access-Control-Allow-Headers:
36
36
  - Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
37
37
  X-Amz-Apigw-Id:
38
- - ISZw7EeIIAMFuow=
38
+ - I1UptG0AoAMFoPQ=
39
39
  Access-Control-Allow-Methods:
40
40
  - GET, POST, OPTIONS
41
41
  X-Amzn-Trace-Id:
42
- - Root=1-64b73cd2-0b2032c770b88fc13693e381;Sampled=0;lineage=521d48d5:0
42
+ - Root=1-64c534a4-555c478b697cc6d6081afe9f;Sampled=0;lineage=521d48d5:0
43
43
  X-Cache:
44
44
  - Miss from cloudfront
45
45
  Via:
46
- - 1.1 27e347e11d87bd5249a0ba1815737e5c.cloudfront.net (CloudFront)
46
+ - 1.1 52e2243a8168629f98bb0607016f7224.cloudfront.net (CloudFront)
47
47
  X-Amz-Cf-Pop:
48
48
  - ATL51-C1
49
49
  X-Amz-Cf-Id:
50
- - 5uUJywQRTRpfRxa9zMvn3OEBH0vx992vWYh-ypepBBGyy6behrFPfw==
50
+ - Ke1TVShWUJU_5veEOUEhW9I6EKvlGGvtDmraRpsn77Nkum6GeeOypQ==
51
51
  body:
52
52
  encoding: UTF-8
53
53
  base64_string: |
@@ -117,5 +117,5 @@ http_interactions:
117
117
  dHJ1Y3R1cmVkaWRlbnRpZmllciB0eXBlPSJJU08iPgogICAgICA8cHJvamVj
118
118
  dC1udW1iZXI+SVNPIDE5MTE1PC9wcm9qZWN0LW51bWJlcj4KICAgIDwvc3Ry
119
119
  dWN0dXJlZGlkZW50aWZpZXI+CiAgPC9leHQ+CjwvYmliZGF0YT4=
120
- recorded_at: Wed, 19 Jul 2023 01:31:14 GMT
120
+ recorded_at: Sat, 29 Jul 2023 15:48:02 GMT
121
121
  recorded_with: VCR 6.2.0