requeue 0.7.3 → 0.8.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: a50634423a9b4983dabf590dec78f667453341d6
4
- data.tar.gz: a0cc2ce7e7b85502f94aac32e8d961f27f908fe5
3
+ metadata.gz: 803325213f9e3e8321146cc00588381e9158396d
4
+ data.tar.gz: f39280e72b3cd3bb7a396cb4b7a1c9c893990017
5
5
  SHA512:
6
- metadata.gz: f7fbb67b2d91a065672e78c609b3071dae7a501233e447b4de713de8a9ef2c4481dfeedea9d3179ea362e8474fc992f66535de1b3160cd390ff341977d933d61
7
- data.tar.gz: d5b8e45fc3d90c7a904a09ccdaa0b57775301dfb7ce589c07521b132f17cbe0fb0689a97decbf4feea416133207bf5a61cfa769bd2e07fa0535d7683e7827019
6
+ metadata.gz: b48342b8ec4015a90f968bd49d581c2fb422a8106c4b3a6599680ca46e1a15d76e2b5e2972429062c9343203a0fe08294eb5538bb94a64f465a29861d17b72c8
7
+ data.tar.gz: 5095055ac1b0c8aa0e07cd9857788970f1f0db20863424b734e34569feb38413c00a43f47f91bea5c9c3421641dd59cc4ba491d2529ef3ede8819b48b88df358
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Requeue
2
2
  [![Code Climate](https://codeclimate.com/github/lumoslabs/requeue.png)](https://codeclimate.com/github/lumoslabs/requeue)
3
+
4
+ [![Circle CI](https://circleci.com/gh/lumoslabs/requeue.png?circle-token=09b59b996588e9bd5cc4ce3dc01507c071f05025)](https://circleci.com/gh/lumoslabs/requeue)
5
+
3
6
  Requeue is a rediciulosly simple queue backed by redis.
4
7
 
5
8
  ## Installation
@@ -46,28 +49,36 @@ q.clear!
46
49
  q.steal!
47
50
 
48
51
  #To get the position of a value
49
- q.position('thing') => 0
52
+ q.position('thing')
53
+ => 0
50
54
 
51
55
  #To see if an item is queued
52
- q.queued?('thing') => true
56
+ q.queued?('thing')
57
+ => true
53
58
 
54
59
  #To see the the current first item of the queue
55
- q.owner => 'thing'
60
+ q.owner
61
+ => 'thing'
56
62
 
57
63
  #To get the queue as a hash
58
64
  q.as_hash
65
+ => {:queue => ['1','2','3'] :owned => true :length => 3}
59
66
 
60
67
  #To get the queue as a json blob
61
68
  q.as_json
69
+ => '{"queue": [1,2,3], "owned" : true, "length": 3 }'
62
70
 
63
71
  #To get the internal name of the queue
64
72
  q.name
73
+ => 'awesome:queue'
65
74
 
66
75
  #To get the length of the queue
67
76
  q.length
77
+ => 3
68
78
 
69
79
  #To get all of the items in the queue
70
80
  q.list
81
+ => [1,2,3]
71
82
  ```
72
83
 
73
84
  ## Contributing
@@ -20,11 +20,11 @@ module Requeue
20
20
  @redis.llen(name)
21
21
  end
22
22
 
23
- def clear!
23
+ def clear
24
24
  @redis.del(name)
25
25
  end
26
26
 
27
- def enqueue!(value)
27
+ def enqueue(value)
28
28
  if (@unique == false || !queued?(value))
29
29
  @redis.rpush(name, value)
30
30
  else
@@ -32,7 +32,7 @@ module Requeue
32
32
  end
33
33
  end
34
34
 
35
- def dequeue!
35
+ def dequeue
36
36
  @redis.lpop(name)
37
37
  end
38
38
 
@@ -44,7 +44,7 @@ module Requeue
44
44
  list.index(value)
45
45
  end
46
46
 
47
- def remove!(value)
47
+ def remove(value)
48
48
  @redis.lrem(name, 0, value)
49
49
  end
50
50
 
@@ -60,7 +60,7 @@ module Requeue
60
60
  length > 0
61
61
  end
62
62
 
63
- def steal!(value)
63
+ def steal(value)
64
64
  @redis.lpush(name, value)
65
65
  end
66
66
 
@@ -1,3 +1,3 @@
1
1
  module Requeue
2
- VERSION = "0.7.3"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -6,48 +6,48 @@ describe Requeue::Queue do
6
6
  end
7
7
 
8
8
  after(:each) do
9
- @queue.clear!
9
+ @queue.clear
10
10
  end
11
11
 
12
12
  describe '.name' do
13
13
  it { expect(@queue.name).to eq("test:queue") }
14
14
  end
15
15
 
16
- describe '.clear!' do
17
- before { @queue.enqueue!('eric') }
16
+ describe '.clear' do
17
+ before { @queue.enqueue('eric') }
18
18
 
19
19
  it 'should empty the queue' do
20
- expect{ @queue.clear! }.to change { @queue.length }.from(1).to(0)
20
+ expect{ @queue.clear }.to change { @queue.length }.from(1).to(0)
21
21
  end
22
22
 
23
23
  it 'should see an empty queue' do
24
- expect {@queue.clear! }.to change { @queue.owned? }.from(true).to(false)
24
+ expect {@queue.clear }.to change { @queue.owned? }.from(true).to(false)
25
25
  end
26
26
  end
27
27
 
28
28
  describe '.enqueue' do
29
29
  context 'when no users are enqueued' do
30
30
  it 'returns the number of users in the queue' do
31
- expect(@queue.enqueue!('eric')).to eq(1)
31
+ expect(@queue.enqueue('eric')).to eq(1)
32
32
  end
33
33
  end
34
34
 
35
35
  context 'when some users are enqueued' do
36
- before { @queue.enqueue!('bob') }
37
- before { @queue.enqueue!('eric') }
36
+ before { @queue.enqueue('bob') }
37
+ before { @queue.enqueue('eric') }
38
38
  it 'should have a length of 2' do
39
39
  expect(@queue.length).to eq(2)
40
40
  end
41
41
 
42
42
  it 'should only add the user to the queue if it is unique' do
43
- expect(@queue.enqueue!('eric')).to eq(2)
43
+ expect(@queue.enqueue('eric')).to eq(2)
44
44
  expect(@queue.length).to eq(2)
45
45
  end
46
46
 
47
47
  it 'should add non-unique values if the queue is set to non-unique' do
48
48
  nonunique = Requeue::Queue.new(unique:false)
49
- nonunique.enqueue!('eric')
50
- expect{ nonunique.enqueue!('eric') }.to change { nonunique.length }.from(1).to(2)
49
+ nonunique.enqueue('eric')
50
+ expect{ nonunique.enqueue('eric') }.to change { nonunique.length }.from(1).to(2)
51
51
  end
52
52
  end
53
53
  end
@@ -60,8 +60,8 @@ describe Requeue::Queue do
60
60
  end
61
61
 
62
62
  context 'when some users are enqueued' do
63
- before { @queue.enqueue!('bob') }
64
- before { @queue.enqueue!('eric') }
63
+ before { @queue.enqueue('bob') }
64
+ before { @queue.enqueue('eric') }
65
65
 
66
66
  it 'should have the current users' do
67
67
  expect(@queue.list).to eq(['bob', 'eric'])
@@ -70,8 +70,8 @@ describe Requeue::Queue do
70
70
  end
71
71
 
72
72
  describe '.user_queued?' do
73
- before { @queue.enqueue!('bob') }
74
- before { @queue.enqueue!('eric') }
73
+ before { @queue.enqueue('bob') }
74
+ before { @queue.enqueue('eric') }
75
75
 
76
76
  it 'should show eric as queued' do
77
77
  expect(@queue.queued? 'eric').to eq(true)
@@ -87,8 +87,8 @@ describe Requeue::Queue do
87
87
  end
88
88
 
89
89
  describe '.user_position' do
90
- before { @queue.enqueue!('bob') }
91
- before { @queue.enqueue!('eric') }
90
+ before { @queue.enqueue('bob') }
91
+ before { @queue.enqueue('eric') }
92
92
 
93
93
  it 'eric should be in position 1 (the second place)' do
94
94
  expect(@queue.position 'eric').to eq(1)
@@ -97,11 +97,11 @@ describe Requeue::Queue do
97
97
  end
98
98
 
99
99
  describe '.dequeue' do
100
- before { @queue.enqueue!('bob') }
101
- before { @queue.enqueue!('eric') }
100
+ before { @queue.enqueue('bob') }
101
+ before { @queue.enqueue('eric') }
102
102
 
103
103
  it 'eric should be in position 1 (the second place)' do
104
- expect{ @queue.dequeue! }.to change {@queue.position 'eric'}.from(1).to(0)
104
+ expect{ @queue.dequeue }.to change {@queue.position 'eric'}.from(1).to(0)
105
105
  end
106
106
  end
107
107
 
@@ -113,33 +113,33 @@ describe Requeue::Queue do
113
113
  end
114
114
 
115
115
  context 'when a user is enqueued' do
116
- before { @queue.enqueue!('eric') }
116
+ before { @queue.enqueue('eric') }
117
117
  it 'should be owned' do
118
118
  expect(@queue.owner).to eq('eric')
119
119
  end
120
120
  end
121
121
  end
122
122
 
123
- describe '.remove!' do
124
- before { @queue.enqueue!('bob') }
125
- before { @queue.enqueue!('eric') }
123
+ describe '.remove' do
124
+ before { @queue.enqueue('bob') }
125
+ before { @queue.enqueue('eric') }
126
126
 
127
127
  it 'should not contain eric anymore' do
128
- expect { @queue.remove!('eric') }.to change {@queue.queued?('eric')}
129
- expect { @queue.remove!('eric') }.to_not change {@queue.queued?('bob')}
128
+ expect { @queue.remove('eric') }.to change {@queue.queued?('eric')}
129
+ expect { @queue.remove('eric') }.to_not change {@queue.queued?('bob')}
130
130
  end
131
131
  end
132
132
 
133
- describe '.steal!' do
134
- before { @queue.enqueue!('bob') }
135
- before { @queue.enqueue!('eric') }
133
+ describe '.steal' do
134
+ before { @queue.enqueue('bob') }
135
+ before { @queue.enqueue('eric') }
136
136
 
137
137
  it 'jim should own the queue' do
138
- expect { @queue.steal!('jim') }.to change { @queue.owner }.from('bob').to('jim')
138
+ expect { @queue.steal('jim') }.to change { @queue.owner }.from('bob').to('jim')
139
139
  end
140
140
 
141
141
  it 'the queue should still have everyone else in it' do
142
- expect { @queue.steal!('jim') }.to change { @queue.length }.from(2).to(3)
142
+ expect { @queue.steal('jim') }.to change { @queue.length }.from(2).to(3)
143
143
  end
144
144
  end
145
145
 
@@ -152,7 +152,7 @@ describe Requeue::Queue do
152
152
 
153
153
  context 'when a user is enqueued' do
154
154
  it 'should be owned' do
155
- expect { @queue.enqueue!('eric') }.to change { @queue.owned? }
155
+ expect { @queue.enqueue('eric') }.to change { @queue.owned? }
156
156
  end
157
157
  end
158
158
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: requeue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Fode
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-23 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,6 @@ files:
55
55
  - lib/requeue.rb
56
56
  - lib/requeue/version.rb
57
57
  - requeue.gemspec
58
- - spec/.requeue_spec.rb.swp
59
58
  - spec/requeue_spec.rb
60
59
  - spec/spec_helper.rb
61
60
  - spec/support/fakeredis.rb
@@ -84,7 +83,6 @@ signing_key:
84
83
  specification_version: 4
85
84
  summary: A simple resque based queue
86
85
  test_files:
87
- - spec/.requeue_spec.rb.swp
88
86
  - spec/requeue_spec.rb
89
87
  - spec/spec_helper.rb
90
88
  - spec/support/fakeredis.rb