bunny 0.4.3 → 0.4.4

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.
@@ -1,10 +1,10 @@
1
1
  $: << File.expand_path(File.dirname(__FILE__))
2
2
 
3
- require 'protocol/spec'
3
+ require 'protocol/spec08'
4
4
  require 'protocol/protocol'
5
5
 
6
6
  require 'transport/buffer'
7
- require 'transport/frame'
7
+ require 'transport/frame08'
8
8
 
9
9
  require 'qrack/client'
10
10
 
@@ -0,0 +1,28 @@
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
@@ -0,0 +1,94 @@
1
+
2
+ #:stopdoc:
3
+ # this file was autogenerated on Wed Jun 17 15:20:32 +0100 2009
4
+ #
5
+ # DO NOT EDIT! (edit ext/qparser.rb and config.yml instead, and run 'ruby qparser.rb')
6
+
7
+ module Qrack
8
+ module Transport
9
+ class Frame
10
+
11
+ FOOTER = 206
12
+ ID = 0
13
+
14
+ @types = {
15
+ 1 => 'Method',
16
+ 2 => 'Header',
17
+ 3 => 'Body',
18
+ 8 => 'Heartbeat',
19
+ }
20
+
21
+ attr_accessor :channel, :payload
22
+
23
+ def initialize payload = nil, channel = 0
24
+ @channel, @payload = channel, payload
25
+ end
26
+
27
+ def id
28
+ self.class::ID
29
+ end
30
+
31
+ def to_binary
32
+ buf = Transport::Buffer.new
33
+ buf.write :octet, id
34
+ buf.write :short, channel
35
+ buf.write :longstr, payload
36
+ buf.write :octet, FOOTER
37
+ buf.rewind
38
+ buf
39
+ end
40
+
41
+ def to_s
42
+ to_binary.to_s
43
+ end
44
+
45
+ def == frame
46
+ [ :id, :channel, :payload ].inject(true) do |eql, field|
47
+ eql and __send__(field) == frame.__send__(field)
48
+ end
49
+ end
50
+
51
+ def self.parse buf
52
+ buf = Transport::Buffer.new(buf) unless buf.is_a? Transport::Buffer
53
+ buf.extract do
54
+ id, channel, payload, footer = buf.read(:octet, :short, :longstr, :octet)
55
+ Qrack::Transport.const_get(@types[id]).new(payload, channel) if footer == FOOTER
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ class Method < Frame
62
+
63
+ ID = 1
64
+
65
+ def initialize payload = nil, channel = 0
66
+ super
67
+ unless @payload.is_a? Protocol::Class::Method or @payload.nil?
68
+ @payload = Protocol.parse(@payload)
69
+ end
70
+ end
71
+ end
72
+
73
+ class Header < Frame
74
+
75
+ ID = 2
76
+
77
+ def initialize payload = nil, channel = 0
78
+ super
79
+ unless @payload.is_a? Protocol::Header or @payload.nil?
80
+ @payload = Protocol::Header.new(@payload)
81
+ end
82
+ end
83
+ end
84
+
85
+ class Body < Frame
86
+ ID = 3
87
+ end
88
+
89
+ class Heartbeat < Frame
90
+ ID = 8
91
+ end
92
+
93
+ end
94
+ end
@@ -33,4 +33,8 @@ describe Bunny do
33
33
  @b.queues.has_key?('test1').should be true
34
34
  end
35
35
 
36
+ it "should be able to set QoS" do
37
+ @b.qos.should == :qos_ok
38
+ end
39
+
36
40
  end
@@ -8,7 +8,7 @@
8
8
 
9
9
  require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib bunny]))
10
10
 
11
- describe Bunny::Exchange do
11
+ describe Bunny do
12
12
 
13
13
  before(:each) do
14
14
  @b = Bunny.new
@@ -50,16 +50,26 @@ describe Bunny::Exchange do
50
50
  exch.type.should == :topic
51
51
  @b.exchanges.has_key?('amq.topic').should be true
52
52
  end
53
+
53
54
 
54
- # headers exchange not implemented in RabbitMQ yet. Uncomment if target broker/server supports it
55
- #
56
- #it "should allow a default headers exchange to be instantiated without specifying :type" do
57
- # exch = @b.exchange('amq.match')
58
- # exch.should be_an_instance_of Bunny::Exchange
59
- # exch.name.should == 'amq.match'
60
- # exch.type.should == :headers
61
- # @b.exchanges.has_key?('amq.match').should be true
62
- #end
55
+ =begin
56
+ #*** Uncomment these tests if your broker/server supports headers exchanges ***
57
+ it "should allow a default headers (amq.match) exchange to be instantiated without specifying :type" do
58
+ exch = @b.exchange('amq.match')
59
+ exch.should be_an_instance_of Bunny::Exchange
60
+ exch.name.should == 'amq.match'
61
+ exch.type.should == :headers
62
+ @b.exchanges.has_key?('amq.match').should be true
63
+ end
64
+
65
+ it "should allow a default headers (amq.headers) exchange to be instantiated without specifying :type" do
66
+ exch = @b.exchange('amq.headers')
67
+ exch.should be_an_instance_of Bunny::Exchange
68
+ exch.name.should == 'amq.headers'
69
+ exch.type.should == :headers
70
+ @b.exchanges.has_key?('amq.headers').should be true
71
+ end
72
+ =end
63
73
 
64
74
  it "should create an exchange as direct by default" do
65
75
  exch = @b.exchange('direct_defaultex')
@@ -92,6 +102,17 @@ describe Bunny::Exchange do
92
102
  exch.type.should == :fanout
93
103
  @b.exchanges.has_key?('fanout_exchange').should be true
94
104
  end
105
+
106
+ =begin
107
+ #*** Uncomment this test if your broker/server supports headers exchanges ***
108
+ it "should be able to be instantiated as a headers exchange" do
109
+ exch = @b.exchange('headers_exchange', :type => :headers)
110
+ exch.should be_an_instance_of Bunny::Exchange
111
+ exch.name.should == 'headers_exchange'
112
+ exch.type.should == :headers
113
+ @b.exchanges.has_key?('headers_exchange').should be true
114
+ end
115
+ =end
95
116
 
96
117
  it "should ignore the :nowait option when instantiated" do
97
118
  exch = @b.exchange('direct2_exchange', :nowait => true)
@@ -8,7 +8,7 @@
8
8
 
9
9
  require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib bunny]))
10
10
 
11
- describe Bunny::Queue do
11
+ describe Bunny do
12
12
 
13
13
  before(:each) do
14
14
  @b = Bunny.new
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.3
4
+ version: 0.4.4
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-10 00:00:00 +01:00
12
+ date: 2009-06-19 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,27 +25,35 @@ files:
25
25
  - LICENSE
26
26
  - README
27
27
  - Rakefile
28
+ - bunny.gemspec
28
29
  - examples/simple.rb
29
30
  - examples/simple_ack.rb
30
31
  - examples/simple_consumer.rb
31
32
  - examples/simple_fanout.rb
32
33
  - examples/simple_publisher.rb
33
34
  - examples/simple_topic.rb
35
+ - examples/simple_headers.rb
34
36
  - lib/bunny.rb
35
- - lib/bunny/client.rb
36
- - lib/bunny/exchange.rb
37
- - lib/bunny/queue.rb
37
+ - lib/bunny/client08.rb
38
+ - lib/bunny/client091.rb
39
+ - lib/bunny/exchange08.rb
40
+ - lib/bunny/exchange091.rb
41
+ - lib/bunny/queue08.rb
42
+ - lib/bunny/queue091.rb
38
43
  - lib/qrack/client.rb
39
44
  - lib/qrack/protocol/protocol.rb
40
- - lib/qrack/protocol/spec.rb
41
- - lib/qrack/qrack.rb
45
+ - lib/qrack/protocol/spec08.rb
46
+ - lib/qrack/protocol/spec091.rb
47
+ - lib/qrack/qrack08.rb
48
+ - lib/qrack/qrack091.rb
42
49
  - lib/qrack/transport/buffer.rb
43
- - lib/qrack/transport/frame.rb
50
+ - lib/qrack/transport/frame08.rb
51
+ - lib/qrack/transport/frame091.rb
44
52
  - spec/bunny_spec.rb
45
53
  - spec/exchange_spec.rb
46
54
  - spec/queue_spec.rb
47
55
  has_rdoc: true
48
- homepage: http://github.com/celldee/bunny
56
+ homepage: http://github.com/celldee/bunny/tree/master
49
57
  post_install_message:
50
58
  rdoc_options:
51
59
  - --main