turnpike 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -10
- data/lib/turnpike/queue.rb +6 -3
- data/lib/turnpike/version.rb +1 -1
- data/lib/turnpike.rb +3 -2
- data/test/turnpike_test.rb +1 -1
- data/turnpike.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 826cb79526ad3b850c35706cf2f83d31d964bea9
|
4
|
+
data.tar.gz: 2660a866510fe81c2fa4803d3934d1c7cc391dfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbfc8eac02fb62742f91149a17efe40acbd3ee12c68403fe279ec68b7298c75734efed720ccdcb279326a3b0c5c3a9340e3b97e7c106a69b5f61b7fb931505e6
|
7
|
+
data.tar.gz: 7a715795ff4ff9e7d9f4aead0e3d4e1bda67d5f86bb34361474fd70fc4dbf21bcb89e9261521eff8b4c11e9d6c750c5fdbeca625e9a9e50d0186edd89aa3d667
|
data/README.md
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
# Turnpike
|
2
2
|
|
3
|
-
|
3
|
+
![turnpike][nj]
|
4
4
|
|
5
|
-
Turnpike wraps
|
6
|
-
|
7
|
-
![turnpike][3]
|
8
|
-
|
9
|
-
# Usage
|
5
|
+
Turnpike wraps [Redis][redis], uses [Message Pack][msgpack], and speaks Ruby.
|
10
6
|
|
11
7
|
```ruby
|
12
8
|
queue = Turnpike['foo']
|
@@ -19,7 +15,6 @@ queue.pop(4) # => [1, 2, 3, 4]
|
|
19
15
|
|
20
16
|
Turnpike requires Redis 2.4 or higher.
|
21
17
|
|
22
|
-
[
|
23
|
-
[
|
24
|
-
[
|
25
|
-
[4]: http://redis.io/topics/data-types
|
18
|
+
[nj]: http://f.cl.ly/items/33242X323P3M1t1G400H/turnpike.jpg
|
19
|
+
[redis]: http://redis.io/
|
20
|
+
[msgpack]: http://msgpack.org/
|
data/lib/turnpike/queue.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'msgpack'
|
2
|
+
require 'redis'
|
3
|
+
|
1
4
|
module Turnpike
|
2
5
|
# A queue.
|
3
6
|
class Queue
|
@@ -32,7 +35,7 @@ module Turnpike
|
|
32
35
|
items = []
|
33
36
|
n.times do
|
34
37
|
break unless item = redis.lpop(name)
|
35
|
-
items <<
|
38
|
+
items << MessagePack.unpack(item)
|
36
39
|
end
|
37
40
|
|
38
41
|
n == 1 ? items.first : items
|
@@ -44,7 +47,7 @@ module Turnpike
|
|
44
47
|
#
|
45
48
|
# Returns the Integer size of the queue after the operation.
|
46
49
|
def push(*items)
|
47
|
-
redis.rpush(name, items.map { |i|
|
50
|
+
redis.rpush(name, items.map { |i| MessagePack.pack(i) })
|
48
51
|
end
|
49
52
|
|
50
53
|
# Syntactic sugar.
|
@@ -61,7 +64,7 @@ module Turnpike
|
|
61
64
|
#
|
62
65
|
# Returns the Integer size of the queue after the operation.
|
63
66
|
def unshift(*items)
|
64
|
-
redis.lpush(name, items.map { |i|
|
67
|
+
redis.lpush(name, items.map { |i| MessagePack.pack(i) })
|
65
68
|
end
|
66
69
|
|
67
70
|
private
|
data/lib/turnpike/version.rb
CHANGED
data/lib/turnpike.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
require 'redis'
|
2
1
|
require 'turnpike/queue'
|
3
2
|
|
4
3
|
# A Redis-backed queue.
|
5
4
|
module Turnpike
|
6
|
-
#
|
5
|
+
# Create a queue.
|
7
6
|
#
|
8
7
|
# name - A queue name that responds to to_s.
|
8
|
+
#
|
9
|
+
# Returns a Turnpike::Queue.
|
9
10
|
def self.[](name)
|
10
11
|
Queue.new(name)
|
11
12
|
end
|
data/test/turnpike_test.rb
CHANGED
data/turnpike.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turnpike
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: msgpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.5.4
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|