simple_queues 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module SimpleQueues
6
6
  #
7
7
  # Messages are enqueued to the right, dequeued from the left - thus the most recent messages are at the end of the list.
8
8
  class Redis
9
- attr_reader :encoder
9
+ attr_accessor :encoder
10
10
 
11
11
  # @param redis A Redis instance, or something that looks like Redis.
12
12
  # @param options [Hash] A set of options.
@@ -93,12 +93,13 @@ module SimpleQueues
93
93
  _, result = @redis.blpop(q_name(queue_name), timeout.to_i)
94
94
  decode(result)
95
95
  else
96
- raise "NOT DONE"
96
+ raise ArgumentError, "Expected 1 (timeout) or 2 (queue name, timeout) arguments, not #{args.length}"
97
97
  end
98
98
 
99
99
  end
100
100
 
101
- private
101
+ protected
102
+
102
103
  def q_name(queue_name)
103
104
  queue_name &&= queue_name.to_s
104
105
  raise ArgumentError, "Queue name argument was nil - must not be" if queue_name.nil? || queue_name.empty?
@@ -1,3 +1,3 @@
1
1
  module SimpleQueues
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -27,14 +27,14 @@ describe SimpleQueues::Redis, "multiple dequeue" do
27
27
  end
28
28
 
29
29
  context "#dequeue_with_timeout" do
30
- it "should return the queue name when a message was dequeued" do
30
+ it "should return the queue name where the message was dequeued" do
31
31
  queue.on_dequeue(:a) {|message| message}
32
32
  queue.on_dequeue(:b) {|message| raise "not here"}
33
33
  queue.enqueue(:a, :sent_to => "a")
34
34
  queue.dequeue_with_timeout(1).should == "a"
35
35
  end
36
36
 
37
- it "should return nil when no queues returned anything" do
37
+ it "should return nil when no messages were pending" do
38
38
  queue.on_dequeue(:a) {|message| raise "not here"}
39
39
  queue.dequeue_with_timeout(1).should be_nil
40
40
  end
@@ -47,9 +47,8 @@ describe SimpleQueues::Redis, "multiple dequeue" do
47
47
  queue.enqueue(:a, "sent_to" => "a", "serial" => 1)
48
48
  queue.enqueue(:b, "sent_to" => "b", "serial" => 1)
49
49
  queue.enqueue(:a, "sent_to" => "a", "serial" => 2)
50
- while queue.dequeue_with_timeout(1)
51
- # NOP
52
- end
50
+
51
+ 3.times { queue.dequeue_with_timeout(1) }
53
52
 
54
53
  a.should == [{"sent_to" => "a", "serial" => 1}, {"sent_to" => "a", "serial" => 2}]
55
54
  b.should == [{"sent_to" => "b", "serial" => 1}]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: simple_queues
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.0
5
+ version: 1.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Fran\xC3\xA7ois Beausoleil"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-25 00:00:00 -04:00
13
+ date: 2011-03-29 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency