amqp-boilerplate 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,9 +30,11 @@ module AMQP
30
30
  # Macro for selecting exchange to bind to
31
31
  #
32
32
  # @param [String] name Exchange name
33
+ # @param [Hash] options Options that will be passed as options to {http://rdoc.info/github/ruby-amqp/amqp/master/AMQP/Queue#bind-instance_method AMQP::Queue#bind}
33
34
  # @return [void]
34
- def amqp_exchange(name)
35
+ def amqp_exchange(name, options = {})
35
36
  @exchange_name = name
37
+ @exchange_options = options
36
38
  end
37
39
 
38
40
  # Macro that sets up the amqp_queue for a class.
@@ -60,7 +62,8 @@ module AMQP
60
62
  channel.on_error(&consumer.method(:handle_channel_error))
61
63
 
62
64
  queue = channel.queue(@queue_name, @queue_options)
63
- queue.bind(@exchange_name) if @exchange_name
65
+ # Binding a queue to a exchange by passing a string (instead of a AMQP::Exchange instance)
66
+ queue.bind(@exchange_name, @exchange_options) if @exchange_name
64
67
  queue.subscribe(@subscription_options, &consumer.method(:handle_message))
65
68
 
66
69
  AMQP::Boilerplate.logger.info("[#{self.name}.start] Started consumer '#{self.name}'")
@@ -1,5 +1,5 @@
1
1
  module AMQP
2
2
  module Boilerplate
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -94,7 +94,6 @@ describe AMQP::Boilerplate::Consumer do
94
94
  describe "when an exchange name has been provided" do
95
95
  before(:each) do
96
96
  @exchange_name = "amq.fanout"
97
- BarConsumer.amqp_exchange(@exchange_name)
98
97
  end
99
98
 
100
99
  after(:each) do
@@ -102,7 +101,20 @@ describe AMQP::Boilerplate::Consumer do
102
101
  end
103
102
 
104
103
  it "should bind to the exchange" do
105
- @queue.should_receive(:bind).with(@exchange_name)
104
+ BarConsumer.amqp_exchange(@exchange_name)
105
+ @queue.should_receive(:bind).with(@exchange_name, anything)
106
+ BarConsumer.start
107
+ end
108
+
109
+ it "should pass an empty hash when no amqp_exchange options are defined" do
110
+ BarConsumer.amqp_exchange(@exchange_name)
111
+ @queue.should_receive(:bind).with(anything, {})
112
+ BarConsumer.start
113
+ end
114
+
115
+ it "should pass options to the bind method" do
116
+ BarConsumer.amqp_exchange(@exchange_name, :routing_key => 'foo.bar')
117
+ @queue.should_receive(:bind).with(anything, :routing_key => 'foo.bar')
106
118
  BarConsumer.start
107
119
  end
108
120
  end
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Baselier
@@ -16,13 +16,13 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-09-15 00:00:00 +02:00
19
+ date: 2011-09-20 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rake
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ type: :development
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
28
  - - ~>
@@ -32,12 +32,12 @@ dependencies:
32
32
  - 0
33
33
  - 9
34
34
  version: "0.9"
35
- type: :development
36
- version_requirements: *id001
35
+ prerelease: false
36
+ requirement: *id001
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
39
+ type: :development
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -47,12 +47,12 @@ dependencies:
47
47
  - 2
48
48
  - 6
49
49
  version: "2.6"
50
- type: :development
51
- version_requirements: *id002
50
+ prerelease: false
51
+ requirement: *id002
52
52
  - !ruby/object:Gem::Dependency
53
53
  name: yard
54
- prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
54
+ type: :development
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ~>
@@ -62,12 +62,12 @@ dependencies:
62
62
  - 0
63
63
  - 7
64
64
  version: "0.7"
65
- type: :development
66
- version_requirements: *id003
65
+ prerelease: false
66
+ requirement: *id003
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: amqp
69
- prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
69
+ type: :runtime
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
71
71
  none: false
72
72
  requirements:
73
73
  - - ~>
@@ -77,8 +77,8 @@ dependencies:
77
77
  - 0
78
78
  - 8
79
79
  version: "0.8"
80
- type: :runtime
81
- version_requirements: *id004
80
+ prerelease: false
81
+ requirement: *id004
82
82
  description: Collection of modules that aid in setting up AMQP producers and consumers.
83
83
  email:
84
84
  - patrick@kabisa.nl