relaton 1.18.0 → 1.18.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7c5f3e470692974347ac474f45af281a5bb14f7733d9cbbfc21797cde40da60
4
- data.tar.gz: 723005aeb2717a6f90ef1bb017e5aae78076d69f038711878dc39624c1f5fdf7
3
+ metadata.gz: af8b5d7f3d6847ea4b48d9bb60dbc19c2cfb954c87e393b1dc029cb91e694c3b
4
+ data.tar.gz: 380db51f0e9dbad1f0b71f14a5ec6dca444a73f68999e7e4814cb1a1f43d3c24
5
5
  SHA512:
6
- metadata.gz: 747a70cc7e9d36ee839be8faa61b68b7fcc9085b01de70237ff132b04a2fd3b665be5256d2387fc308517171db7f23ec4d4015035fef2694a8472ce493e99117
7
- data.tar.gz: cc2db525a28fa3711e409c61f3292206ae7626976519ce86ec3a69a9fa510649aa2a88c9750f2cc24276b7bc60eb35602d4826b630f1d122d26cdd576d4f6a34
6
+ metadata.gz: a30902c431c0b597f6556428769715e67d1edd091316f22f9e8040884139404a69a33bccd3f8b0ce4fa743f99cc509c112eaeacafe40f7cf52c581a9d0ed53d0
7
+ data.tar.gz: 5e7f96ac654ea64dff9604c2e2a09a5460c985dd447e368cbbf2d58ff41dd3d4537d0f7925ad753999c9f5e325f702059f588b54f556474a5a94b8f05315a579
data/lib/relaton/db.rb CHANGED
@@ -447,15 +447,26 @@ module Relaton
447
447
  bib = net_retry(code, year, opts, processor, opts.fetch(:retries, 1))
448
448
 
449
449
  entry = check_entry(bib, stdclass, **args)
450
- return entry if args[:db].nil? || args[:id].nil?
450
+ return entry if args[:db].nil?
451
451
 
452
452
  @semaphore.synchronize { args[:db][args[:id]] ||= entry }
453
+ args[:no_cache] ? bib_entry(bib) : entry
453
454
  end
454
455
 
