Permalink
Browse files

Change `ns` to `key` for consistency with other libraries.

  • Loading branch information...
1 parent c618efb commit 1ea463f91098d5530f68d45552cc40ec8c63ee65 @djanowski djanowski committed Mar 1, 2012
Showing with 11 additions and 5 deletions.
  1. +2 −0 CHANGELOG.md
  2. +5 −5 lib/ost.rb
  3. +4 −0 test/ost_test.rb
View
@@ -5,3 +5,5 @@
You are in charge of rescuing and deciding what to do.
* You can inspect the status of the queue by calling `Ost::Queue#items`.
+
+* If you need access to the underlying Redis key, it's in `Ost::Queue#key`.
View
@@ -5,14 +5,14 @@ module Ost
TIMEOUT = ENV["OST_TIMEOUT"] || 2
class Queue
- attr :ns
+ attr :key
def initialize(name)
- @ns = Nest.new(:ost)[name]
+ @key = Nest.new(:ost)[name]
end
def push(value)
- redis.lpush(ns, value)
+ key.lpush(value)
end
def each(&block)
@@ -21,7 +21,7 @@ def each(&block)
loop do
break if @stopping
- _, item = redis.brpop(ns, TIMEOUT)
+ _, item = key.brpop(TIMEOUT)
next if item.nil? or item.empty?
block.call(item)
@@ -33,7 +33,7 @@ def stop
end
def items
- ns.lrange(0, -1)
+ key.lrange(0, -1)
end
alias << push
View
@@ -87,4 +87,8 @@ def enqueue(id)
assert_equal ["1"], Ost[:events].items
end
+
+ test "allows access to the underlying key" do
+ assert_equal 0, Ost[:events].key.llen
+ end
end

0 comments on commit 1ea463f

Please sign in to comment.