progressrus 0.1.7 → 0.1.8

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: 727055d15ba54369cae7046c8aa952825bb9e231a4a71c93eb8478ed733dec0e
4
- data.tar.gz: b97d4e19b2c37fe8b7bf431a94dedb50d1ce9dae71b649707331bc560ab3ecba
3
+ metadata.gz: a1e63f1c18708a23b56833afb791eaf7bc27e05243fd4abbd65290e3100d5bf8
4
+ data.tar.gz: 5387f3c957800d8292ea2f5ebb81b7e5fdacb3a4d045c0f9b2fb14686256f97f
5
5
  SHA512:
6
- metadata.gz: 0ed8f27268df03f9ca64537053688c14323fe02e36bdaa82a3909670ca404cf6d53215db3aa1d74e966e831a26edce1687a4f3b989db94d3c3cbca47f69716fe
7
- data.tar.gz: 794568abeca06e53f22fd32d19c0da54a888053278a1bd6e16af5a4103a5903000705ed74b2f8a9d83ea33229a0ee079970c3907fac0a1874789e0c3f8205e28
6
+ metadata.gz: a5039104d899d32e43c908213170555ef5ab1b7031af6099497328195d6985643725c4b09cbd5411edbce03769cd98fcd368e2eca54a79ad78e86a471ba99a01
7
+ data.tar.gz: 5ff5e57e00cd6ff54bc35479047a0d40ae41691fb34324697600f5c4c47b983128bc64e1165102f6e3d187f76aeaffa4e6d6920ca92c5adffd3b573d88711b77
@@ -59,7 +59,11 @@ class Progressrus
59
59
  private
60
60
 
61
61
  def key(scope)
62
- "#{prefix}:#{scope.join(":")}"
62
+ if prefix.respond_to?(:call)
63
+ prefix.call(scope)
64
+ else
65
+ "#{prefix}:#{scope.join(":")}"
66
+ end
63
67
  end
64
68
 
65
69
  def deserialize(value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Progressrus
2
- VERSION = "0.1.7"
4
+ VERSION = '0.1.8'
3
5
  end
@@ -1,6 +1,11 @@
1
1
  require_relative "../test_helper"
2
2
 
3
3
  class RedisStoreTest < Minitest::Test
4
+ class PrefixClass
5
+ def self.call(scope)
6
+ "custom_prefix:#{scope.join(':')}"
7
+ end
8
+ end
4
9
  def setup
5
10
  @scope = ["walrus", "1234"]
6
11
  @progress = Progressrus.new(
@@ -17,11 +22,19 @@ class RedisStoreTest < Minitest::Test
17
22
  name: "oemg-name-two"
18
23
  )
19
24
 
20
- @store = Progressrus::Store::Redis.new(::Redis.new(host: ENV["PROGRESSRUS_REDIS_HOST"] || "localhost"))
25
+ @redis = ::Redis.new(host: ENV["PROGRESSRUS_REDIS_HOST"] || "localhost")
26
+
27
+ @store = Progressrus::Store::Redis.new(@redis)
21
28
  end
22
29
 
23
30
  def teardown
24
- @store.flush(@scope)
31
+ @store.flush(@scope)
32
+ end
33
+
34
+ def test_prefix_can_be_a_proc
35
+ store = Progressrus::Store::Redis.new(@redis, prefix: PrefixClass)
36
+ store.persist(@progress)
37
+ refute_empty(@redis.hgetall('custom_prefix:walrus:1234'))
25
38
  end
26
39
 
27
40
  def test_persist_should_set_key_value_if_outdated
@@ -99,5 +112,4 @@ class RedisStoreTest < Minitest::Test
99
112
  @store.persist(@progress)
100
113
  @store.persist(@progress, force: true)
101
114
  end
102
-
103
115
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: progressrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Eskildsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-23 00:00:00.000000000 Z
11
+ date: 2019-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 3.0.2
174
+ rubygems_version: 3.0.3
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Monitor the progress of remote, long-running jobs.