progressrus 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/progressrus.rb +9 -1
- data/lib/progressrus/store/redis.rb +1 -1
- data/lib/progressrus/version.rb +1 -1
- data/test/integration_test.rb +8 -0
- data/test/store/redis_test.rb +11 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b088dbba839ff6037add109dc9e9a9ea52074a4
|
4
|
+
data.tar.gz: 67204fed60013d7b12819474868562766fe17d41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7599e3adfaa638985adccd88c2acf4fbccca9f90e5bc5d2ac7262cd9a9fd4982d94916f031df244a236e31e75685f97b29a7ae7501fe7c978e032f932fb82106
|
7
|
+
data.tar.gz: af39e6cc6e04afa0c2bcd491dc23876586f278e439b8fd6ca44ae3b010c8136996ee0cd712b98dd4c93cfd1671db89466fa78973c5e8e878b07ae1d733b00b82
|
data/lib/progressrus.rb
CHANGED
@@ -40,7 +40,7 @@ class Progressrus
|
|
40
40
|
def initialize(scope: "progressrus", total: nil, name: nil,
|
41
41
|
id: SecureRandom.uuid, params: {}, stores: Progressrus.stores,
|
42
42
|
completed_at: nil, started_at: nil, count: 0, failed_at: nil,
|
43
|
-
error_count: 0, persist: false, expires_at: nil)
|
43
|
+
error_count: 0, persist: false, expires_at: nil, persisted: false)
|
44
44
|
|
45
45
|
raise ArgumentError, "Total cannot be negative." if total && total < 0
|
46
46
|
|
@@ -57,6 +57,7 @@ class Progressrus
|
|
57
57
|
@completed_at = parse_time(completed_at)
|
58
58
|
@failed_at = parse_time(failed_at)
|
59
59
|
@expires_at = parse_time(expires_at)
|
60
|
+
@persisted = persisted
|
60
61
|
|
61
62
|
persist(force: true) if persist
|
62
63
|
end
|
@@ -122,6 +123,8 @@ class Progressrus
|
|
122
123
|
def total=(new_total)
|
123
124
|
raise ArgumentError, "Total cannot be negative." if new_total < 0
|
124
125
|
@total = new_total
|
126
|
+
persist(force: true) if persisted?
|
127
|
+
@total
|
125
128
|
end
|
126
129
|
|
127
130
|
def total
|
@@ -153,6 +156,10 @@ class Progressrus
|
|
153
156
|
expires_at && expires_at < now
|
154
157
|
end
|
155
158
|
|
159
|
+
def persisted?
|
160
|
+
@persisted
|
161
|
+
end
|
162
|
+
|
156
163
|
private
|
157
164
|
|
158
165
|
def persist(force: false)
|
@@ -162,6 +169,7 @@ class Progressrus
|
|
162
169
|
rescue Progressrus::Store::BackendError => e
|
163
170
|
end
|
164
171
|
end
|
172
|
+
@persisted = true
|
165
173
|
end
|
166
174
|
|
167
175
|
def parse_time(time)
|
data/lib/progressrus/version.rb
CHANGED
data/test/integration_test.rb
CHANGED
@@ -21,6 +21,14 @@ class IntegrationTest < Minitest::Test
|
|
21
21
|
assert_equal 1, tick.count
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_setting_total_after_persist_persists_total
|
25
|
+
progress = Progressrus.new(scope: ["walrus"], total: 0, persist: true, id: '123')
|
26
|
+
assert_equal 0, progress.total
|
27
|
+
progress.total = 20
|
28
|
+
progress = Progressrus.find(["walrus"], '123')
|
29
|
+
assert_equal 20, progress.total
|
30
|
+
end
|
31
|
+
|
24
32
|
def test_create_multiple_ticks_and_see_them_in_redis
|
25
33
|
@progress.tick
|
26
34
|
|
data/test/store/redis_test.rb
CHANGED
@@ -38,12 +38,14 @@ class RedisStoreTest < Minitest::Test
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_scope_should_return_progressruses_indexed_by_id
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
@store.persist(@progress)
|
42
|
+
@store.persist(@another_progress)
|
43
|
+
actual = @store.scope(@scope)
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
assert_equal @progress.id, actual['oemg'].id
|
46
|
+
assert actual['oemg'].persisted?
|
47
|
+
assert_equal @another_progress.id, actual['oemg-two'].id
|
48
|
+
assert actual['oemg-two'].persisted?
|
47
49
|
end
|
48
50
|
|
49
51
|
def test_scope_should_return_an_empty_hash_if_nothing_is_found
|
@@ -51,9 +53,10 @@ class RedisStoreTest < Minitest::Test
|
|
51
53
|
end
|
52
54
|
|
53
55
|
def test_find_should_return_a_single_progressrus_for_scope_and_id
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
@store.persist(@progress)
|
57
|
+
stored_progress = @store.find(@scope, 'oemg')
|
58
|
+
assert_equal @progress.id, stored_progress.id
|
59
|
+
assert stored_progress.persisted?
|
57
60
|
end
|
58
61
|
|
59
62
|
def test_find_should_return_nil_if_nothing_is_found
|
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.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Eskildsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.
|
189
|
+
rubygems_version: 2.6.10
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Monitor the progress of remote, long-running jobs.
|