boss_queue 0.5.3 → 0.5.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.5.3
1
+ 0.5.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "boss_queue"
8
- s.version = "0.5.3"
8
+ s.version = "0.5.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"]
12
- s.date = "2013-10-22"
12
+ s.date = "2013-12-23"
13
13
  s.description = "A fault tolerant job queue built around Amazon SQS & DynamoDB"
14
14
  s.email = "daniel@populr.me"
15
15
  s.extra_rdoc_files = [
@@ -99,7 +99,16 @@ class BossQueue
99
99
  end
100
100
 
101
101
  def sqs_queue # :nodoc:
102
- @sqs_queue ||= AWS::SQS.new.queues[AWS::SQS.new.queues.url_for(queue_name)]
102
+ @sqs_queue ||= BossQueue.sqs_queues[BossQueue.sqs_queue_url(queue_name)]
103
+ end
104
+
105
+ def self.sqs_queues # :nodoc:
106
+ @sqs_queues ||= AWS::SQS.new.queues
107
+ end
108
+
109
+ def self.sqs_queue_url(name) # :nodoc:
110
+ @url_mapping ||= {}
111
+ @url_mapping[name] ||= BossQueue.sqs_queues.url_for(name)
103
112
  end
104
113
 
105
114
  def self.environment # :nodoc:
@@ -137,7 +137,7 @@ class BossQueue
137
137
  end
138
138
 
139
139
  def sqs_queue
140
- @sqs_queue ||= AWS::SQS.new.queues[AWS::SQS.new.queues.url_for(queue_name)]
140
+ @sqs_queue ||= BossQueue.sqs_queues[BossQueue.sqs_queue_url(queue_name)]
141
141
  end
142
142
 
143
143
  # from ActiveSupport source: http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-constantize
@@ -250,8 +250,10 @@ describe "BossQueue module" do
250
250
  describe "#work" do
251
251
  before(:each) do
252
252
  @sqs_queue = double('queue')
253
- AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
254
- AWS::SQS.stub_chain(:new, :queues, :[]).and_return(@sqs_queue)
253
+ @sqs_queues = double('queues')
254
+ @sqs_queues.stub(:[]).and_return(@sqs_queue)
255
+ BossQueue.stub(:sqs_queues).and_return(@sqs_queues)
256
+ BossQueue.stub(:sqs_queue_url).and_return('queue_url')
255
257
 
256
258
  @sqs_message = double('message')
257
259
  @sqs_message.stub(:body).and_return('ijk')
@@ -224,10 +224,13 @@ describe "BossQueue::Job" do
224
224
 
225
225
  describe "#enqueue" do
226
226
  it "should enqueue id into the SQS queue" do
227
- queue = double('queue')
228
- AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
229
- AWS::SQS.stub_chain(:new, :queues, :[]).and_return(queue)
230
- queue.should_receive(:send_message).with('ijk')
227
+ sqs_queue = double('queue')
228
+ sqs_queues = double('queues')
229
+ sqs_queues.stub(:[]).and_return(sqs_queue)
230
+ BossQueue.stub(:sqs_queues).and_return(sqs_queues)
231
+ BossQueue.stub(:sqs_queue_url).and_return('queue_url')
232
+
233
+ sqs_queue.should_receive(:send_message).with('ijk')
231
234
  job = BossQueue::Job.new
232
235
  job.id = 'ijk'
233
236
  job.enqueue
@@ -236,30 +239,41 @@ describe "BossQueue::Job" do
236
239
 
237
240
  describe "#enqueue_with_delay" do
238
241
  it "should enqueue id into the SQS queue with a delay" do
239
- queue = double('queue')
240
- AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
241
- AWS::SQS.stub_chain(:new, :queues, :[]).and_return(queue)
242
- queue.should_receive(:send_message).with('ijk', :delay_seconds => 60)
242
+ sqs_queue = double('queue')
243
+ sqs_queues = double('queues')
244
+ sqs_queues.stub(:[]).and_return(sqs_queue)
245
+ BossQueue.stub(:sqs_queues).and_return(sqs_queues)
246
+ BossQueue.stub(:sqs_queue_url).and_return('queue_url')
247
+
248
+
249
+ sqs_queue.should_receive(:send_message).with('ijk', :delay_seconds => 60)
243
250
  job = BossQueue::Job.new
244
251
  job.id = 'ijk'
245
252
  job.enqueue_with_delay(60)
246
253
  end
247
254
 
248
255
  it "should limit the delay to 15 minutes" do
249
- queue = double('queue')
250
- AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
251
- AWS::SQS.stub_chain(:new, :queues, :[]).and_return(queue)
252
- queue.should_receive(:send_message).with('ijk', :delay_seconds => 900)
256
+ sqs_queue = double('queue')
257
+ sqs_queues = double('queues')
258
+ sqs_queues.stub(:[]).and_return(sqs_queue)
259
+ BossQueue.stub(:sqs_queues).and_return(sqs_queues)
260
+ BossQueue.stub(:sqs_queue_url).and_return('queue_url')
261
+
262
+
263
+ sqs_queue.should_receive(:send_message).with('ijk', :delay_seconds => 900)
253
264
  job = BossQueue::Job.new
254
265
  job.id = 'ijk'
255
266
  job.enqueue_with_delay(10000)
256
267
  end
257
268
 
258
269
  it "should set a negative delay to 0" do
259
- queue = double('queue')
260
- AWS::SQS.stub_chain(:new, :queues, :url_for).and_return('queue_url')
261
- AWS::SQS.stub_chain(:new, :queues, :[]).and_return(queue)
262
- queue.should_receive(:send_message).with('ijk', :delay_seconds => 0)
270
+ sqs_queue = double('queue')
271
+ sqs_queues = double('queues')
272
+ sqs_queues.stub(:[]).and_return(sqs_queue)
273
+ BossQueue.stub(:sqs_queues).and_return(sqs_queues)
274
+ BossQueue.stub(:sqs_queue_url).and_return('queue_url')
275
+
276
+ sqs_queue.should_receive(:send_message).with('ijk', :delay_seconds => 0)
263
277
  job = BossQueue::Job.new
264
278
  job.id = 'ijk'
265
279
  job.enqueue_with_delay(-60)
@@ -353,7 +367,7 @@ describe "BossQueue::Job" do
353
367
  @job.fail(@err)
354
368
  @job.exception_name.should == @err.class.to_s
355
369
  @job.exception_message.should == @err.message
356
- @job.stacktrace.should == @err.backtrace[0, 7].join("\n")
370
+ @job.stacktrace.should == @err.backtrace[0, 15].join("\n")
357
371
  end
358
372
 
359
373
  it "should call save!" do
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.5.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-22 00:00:00.000000000 Z
12
+ date: 2013-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: 969865320343825395
163
+ hash: -4280247350962711662
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements: