when-do 1.0.1 → 1.0.2
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 +4 -4
- data/lib/when-do.rb +2 -2
- data/spec/lib/when-do_spec.rb +3 -3
- data/when-do.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 382568d16a71d46cb7cb6d9ca52d33c2745f0ed1
|
4
|
+
data.tar.gz: 07c97201b9a0e3c4b893f1d44c4eef348273b097
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bd79a76c7f92ea9d7a497284e6045a0c8bd44f89fb1cd3db7bd0a29b8b62a2870d5131a3b2e8244c4aee6b260c101cdfc0d94e4b78ec8bea95824790776ec4f
|
7
|
+
data.tar.gz: 843e35cc2c089ca1d81b678c820da408776efae748d0a8565a855f6b5b493ad76a5f8c48286718b6d31f4d74f5ea90abb73d3cedfa1e34b0162adbc98feb2368
|
data/lib/when-do.rb
CHANGED
@@ -45,7 +45,7 @@ module When
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.enqueue_at(time, klass, *args)
|
48
|
-
job = { 'jid' => SecureRandom.uuid, 'class' => klass, 'args' => args }
|
48
|
+
job = { 'jid' => SecureRandom.uuid, 'class' => klass.to_s, 'args' => args }
|
49
49
|
if redis.zadd(delayed_queue_key, time.to_i, job.to_json)
|
50
50
|
logger.info("Delayed: will enqueue #{job} to run at #{time}.")
|
51
51
|
job['jid']
|
@@ -57,7 +57,7 @@ module When
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.enqueue(klass, *args)
|
60
|
-
job = { 'jid' => SecureRandom.uuid, 'class' => klass, 'args' => args }
|
60
|
+
job = { 'jid' => SecureRandom.uuid, 'class' => klass.to_s, 'args' => args }
|
61
61
|
if redis.lpush(worker_queue_key, job.to_json) > 0
|
62
62
|
job['jid']
|
63
63
|
else
|
data/spec/lib/when-do_spec.rb
CHANGED
@@ -36,19 +36,19 @@ describe When do
|
|
36
36
|
let(:klass) { String }
|
37
37
|
|
38
38
|
it 'adds an item to the delayed list' do
|
39
|
-
expect { When.enqueue_at(now,
|
39
|
+
expect { When.enqueue_at(now, klass) }
|
40
40
|
.to change { redis.zrange(When.delayed_queue_key, 0, -1).count }
|
41
41
|
.from(0).to(1)
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'adds the correct score' do
|
45
|
-
When.enqueue_at(now,
|
45
|
+
When.enqueue_at(now, klass)
|
46
46
|
score = redis.zrange(When.delayed_queue_key, 0, -1, with_scores: true).first.last
|
47
47
|
expect(score).to eq now.to_i.to_f
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'adds the correct args' do
|
51
|
-
When.enqueue_at(now,
|
51
|
+
When.enqueue_at(now, klass, *args)
|
52
52
|
new_args = JSON.parse(redis.zrange(When.delayed_queue_key, 0, -1).first)['args']
|
53
53
|
expect(new_args).to eq args
|
54
54
|
end
|
data/when-do.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "when-do"
|
7
|
-
spec.version = '1.0.
|
7
|
+
spec.version = '1.0.2'
|
8
8
|
spec.authors = ["TH"]
|
9
9
|
spec.email = ["tylerhartland7@gmail.com"]
|
10
10
|
spec.description = %q{Queues jobs when you want.}
|