456
+ #
457
+ # If the reference isn't equal to the document identifier
458
+ # then store the document in the cache and create for the reference a redirection to the document
459
+ #
460
+ # @param [<Type>] bib <description>
461
+ # @param [<Type>] stdclass <description>
462
+ # @param [<Type>] **args <description>
463
+ #
464
+ # @return [<Type>] <description>
465
+ #
455
466
  def check_entry(bib, stdclass, **args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
456
467
  bib_id = bib&.docidentifier&.first&.id
457
468
 
458
- # when docid doesn't match bib's id then return a reference to bib's id
469
+ # when ref isn't equal to bib's id then return a redirection to bib's id
459
470
  if args[:db] && args[:id] && bib_id && args[:id] !~ %r{#{Regexp.quote("(#{bib_id})")}}
460
471
  bid = std_id(bib.docidentifier.first.id, nil, {}, stdclass).first
461
472
  @semaphore.synchronize { args[:db][bid] ||= bib_entry bib }
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.18.0".freeze
2
+ VERSION = "1.18.1".freeze
3
3
  end
@@ -50,6 +50,38 @@ RSpec.describe Relaton::Db do
50
50
  expect(subject.send(:combine_doc, code, nil, {}, :relaton_bipm)).to be_nil
51
51
  end
52
52
  end
53
+
54
+ context "#fetch_entry" do
55
+ let(:db_cache) { double "db_cache" }
56
+
57
+ before do
58
+ expect(subject).to receive(:net_retry).with("ISO 123", nil, {}, kind_of(RelatonIso::Processor), 1).and_return :bib
59
+ end
60
+
61
+ it "using cache" do
62
+ expect(db_cache).to receive(:[]).with("ISO(ISO 123)").and_return nil
63
+ expect(db_cache).to receive(:[]=).with("ISO(ISO 123)", :entry)
64
+ expect(subject).to receive(:check_entry).with(:bib, :relaton_iso, db: db_cache, id: "ISO(ISO 123)").and_return :entry
65
+ entry = subject.send :fetch_entry, "ISO 123", nil, {}, :relaton_iso, db: db_cache, id: "ISO(ISO 123)"
66
+ expect(entry).to be :entry
67
+ end
68
+
69
+ it "DbCache is undefined" do
70
+ expect(subject).to receive(:check_entry).with(:bib, :relaton_iso, **{}).and_return :entry
71
+ entry = subject.send :fetch_entry, "ISO 123", nil, {}, :relaton_iso
72
+ expect(entry).to be :entry
73
+ end
74
+
75
+ it "not using cache" do
76
+ expect(subject).to receive(:bib_entry).with(:bib).and_return :entry
77
+ expect(subject).to receive(:check_entry).with(
78
+ :bib, :relaton_iso, db: db_cache, id: "ISO(ISO 123)", no_cache: true
79
+ ).and_return :entry
80
+ expect(db_cache).to receive(:[]).with("ISO(ISO 123)").and_return :entry
81
+ entry = subject.send :fetch_entry, "ISO 123", nil, {}, :relaton_iso, db: db_cache, id: "ISO(ISO 123)", no_cache: true
82
+ expect(entry).to be :entry
83
+ end
84
+ end
53
85
  end
54
86
 
55
87
  context "class methods" do
@@ -39,21 +39,21 @@ http_interactions:
39
39
  X-Xss-Protection:
40
40
  - 1; mode=block
41
41
  X-Github-Request-Id:
42
- - E384:10E5:26C1F3:300C4F:6594DF80
42
+ - AF8E:3D9C:52425E:6105F0:65C45A0E
43
43
  Accept-Ranges:
44
44
  - bytes
45
45
  Date:
46
- - Wed, 03 Jan 2024 05:06:32 GMT
46
+ - Thu, 08 Feb 2024 04:35:26 GMT
47
47
  Via:
48
48
  - 1.1 varnish
49
49
  X-Served-By:
50
- - cache-pdk-kpdk1780127-PDK
50
+ - cache-pdk-kpdk1780041-PDK
51
51
  X-Cache:
52
- - HIT
52
+ - MISS
53
53
  X-Cache-Hits:
54
- - '1'
54
+ - '0'
55
55
  X-Timer:
56
- - S1704258392.124397,VS0,VE189
56
+ - S1707366926.197574,VS0,VE231
57
57
  Vary:
58
58
  - Authorization,Accept-Encoding,Origin
59
59
  Access-Control-Allow-Origin:
@@ -61,9 +61,9 @@ http_interactions:
61
61
  Cross-Origin-Resource-Policy:
62
62
  - cross-origin
63
63
  X-Fastly-Request-Id:
64
- - 515ab9c3fc71f9d2e8c83836ff2293a364056a68
64
+ - 0d065624f1a175178ec59d149cb969b493434950
65
65
  Expires:
66
- - Wed, 03 Jan 2024 05:11:32 GMT
66
+ - Thu, 08 Feb 2024 04:40:26 GMT
67
67
  Source-Age:
68
68
  - '0'
69
69
  body:
@@ -11299,7 +11299,7 @@ http_interactions:
11299
11299
  HgMUAAAACAA6cm9XZto2RTS1BwAWXlAADQAYAAAAAAABAAAApIEAAAAAaW5k
11300
11300
  ZXgtdjEueWFtbFVUBQADENNUZXV4CwABBOkDAAAEfwAAAFBLBQYAAAAAAQAB
11301
11301
  AFMAAAB7tQcAAAA=
11302
- recorded_at: Wed, 03 Jan 2024 05:06:32 GMT
11302
+ recorded_at: Thu, 08 Feb 2024 04:35:26 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
@@ -11313,6 +11313,8 @@ http_interactions:
11313
11313
  - "*/*"
11314
11314
  User-Agent:
11315
11315
  - Ruby
11316
+ Host:
11317
+ - raw.githubusercontent.com
11316
11318
  response:
11317
11319
  status:
11318
11320
  code: 200
@@ -11339,21 +11341,21 @@ http_interactions:
11339
11341
  X-Xss-Protection:
11340
11342
  - 1; mode=block
11341
11343
  X-Github-Request-Id:
11342
- - EAD6:093D:1A0A6A9:1FA171A:6594DF83
11344
+ - BD5E:49CA:418C58:4D25B2:65C45A11
11343
11345
  Accept-Ranges:
11344
11346
  - bytes
11345
11347
  Date:
11346
- - Wed, 03 Jan 2024 05:06:34 GMT
11348
+ - Thu, 08 Feb 2024 04:35:30 GMT
11347
11349
  Via:
11348
11350
  - 1.1 varnish
11349
11351
  X-Served-By:
11350
- - cache-pdk-kpdk1780147-PDK
11352
+ - cache-pdk-kpdk1780132-PDK
11351
11353
  X-Cache:
11352
- - HIT
11354
+ - MISS
11353
11355
  X-Cache-Hits:
11354
- - '1'
11356
+ - '0'
11355
11357
  X-Timer:
11356
- - S1704258395.643601,VS0,VE123
11358
+ - S1707366930.087565,VS0,VE159
11357
11359
  Vary:
11358
11360
  - Authorization,Accept-Encoding,Origin
11359
11361
  Access-Control-Allow-Origin:
@@ -11361,9 +11363,9 @@ http_interactions:
11361
11363
  Cross-Origin-Resource-Policy:
11362
11364
  - cross-origin
11363
11365
  X-Fastly-Request-Id:
11364
- - 041b74d548b24ba1e9e799133bd9b47c2dbb25ee
11366
+ - bc9142ca8bb17cb878fb0d6088b57b5668e292ac
11365
11367
  Expires:
11366
- - Wed, 03 Jan 2024 05:11:34 GMT
11368
+ - Thu, 08 Feb 2024 04:40:30 GMT
11367
11369
  Source-Age:
11368
11370
  - '0'
11369
11371
  body:
@@ -11404,5 +11406,5 @@ http_interactions:
11404
11406
  bWVldGluZzogU01HLTI4CiAgZnJlZXplX3N0YWdlMl9tZWV0aW5nOiBTTUct
11405
11407
  MjgKICBmcmVlemVfc3RhZ2UzX21lZXRpbmc6IFNNRy0yOAogIGNsb3NlX21l
11406
11408
  ZXRpbmc6IFNQLTI4CiAgcHJvamVjdF9lbmQ6ICcxOTk5LTAyLTEyJwo=
11407
- recorded_at: Wed, 03 Jan 2024 05:06:34 GMT
11409
+ recorded_at: Thu, 08 Feb 2024 04:35:30 GMT
11408
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, 03 Jan 2024 05:08:07 GMT
30
+ - Thu, 08 Feb 2024 04:36:19 GMT
31
31
  X-Amzn-Requestid:
32
- - 80e58fa0-ad1f-4773-9cde-a4478a0ce3fa
32
+ - 12c03e4b-24de-4537-95ca-f4db5de98d7b
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
- - Q8nCYGacIAMEIXw=
38
+ - SzMH7Eb0oAMEgTQ=
39
39
  Access-Control-Allow-Methods:
40
40
  - GET, POST, OPTIONS
41
41
  X-Amzn-Trace-Id:
42
- - Root=1-6594eba8-691cf3bf1aa69aee7753ded0;Sampled=0;lineage=521d48d5:0
42
+ - Root=1-65c45a32-613956cb2302343f56f4374f;Parent=29415cb8fd97d15e;Sampled=0;lineage=521d48d5:0
43
43
  X-Cache:
44
44
  - Miss from cloudfront
45
45
  Via:
46
- - 1.1 af4b82f24e15a32a618ba4f9be9cbf92.cloudfront.net (CloudFront)
46
+ - 1.1 2049bafbdd2d1f88e039f5995c93088a.cloudfront.net (CloudFront)
47
47
  X-Amz-Cf-Pop:
48
48
  - ATL51-C1
49
49
  X-Amz-Cf-Id:
50
- - x-w2RC78CvvzOXbsFysTkVO6p_jVVVBm1UEC07jHP0mcyzRkDRP0-Q==
50
+ - 9fUBqPyNt3zSyV83upqlH_JqjvIYzM8pq6Zw0gngiy4n71szIx-jmA==
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, 03 Jan 2024 05:08:07 GMT
120
+ recorded_at: Thu, 08 Feb 2024 04:36:19 GMT
121
121
  recorded_with: VCR 6.2.0