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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e13bb019c42ee440ea63cde4ebc38035b85aaa88
4
- data.tar.gz: 383a74364de5cf608e411e8fe2bfc97f04a80d31
3
+ metadata.gz: 382568d16a71d46cb7cb6d9ca52d33c2745f0ed1
4
+ data.tar.gz: 07c97201b9a0e3c4b893f1d44c4eef348273b097
5
5
  SHA512:
6
- metadata.gz: 91d42490f87766bfea89810bdad7d62479bfa91c504e97b98128fd4cff40e0eb2478b0f7aeb4d711c4c8c8f779724aa14ebea8b5c95a638e529c0129db455936
7
- data.tar.gz: a12856c07cba67c6cb7c4f62236ab9d43e539d2aa5c141ed59cda45ca37b37674087e460ad1cb69ad72a1f51209ac4f551184b62e4a1afbd113b686f1239e87b
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
@@ -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, String) }
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, String)
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, String, *args)
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.1'
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.}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: when-do
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - TH