sucker_punch 1.0.0.beta2 → 1.0.0.beta3

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: f9d68b7c7b9b1609f465227f56920578ca0cd037
4
- data.tar.gz: 561bf68629e9c4fc95b3156d29c168e081f85bcf
3
+ metadata.gz: a6a250f32e588a9b931f776dd670522ca0ec3ff7
4
+ data.tar.gz: 7be73d1af367060749480ea2eed8ad637beb8ea7
5
5
  SHA512:
6
- metadata.gz: 04688497fae792eb3bedd54c34261848632e18b956e2fe3fb539e4c9fee229a2c062745eede2f99359c3723b00eded0f065d4965597609a750125151f46d534a
7
- data.tar.gz: 7b579b1302292f6d36848f7a805dbe47d4b0521892b8b892d8821b2cdf7d46497b5a42450dfdb9c07459fdd9db90ddeb63a2a622c00bc8bf4ab591055d900404
6
+ metadata.gz: 43ca879a7efc7732acb5d2dedcea87fa25408e5982ad9d457bece8793b6474a03e2253aa44043350e8ed60c5f3686d0978a749eb788c84e530fab7eea83e1cd1
7
+ data.tar.gz: 8cdd511604d7422b883fc71f2a840f217ef881f3ec65cde8916bd916b76383008043ef87f4c4dc28f4357b6ee8195380bce181009dc3e62be4680c42f88bd971
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.0.0.beta3
2
+ --------
3
+
4
+ - Constrain workers when creating a queue to raise more helpful exceptions
5
+
1
6
  1.0.0.beta2
2
7
  --------
3
8
 
@@ -6,6 +6,8 @@ module SuckerPunch
6
6
  attr_accessor :pool
7
7
 
8
8
  DEFAULT_OPTIONS = { workers: 2 }
9
+ class MaxWorkersExceeded < StandardError; end
10
+ class NotEnoughWorkers < StandardError; end
9
11
 
10
12
  def self.find(klass)
11
13
  queue = self.new(klass)
@@ -19,6 +21,9 @@ module SuckerPunch
19
21
  end
20
22
 
21
23
  def register(workers = DEFAULT_OPTIONS[:workers] )
24
+ raise MaxWorkersExceeded if workers > 100
25
+ raise NotEnoughWorkers if workers < 1
26
+
22
27
  @mutex.synchronize {
23
28
  unless registered?
24
29
  initialize_celluloid_pool(workers)
@@ -1,3 +1,3 @@
1
1
  module SuckerPunch
2
- VERSION = "1.0.0.beta2"
2
+ VERSION = "1.0.0.beta3"
3
3
  end
@@ -43,6 +43,18 @@ describe SuckerPunch::Queue do
43
43
  queues = SuckerPunch::Queues.all
44
44
  expect(queues.size).to be(1)
45
45
  end
46
+
47
+ context "when too many workers are specified" do
48
+ it "raises a MaxWorkersExceeded exception" do
49
+ expect{ queue.register(101) }.to raise_error(SuckerPunch::Queue::MaxWorkersExceeded)
50
+ end
51
+ end
52
+
53
+ context "when too few workers are specified" do
54
+ it "raises a NotEnoughWorkers exception" do
55
+ expect{ queue.register(0) }.to raise_error(SuckerPunch::Queue::NotEnoughWorkers)
56
+ end
57
+ end
46
58
  end
47
59
 
48
60
  describe "#registered?" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sucker_punch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Hilkert