gitlab-client-cache 0.0.2 → 0.0.3

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: e3d1c3a537e0ae3dedbd5ddcc6fe82e377f299cea066b3a6352352bffdde1cdf
4
- data.tar.gz: 993e7b32375edc9e7d5a9ff1e3c291168c5ea4b7e6b5dcd9ff3b56249356643e
3
+ metadata.gz: d350a75806d888f784565799473875ef199104536103de749aaaef8b53f98c78
4
+ data.tar.gz: 2b71a182d6c912140bbf9838ed9210e080c4dc2ce077957797f7f1609437e500
5
5
  SHA512:
6
- metadata.gz: 40193ec872a903d7429cf0a22f052a99fe1350cc641ffa585562f452fa706ca5e4d98d53a399c0327449a449b7303c03f50f78eca5376c1a1ef6ef04aed045c6
7
- data.tar.gz: 80be8c83333e8cf09e8b31d4d891e30e9c4d720be8d9010823cd7d3b7e41fc412fc53eef31d49a69ab0f28b80286d30d1deab206d0ee1b4f8894a9afa6b39662
6
+ metadata.gz: 26883d8c2693da2bf08e33366eac75772f39bbb2948229c5110ffe4937757088f6f5f6410a1e76db6414b832e93fa8ac3c148e8e69133d5a4ec29cba17533542
7
+ data.tar.gz: 516973e271b58a4bff32383024dbaa7b72310ffc63be65d09c6b1e49bcc35a0c69abea9b6bc0c7227287298ae9ac02856a8a618f120a8847804cba5304fb837b
@@ -14,7 +14,7 @@ class Gitlab::Client::Cache::Caching
14
14
  def cached(http_path, http_params)
15
15
  path = path_to(http_path, http_params)
16
16
 
17
- if path.exist? && path_fresh?(path)
17
+ if path.exist? && path_fresh?(path, http_path, http_params)
18
18
  load(path)
19
19
  else
20
20
  dump(path, yield)
@@ -23,10 +23,20 @@ class Gitlab::Client::Cache::Caching
23
23
 
24
24
  private
25
25
 
26
- def path_fresh?(path)
27
- return true unless @config.expires_in
26
+ def path_fresh?(path, http_path, http_params)
27
+ expires_in = @config.expires_in
28
28
 
29
- path.mtime + @config.expires_in >= Time.now
29
+ if expires_in.is_a?(Array)
30
+ expires_in = \
31
+ expires_in.each do |block|
32
+ result = block.is_a?(Proc) ? block.call(http_path, http_params) : block
33
+ break result unless result == :default
34
+ end
35
+ end
36
+
37
+ return true unless expires_in
38
+
39
+ path.mtime + expires_in >= Time.now
30
40
  end
31
41
 
32
42
  def load(path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitlabClientCache
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-client-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Leitzen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-07 00:00:00.000000000 Z
11
+ date: 2023-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab