bunny 0.4.4 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/Rakefile +21 -3
  2. data/bunny.gemspec +34 -20
  3. data/examples/{simple.rb → simple_08.rb} +0 -0
  4. data/examples/simple_09.rb +30 -0
  5. data/examples/{simple_ack.rb → simple_ack_08.rb} +0 -0
  6. data/examples/simple_ack_09.rb +33 -0
  7. data/examples/{simple_consumer.rb → simple_consumer_08.rb} +0 -0
  8. data/examples/simple_consumer_09.rb +55 -0
  9. data/examples/{simple_fanout.rb → simple_fanout_08.rb} +0 -0
  10. data/examples/simple_fanout_09.rb +39 -0
  11. data/examples/{simple_headers.rb → simple_headers_08.rb} +0 -0
  12. data/examples/simple_headers_09.rb +40 -0
  13. data/examples/{simple_publisher.rb → simple_publisher_08.rb} +0 -0
  14. data/examples/simple_publisher_09.rb +27 -0
  15. data/examples/{simple_topic.rb → simple_topic_08.rb} +0 -0
  16. data/examples/simple_topic_09.rb +59 -0
  17. data/lib/bunny.rb +19 -14
  18. data/lib/bunny/channel08.rb +38 -0
  19. data/lib/bunny/channel09.rb +38 -0
  20. data/lib/bunny/client08.rb +167 -74
  21. data/lib/bunny/{client091.rb → client09.rb} +195 -92
  22. data/lib/bunny/{exchange091.rb → exchange09.rb} +12 -11
  23. data/lib/bunny/queue08.rb +1 -0
  24. data/lib/bunny/{queue091.rb → queue09.rb} +38 -28
  25. data/lib/qrack/client.rb +7 -0
  26. data/lib/qrack/protocol/{protocol.rb → protocol08.rb} +1 -4
  27. data/lib/qrack/protocol/protocol09.rb +133 -0
  28. data/lib/qrack/protocol/{spec091.rb → spec09.rb} +5 -5
  29. data/lib/qrack/qrack08.rb +2 -10
  30. data/lib/qrack/qrack09.rb +20 -0
  31. data/lib/qrack/transport/{buffer.rb → buffer08.rb} +0 -0
  32. data/lib/qrack/transport/buffer09.rb +276 -0
  33. data/lib/qrack/transport/{frame091.rb → frame09.rb} +8 -8
  34. data/spec/{bunny_spec.rb → spec_08/bunny_spec.rb} +4 -4
  35. data/spec/{exchange_spec.rb → spec_08/exchange_spec.rb} +3 -10
  36. data/spec/{queue_spec.rb → spec_08/queue_spec.rb} +1 -1
  37. data/spec/spec_09/bunny_spec.rb +40 -0
  38. data/spec/spec_09/exchange_spec.rb +131 -0
  39. data/spec/spec_09/queue_spec.rb +106 -0
  40. metadata +38 -22
  41. data/lib/qrack/qrack091.rb +0 -28
@@ -6,7 +6,7 @@
6
6
  # If this is not the case, please change the 'Bunny.new' call below to include
7
7
  # the relevant arguments e.g. @b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
8
8
 
9
- require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib bunny]))
9
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. lib bunny]))
10
10
 
11
11
  describe Bunny do
12
12
 
@@ -0,0 +1,40 @@
1
+ # bunny_spec.rb
2
+
3
+ # Assumes that target message broker/server has a user called 'guest' with a password 'guest'
4
+ # and that it is running on 'localhost'.
5
+
6
+ # If this is not the case, please change the 'Bunny.new' call below to include
7
+ # the relevant arguments e.g. @b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
8
+
9
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. lib bunny]))
10
+
11
+ describe Bunny do
12
+
13
+ before(:each) do
14
+ @b = Bunny.new(:spec => '09')
15
+ @b.start
16
+ end
17
+
18
+ it "should connect to an AMQP server" do
19
+ @b.status.should == :connected
20
+ end
21
+
22
+ it "should be able to create an exchange" do
23
+ exch = @b.exchange('test_exchange')
24
+ exch.should be_an_instance_of Bunny::Exchange09
25
+ exch.name.should == 'test_exchange'
26
+ @b.exchanges.has_key?('test_exchange').should be true
27
+ end
28
+
29
+ it "should be able to create a queue" do
30
+ q = @b.queue('test1')
31
+ q.should be_an_instance_of Bunny::Queue09
32
+ q.name.should == 'test1'
33
+ @b.queues.has_key?('test1').should be true
34
+ end
35
+
36
+ it "should be able to set QoS" do
37
+ @b.qos.should == :qos_ok
38
+ end
39
+
40
+ end
@@ -0,0 +1,131 @@
1
+ # exchange_spec.rb
2
+
3
+ # Assumes that target message broker/server has a user called 'guest' with a password 'guest'
4
+ # and that it is running on 'localhost'.
5
+
6
+ # If this is not the case, please change the 'Bunny.new' call below to include
7
+ # the relevant arguments e.g. @b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
8
+
9
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. lib bunny]))
10
+
11
+ describe Bunny do
12
+
13
+ before(:each) do
14
+ @b = Bunny.new(:spec => '09')
15
+ @b.start
16
+ end
17
+
18
+ it "should raise an error if instantiated as non-existent type" do
19
+ lambda { @b.exchange('bogus_ex', :type => :bogus) }.should raise_error(Bunny::ProtocolError)
20
+ end
21
+
22
+ it "should allow a default direct exchange to be instantiated by specifying :type" do
23
+ exch = @b.exchange('amq.direct', :type => :direct)
24
+ exch.should be_an_instance_of Bunny::Exchange09
25
+ exch.name.should == 'amq.direct'
26
+ exch.type.should == :direct
27
+ @b.exchanges.has_key?('amq.direct').should be true
28
+ end
29
+
30
+ it "should allow a default direct exchange to be instantiated without specifying :type" do
31
+ exch = @b.exchange('amq.direct')
32
+ exch.should be_an_instance_of Bunny::Exchange09
33
+ exch.name.should == 'amq.direct'
34
+ exch.type.should == :direct
35
+ @b.exchanges.has_key?('amq.direct').should be true
36
+ end
37
+
38
+ it "should allow a default fanout exchange to be instantiated without specifying :type" do
39
+ exch = @b.exchange('amq.fanout')
40
+ exch.should be_an_instance_of Bunny::Exchange09
41
+ exch.name.should == 'amq.fanout'
42
+ exch.type.should == :fanout
43
+ @b.exchanges.has_key?('amq.fanout').should be true
44
+ end
45
+
46
+ it "should allow a default topic exchange to be instantiated without specifying :type" do
47
+ exch = @b.exchange('amq.topic')
48
+ exch.should be_an_instance_of Bunny::Exchange09
49
+ exch.name.should == 'amq.topic'
50
+ exch.type.should == :topic
51
+ @b.exchanges.has_key?('amq.topic').should be true
52
+ end
53
+
54
+ it "should allow a default headers (amq.match) exchange to be instantiated without specifying :type" do
55
+ exch = @b.exchange('amq.match')
56
+ exch.should be_an_instance_of Bunny::Exchange09
57
+ exch.name.should == 'amq.match'
58
+ exch.type.should == :headers
59
+ @b.exchanges.has_key?('amq.match').should be true
60
+ end
61
+
62
+ it "should allow a default headers (amq.headers) exchange to be instantiated without specifying :type" do
63
+ exch = @b.exchange('amq.headers')
64
+ exch.should be_an_instance_of Bunny::Exchange09
65
+ exch.name.should == 'amq.headers'
66
+ exch.type.should == :headers
67
+ @b.exchanges.has_key?('amq.headers').should be true
68
+ end
69
+
70
+ it "should create an exchange as direct by default" do
71
+ exch = @b.exchange('direct_defaultex')
72
+ exch.should be_an_instance_of Bunny::Exchange09
73
+ exch.name.should == 'direct_defaultex'
74
+ exch.type.should == :direct
75
+ @b.exchanges.has_key?('direct_defaultex').should be true
76
+ end
77
+
78
+ it "should be able to be instantiated as a direct exchange" do
79
+ exch = @b.exchange('direct_exchange', :type => :direct)
80
+ exch.should be_an_instance_of Bunny::Exchange09
81
+ exch.name.should == 'direct_exchange'
82
+ exch.type.should == :direct
83
+ @b.exchanges.has_key?('direct_exchange').should be true
84
+ end
85
+
86
+ it "should be able to be instantiated as a topic exchange" do
87
+ exch = @b.exchange('topic_exchange', :type => :topic)
88
+ exch.should be_an_instance_of Bunny::Exchange09
89
+ exch.name.should == 'topic_exchange'
90
+ exch.type.should == :topic
91
+ @b.exchanges.has_key?('topic_exchange').should be true
92
+ end
93
+
94
+ it "should be able to be instantiated as a fanout exchange" do
95
+ exch = @b.exchange('fanout_exchange', :type => :fanout)
96
+ exch.should be_an_instance_of Bunny::Exchange09
97
+ exch.name.should == 'fanout_exchange'
98
+ exch.type.should == :fanout
99
+ @b.exchanges.has_key?('fanout_exchange').should be true
100
+ end
101
+
102
+ it "should be able to be instantiated as a headers exchange" do
103
+ exch = @b.exchange('headers_exchange', :type => :headers)
104
+ exch.should be_an_instance_of Bunny::Exchange09
105
+ exch.name.should == 'headers_exchange'
106
+ exch.type.should == :headers
107
+ @b.exchanges.has_key?('headers_exchange').should be true
108
+ end
109
+
110
+ it "should ignore the :nowait option when instantiated" do
111
+ exch = @b.exchange('direct2_exchange', :nowait => true)
112
+ end
113
+
114
+ it "should be able to publish a message" do
115
+ exch = @b.exchange('direct_exchange')
116
+ exch.publish('This is a published message')
117
+ end
118
+
119
+ it "should be able to be deleted" do
120
+ exch = @b.exchange('direct_exchange')
121
+ res = exch.delete
122
+ res.should == :delete_ok
123
+ @b.exchanges.has_key?('direct_exchange').should be false
124
+ end
125
+
126
+ it "should ignore the :nowait option when deleted" do
127
+ exch = @b.exchange('direct2_exchange')
128
+ exch.delete(:nowait => true)
129
+ end
130
+
131
+ end
@@ -0,0 +1,106 @@
1
+ # queue_spec.rb
2
+
3
+ # Assumes that target message broker/server has a user called 'guest' with a password 'guest'
4
+ # and that it is running on 'localhost'.
5
+
6
+ # If this is not the case, please change the 'Bunny.new' call below to include
7
+ # the relevant arguments e.g. @b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
8
+
9
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. lib bunny]))
10
+
11
+ describe Bunny do
12
+
13
+ before(:each) do
14
+ @b = Bunny.new(:spec => '09')
15
+ @b.start
16
+ end
17
+
18
+ it "should ignore the :nowait option when instantiated" do
19
+ q = @b.queue('test0', :nowait => true)
20
+ end
21
+
22
+ it "should ignore the :nowait option when binding to an exchange" do
23
+ exch = @b.exchange('direct_exch')
24
+ q = @b.queue('test0')
25
+ q.bind(exch, :nowait => true).should == :bind_ok
26
+ end
27
+
28
+ it "should be able to bind to an exchange" do
29
+ exch = @b.exchange('direct_exch')
30
+ q = @b.queue('test1')
31
+ q.bind(exch).should == :bind_ok
32
+ end
33
+
34
+ it "should ignore the :nowait option when unbinding from an exchange" do
35
+ exch = @b.exchange('direct_exch')
36
+ q = @b.queue('test0')
37
+ q.unbind(exch, :nowait => true).should == :unbind_ok
38
+ end
39
+
40
+ it "should be able to unbind from an exchange" do
41
+ exch = @b.exchange('direct_exch')
42
+ q = @b.queue('test1')
43
+ q.unbind(exch).should == :unbind_ok
44
+ end
45
+
46
+ it "should be able to publish a message" do
47
+ q = @b.queue('test1')
48
+ q.publish('This is a test message')
49
+ q.message_count.should == 1
50
+ end
51
+
52
+ it "should be able to pop a message complete with header and delivery details" do
53
+ q = @b.queue('test1')
54
+ msg = q.pop(:header => true)
55
+ msg.should be_an_instance_of Hash
56
+ msg[:header].should be_an_instance_of Bunny::Protocol09::Header
57
+ msg[:payload].should == 'This is a test message'
58
+ msg[:delivery_details].should be_an_instance_of Hash
59
+ q.message_count.should == 0
60
+ end
61
+
62
+ it "should be able to pop a message and just get the payload" do
63
+ q = @b.queue('test1')
64
+ q.publish('This is another test message')
65
+ msg = q.pop
66
+ msg.should == 'This is another test message'
67
+ q.message_count.should == 0
68
+ end
69
+
70
+ it "should be able to be purged to remove all of its messages" do
71
+ q = @b.queue('test1')
72
+ 5.times {q.publish('This is another test message')}
73
+ q.message_count.should == 5
74
+ q.purge
75
+ q.message_count.should == 0
76
+ end
77
+
78
+ it "should return an empty message when popping an empty queue" do
79
+ q = @b.queue('test1')
80
+ q.publish('This is another test message')
81
+ q.pop
82
+ msg = q.pop
83
+ msg.should == :queue_empty
84
+ end
85
+
86
+ it "should be able to be deleted" do
87
+ q = @b.queue('test1')
88
+ res = q.delete
89
+ res.should == :delete_ok
90
+ @b.queues.has_key?('test1').should be false
91
+ end
92
+
93
+ it "should ignore the :nowait option when deleted" do
94
+ q = @b.queue('test0')
95
+ q.delete(:nowait => true)
96
+ end
97
+
98
+ it "should support server named queues" do
99
+ q = @b.queue
100
+ q.name.should_not == nil
101
+
102
+ @b.queue(q.name).should == q
103
+ q.delete
104
+ end
105
+
106
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-19 00:00:00 +01:00
12
+ date: 2009-08-08 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -26,34 +26,50 @@ files:
26
26
  - README
27
27
  - Rakefile
28
28
  - bunny.gemspec
29
- - examples/simple.rb
30
- - examples/simple_ack.rb
31
- - examples/simple_consumer.rb
32
- - examples/simple_fanout.rb
33
- - examples/simple_publisher.rb
34
- - examples/simple_topic.rb
35
- - examples/simple_headers.rb
29
+ - examples/simple_08.rb
30
+ - examples/simple_ack_08.rb
31
+ - examples/simple_consumer_08.rb
32
+ - examples/simple_fanout_08.rb
33
+ - examples/simple_publisher_08.rb
34
+ - examples/simple_topic_08.rb
35
+ - examples/simple_headers_08.rb
36
+ - examples/simple_09.rb
37
+ - examples/simple_ack_09.rb
38
+ - examples/simple_consumer_09.rb
39
+ - examples/simple_fanout_09.rb
40
+ - examples/simple_publisher_09.rb
41
+ - examples/simple_topic_09.rb
42
+ - examples/simple_headers_09.rb
36
43
  - lib/bunny.rb
44
+ - lib/bunny/channel08.rb
45
+ - lib/bunny/channel09.rb
37
46
  - lib/bunny/client08.rb
38
- - lib/bunny/client091.rb
47
+ - lib/bunny/client09.rb
39
48
  - lib/bunny/exchange08.rb
40
- - lib/bunny/exchange091.rb
49
+ - lib/bunny/exchange09.rb
41
50
  - lib/bunny/queue08.rb
42
- - lib/bunny/queue091.rb
51
+ - lib/bunny/queue09.rb
43
52
  - lib/qrack/client.rb
44
- - lib/qrack/protocol/protocol.rb
53
+ - lib/qrack/protocol/protocol08.rb
54
+ - lib/qrack/protocol/protocol09.rb
45
55
  - lib/qrack/protocol/spec08.rb
46
- - lib/qrack/protocol/spec091.rb
56
+ - lib/qrack/protocol/spec09.rb
47
57
  - lib/qrack/qrack08.rb
48
- - lib/qrack/qrack091.rb
49
- - lib/qrack/transport/buffer.rb
58
+ - lib/qrack/qrack09.rb
59
+ - lib/qrack/transport/buffer08.rb
60
+ - lib/qrack/transport/buffer09.rb
50
61
  - lib/qrack/transport/frame08.rb
51
- - lib/qrack/transport/frame091.rb
52
- - spec/bunny_spec.rb
53
- - spec/exchange_spec.rb
54
- - spec/queue_spec.rb
62
+ - lib/qrack/transport/frame09.rb
63
+ - spec/spec_08/bunny_spec.rb
64
+ - spec/spec_08/exchange_spec.rb
65
+ - spec/spec_08/queue_spec.rb
66
+ - spec/spec_09/bunny_spec.rb
67
+ - spec/spec_09/exchange_spec.rb
68
+ - spec/spec_09/queue_spec.rb
55
69
  has_rdoc: true
56
70
  homepage: http://github.com/celldee/bunny/tree/master
71
+ licenses: []
72
+
57
73
  post_install_message:
58
74
  rdoc_options:
59
75
  - --main
@@ -75,9 +91,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
91
  requirements: []
76
92
 
77
93
  rubyforge_project: bunny-amqp
78
- rubygems_version: 1.3.1
94
+ rubygems_version: 1.3.4
79
95
  signing_key:
80
- specification_version: 2
96
+ specification_version: 3
81
97
  summary: A synchronous Ruby AMQP client that enables interaction with AMQP-compliant brokers/servers.
82
98
  test_files: []
83
99
 
@@ -1,28 +0,0 @@
1
- $: << File.expand_path(File.dirname(__FILE__))
2
-
3
- require 'protocol/spec091'
4
- require 'protocol/protocol'
5
-
6
- require 'transport/buffer'
7
- require 'transport/frame091'
8
-
9
- require 'qrack/client'
10
-
11
- module Qrack
12
-
13
- include Protocol
14
- include Transport
15
-
16
- # Errors
17
- class BufferOverflowError < StandardError; end
18
- class InvalidTypeError < StandardError; end
19
-
20
- # Qrack version number
21
- VERSION = '0.0.1'
22
-
23
- # Return the Qrack version
24
- def self.version
25
- VERSION
26
- end
27
-
28
- end