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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bdc1b9661a68b1c18fca240429d6181bdc7ff33
4
- data.tar.gz: df17c9caad3616a26d0b5958640271a312f0f859
3
+ metadata.gz: 826cb79526ad3b850c35706cf2f83d31d964bea9
4
+ data.tar.gz: 2660a866510fe81c2fa4803d3934d1c7cc391dfa
5
5
  SHA512:
6
- metadata.gz: 01885b3d7c7d721a652eeada839005a9f4a65e4fd79a4061205ec5786648f15ae4d57a23dcd5da8110af825e5530bc8927311e2205c18cb791af6bb3bb729d69
7
- data.tar.gz: 9c05aa377660cc4a2e5da456b149f34f9ffde0666cf7e52cbf13aae0dd096633c2b21a28ea2cf5267481ee2624008ae33e0fc8243537d3e00841873c125c815d
6
+ metadata.gz: bbfc8eac02fb62742f91149a17efe40acbd3ee12c68403fe279ec68b7298c75734efed720ccdcb279326a3b0c5c3a9340e3b97e7c106a69b5f61b7fb931505e6
7
+ data.tar.gz: 7a715795ff4ff9e7d9f4aead0e3d4e1bda67d5f86bb34361474fd70fc4dbf21bcb89e9261521eff8b4c11e9d6c750c5fdbeca625e9a9e50d0186edd89aa3d667
data/README.md CHANGED
@@ -1,12 +1,8 @@
1
1
  # Turnpike
2
2
 
3
- [![travis][1]][2]
3
+ ![turnpike][nj]
4
4
 
5
- Turnpike wraps a [Redis List][4] and speaks Ruby colloquial.
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
- [1]: https://secure.travis-ci.org/hakanensari/turnpike.png
23
- [2]: http://travis-ci.org/hakanensari/turnpike
24
- [3]: http://f.cl.ly/items/33242X323P3M1t1G400H/turnpike.jpg
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/
@@ -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 << Marshal.load(item)
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| Marshal.dump(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| Marshal.dump(i) })
67
+ redis.lpush(name, items.map { |i| MessagePack.pack(i) })
65
68
  end
66
69
 
67
70
  private
@@ -1,3 +1,3 @@
1
1
  module Turnpike
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
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
- # Returns a Queue.
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
@@ -9,7 +9,7 @@ class TestTurnpike < MiniTest::Unit::TestCase
9
9
 
10
10
  def peek(queue)
11
11
  redis = queue.send(:redis)
12
- redis.lrange(queue.name, 0, -1).map { |i| Marshal.load(i) }
12
+ redis.lrange(queue.name, 0, -1).map { |i| MessagePack.unpack(i) }
13
13
  end
14
14
 
15
15
  def test_bracket
data/turnpike.gemspec CHANGED
@@ -17,5 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ['lib']
18
18
 
19
19
  s.add_runtime_dependency 'redis', '~> 3.0'
20
+ s.add_runtime_dependency 'msgpack', '~> 0.5.4'
20
21
  s.add_development_dependency 'rake'
21
22
  end
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.5.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-04-26 00:00:00.000000000 Z
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