ost 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/ost.rb +3 -1
  2. data/test/ost_test.rb +16 -0
  3. metadata +6 -5
data/lib/ost.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "nest"
2
2
 
3
3
  module Ost
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  TIMEOUT = ENV["OST_TIMEOUT"] || 2
6
6
 
7
7
  class Queue
@@ -25,6 +25,8 @@ module Ost
25
25
 
26
26
  item = @key.brpoplpush(@backup, TIMEOUT)
27
27
 
28
+ next unless item
29
+
28
30
  block.call(item)
29
31
 
30
32
  @backup.lpop
data/test/ost_test.rb CHANGED
@@ -53,6 +53,22 @@ scope do
53
53
  assert_equal ["1"], results
54
54
  end
55
55
 
56
+ test "doesn't yield the block on timeout" do |redis|
57
+ results = []
58
+
59
+ Thread.new do
60
+ sleep 2
61
+ redis.lpush(Ost[:events].key, 1)
62
+ end
63
+
64
+ ost do |item|
65
+ results << item
66
+ end
67
+
68
+ assert_equal [], Ost[:events].items
69
+ assert_equal ["1"], results
70
+ end
71
+
56
72
  test "halt processing a queue" do
57
73
  Thread.new do
58
74
  sleep 0.5
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nest
16
- requirement: &2156598040 !ruby/object:Gem::Requirement
16
+ requirement: &70235895313000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156598040
24
+ version_requirements: *70235895313000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cutest
27
- requirement: &2156596100 !ruby/object:Gem::Requirement
27
+ requirement: &70235895312500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '1.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2156596100
35
+ version_requirements: *70235895312500
36
36
  description: Ost lets you manage queues and workers with Redis.
37
37
  email:
38
38
  - michel@soveran.com
@@ -72,3 +72,4 @@ signing_key:
72
72
  specification_version: 3
73
73
  summary: Redis based queues and workers.
74
74
  test_files: []
75
+ has_rdoc: