boss_queue 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/boss_queue.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "boss_queue"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Nelson"]
@@ -22,13 +22,11 @@ class BossQueue
22
22
  timestamps
23
23
 
24
24
  def enqueue
25
- queue = AWS::SQS.new.queues[queue_name]
26
- queue.send_message(id.to_s)
25
+ sqs_queue.send_message(id.to_s)
27
26
  end
28
27
 
29
28
  def enqueue_with_delay(delay)
30
- queue = AWS::SQS.new.queues[queue_name]
31
- queue.send_message(id.to_s, :delay_seconds => [900, [0, delay].max].min)
29
+ sqs_queue.send_message(id.to_s, :delay_seconds => [900, [0, delay].max].min)
32
30
  end
33
31
 
34
32
  def work
@@ -68,8 +66,14 @@ class BossQueue
68
66
  60 * 2**(failed_attempts - 1)
69
67
  end
70
68
 
69
+ private
70
+
71
+ def sqs_queue
72
+ AWS::SQS.new.queues[AWS::SQS.new.queues.url_for(queue_name)]
73
+ end
74
+
71
75
  # from ActiveSupport source: http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-constantize
72
- def constantize(camel_cased_word) # :nodoc:
76
+ def constantize(camel_cased_word)
73
77
  names = camel_cased_word.split('::')
74
78
  names.shift if names.empty? || names.first.empty?
75
79
 
data/spec/job_spec.rb CHANGED
@@ -194,6 +194,7 @@ describe "BossQueue::Job" do
194
194
  describe "#enqueue" do
195
195
  it "should enqueue id into the SQS queue" do
196
196
  queue = double('queue')
197
+ AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
197
198
  AWS::SQS.stub_chain(:new, :queues, :[]).and_return(queue)
198
199
  queue.should_receive(:send_message).with('ijk')
199
200
  job = BossQueue::Job.new
@@ -205,6 +206,7 @@ describe "BossQueue::Job" do
205
206
  describe "#enqueue_with_delay" do
206
207
  it "should enqueue id into the SQS queue with a delay" do
207
208
  queue = double('queue')
209
+ AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
208
210
  AWS::SQS.stub_chain(:new, :queues, :[]).and_return(queue)
209
211
  queue.should_receive(:send_message).with('ijk', :delay_seconds => 60)
210
212
  job = BossQueue::Job.new
@@ -214,6 +216,7 @@ describe "BossQueue::Job" do
214
216
 
215
217
  it "should limit the delay to 15 minutes" do
216
218
  queue = double('queue')
219
+ AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
217
220
  AWS::SQS.stub_chain(:new, :queues, :[]).and_return(queue)
218
221
  queue.should_receive(:send_message).with('ijk', :delay_seconds => 900)
219
222
  job = BossQueue::Job.new
@@ -223,6 +226,7 @@ describe "BossQueue::Job" do
223
226
 
224
227
  it "should set a negative delay to 0" do
225
228
  queue = double('queue')
229
+ AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
226
230
  AWS::SQS.stub_chain(:new, :queues, :[]).and_return(queue)
227
231
  queue.should_receive(:send_message).with('ijk', :delay_seconds => 0)
228
232
  job = BossQueue::Job.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boss_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: 792604885145208685
163
+ hash: -4290568400388980813
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements: