amqp-boilerplate 0.0.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ module AMQP
2
+ module Boilerplate
3
+ module ForceConsumers
4
+ attr_writer :force_consumers
5
+
6
+ # Wether or not to force loading consumers even if the server_type is not Passenger
7
+ #
8
+ # @see AMQP::Boilerplate.configure
9
+ def force_consumers
10
+ @force_consumers ||= false
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  module AMQP
2
2
  module Boilerplate
3
- VERSION = "0.0.8"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -5,6 +5,7 @@ require 'amqp/boilerplate/version'
5
5
 
6
6
  require 'amqp/boilerplate/consumer'
7
7
  require 'amqp/boilerplate/consumer_registry'
8
+ require 'amqp/boilerplate/force_consumers'
8
9
  require 'amqp/boilerplate/logging'
9
10
  require 'amqp/boilerplate/producer'
10
11
 
@@ -12,6 +13,7 @@ module AMQP
12
13
  module Boilerplate
13
14
  extend ConsumerRegistry
14
15
  extend Logging
16
+ extend ForceConsumers
15
17
 
16
18
  # Opens a channel to AMQP and starts all consumers
17
19
  #
@@ -44,7 +46,7 @@ module AMQP
44
46
 
45
47
  load_consumers
46
48
 
47
- if AMQP::Utilities::EventLoopHelper.server_type
49
+ if AMQP::Utilities::EventLoopHelper.server_type || force_consumers
48
50
  start_consumers
49
51
  else
50
52
  AMQP::Boilerplate.logger.debug("[#{self.name}.boot] Unknown server type, not starting consumers")
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe AMQP::Boilerplate::ForceConsumers do
4
+ before(:each) do
5
+ AMQP::Boilerplate.stub(:logger).and_return(mock.as_null_object)
6
+ @channel = mock(AMQP::Channel)
7
+ @channel.stub(:on_error).and_return(true)
8
+ end
9
+
10
+ describe "#force_consumers" do
11
+ before(:each) do
12
+ @channel_close = mock(:reply_code => "OK", :reply_text => "Something")
13
+ end
14
+
15
+ it "should be false by default" do
16
+ AMQP::Boilerplate.force_consumers.should be_an(FalseClass)
17
+ end
18
+ end
19
+ end
@@ -34,6 +34,7 @@ describe AMQP::Boilerplate do
34
34
 
35
35
  describe "when server type is unknown" do
36
36
  before(:each) do
37
+ AMQP::Boilerplate.force_consumers = false
37
38
  AMQP::Utilities::EventLoopHelper.stub(:server_type).and_return(nil)
38
39
  end
39
40
 
@@ -42,6 +43,13 @@ describe AMQP::Boilerplate do
42
43
  AMQP::Boilerplate.boot
43
44
  end
44
45
 
46
+ it "should start consumers if forced" do
47
+ AMQP::Boilerplate.force_consumers = true
48
+ AMQP::Boilerplate.should_receive(:start_consumers)
49
+ AMQP::Boilerplate.boot
50
+ end
51
+
52
+
45
53
  it "should log server type as 'unknown'" do
46
54
  AMQP::Boilerplate.logger.should_receive(:info).with(/Server Type: unknown/)
47
55
  AMQP::Boilerplate.boot
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amqp-boilerplate
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
9
  - 0
9
- - 8
10
- version: 0.0.8
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Baselier
@@ -16,12 +16,10 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-09-30 00:00:00 +02:00
20
- default_executable:
19
+ date: 2012-04-20 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: rake
24
- type: :development
25
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
26
24
  none: false
27
25
  requirements:
@@ -32,11 +30,11 @@ dependencies:
32
30
  - 0
33
31
  - 9
34
32
  version: "0.9"
33
+ type: :development
35
34
  prerelease: false
36
35
  requirement: *id001
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: rspec
39
- type: :development
40
38
  version_requirements: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
@@ -47,11 +45,11 @@ dependencies:
47
45
  - 2
48
46
  - 6
49
47
  version: "2.6"
48
+ type: :development
50
49
  prerelease: false
51
50
  requirement: *id002
52
51
  - !ruby/object:Gem::Dependency
53
52
  name: yard
54
- type: :development
55
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
56
54
  none: false
57
55
  requirements:
@@ -62,11 +60,11 @@ dependencies:
62
60
  - 0
63
61
  - 7
64
62
  version: "0.7"
63
+ type: :development
65
64
  prerelease: false
66
65
  requirement: *id003
67
66
  - !ruby/object:Gem::Dependency
68
67
  name: amqp
69
- type: :runtime
70
68
  version_requirements: &id004 !ruby/object:Gem::Requirement
71
69
  none: false
72
70
  requirements:
@@ -77,6 +75,7 @@ dependencies:
77
75
  - 0
78
76
  - 8
79
77
  version: "0.8"
78
+ type: :runtime
80
79
  prerelease: false
81
80
  requirement: *id004
82
81
  description: Collection of modules that aid in setting up AMQP producers and consumers.
@@ -102,17 +101,18 @@ files:
102
101
  - lib/amqp/boilerplate.rb
103
102
  - lib/amqp/boilerplate/consumer.rb
104
103
  - lib/amqp/boilerplate/consumer_registry.rb
104
+ - lib/amqp/boilerplate/force_consumers.rb
105
105
  - lib/amqp/boilerplate/logging.rb
106
106
  - lib/amqp/boilerplate/producer.rb
107
107
  - lib/amqp/boilerplate/version.rb
108
108
  - spec/amqp/boilerplate/consumer_registry_spec.rb
109
109
  - spec/amqp/boilerplate/consumer_spec.rb
110
+ - spec/amqp/boilerplate/force_consumers_spec.rb
110
111
  - spec/amqp/boilerplate/logging_spec.rb
111
112
  - spec/amqp/boilerplate/producer_spec.rb
112
113
  - spec/amqp/boilerplate_spec.rb
113
114
  - spec/fixtures/consumers/dummy_consumer.rb
114
115
  - spec/spec_helper.rb
115
- has_rdoc: true
116
116
  homepage: ""
117
117
  licenses: []
118
118
 
@@ -142,15 +142,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  requirements: []
143
143
 
144
144
  rubyforge_project: amqp-boilerplate
145
- rubygems_version: 1.5.2
145
+ rubygems_version: 1.8.22
146
146
  signing_key:
147
147
  specification_version: 3
148
148
  summary: Helper modules for quickly setting up AMQP producers/consumers
149
149
  test_files:
150
150
  - spec/amqp/boilerplate/consumer_registry_spec.rb
151
151
  - spec/amqp/boilerplate/consumer_spec.rb
152
+ - spec/amqp/boilerplate/force_consumers_spec.rb
152
153
  - spec/amqp/boilerplate/logging_spec.rb
153
154
  - spec/amqp/boilerplate/producer_spec.rb
154
155
  - spec/amqp/boilerplate_spec.rb
155
156
  - spec/fixtures/consumers/dummy_consumer.rb
156
157
  - spec/spec_helper.rb
158
+ has_rdoc: