celldee-bunny 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. data/README.markdown +15 -7
  2. data/lib/bunny/queue.rb +22 -5
  3. metadata +1 -1
data/README.markdown CHANGED
@@ -1,17 +1,18 @@
1
1
  # README
2
2
 
3
- ## Acknowledgements
4
-
5
- This project has borrowed heavily from the following two projects and owes their respective creators and collaborators a whole lot of gratitude:
6
-
7
- 1. **amqp** by *tmm1* (http://github.com/tmm1/amqp/tree/master)
8
- 2. **carrot** by *famoseagle* (http://github.com/famoseagle/carrot/tree/master)
9
-
10
3
  ## About
11
4
 
12
5
  *bunny* is an AMQP client, written in Ruby, that is intended to allow you to interact with AMQP-compliant message brokers/servers such as RabbitMQ in a synchronous fashion.
6
+
7
+ You can use *bunny* to -
8
+
9
+ * Create and delete exchanges
10
+ * Create and delete queues
11
+ * Publish and consume messages
13
12
 
14
13
  *bunny* is being tested with RabbitMQ version 1.5.4 and version 0-8 of the AMQP specification.
14
+
15
+ There is a Google Group for discussing bunny - [bunny-amqp](http://groups.google.com/group/bunny-amqp)
15
16
 
16
17
  ## Quick Start
17
18
 
@@ -44,6 +45,13 @@ This project has borrowed heavily from the following two projects and owes their
44
45
 
45
46
  puts 'This is the message: ' + msg + "\n\n"
46
47
 
48
+ ## Acknowledgements
49
+
50
+ This project has borrowed heavily from the following two projects and owes their respective creators and collaborators a whole lot of gratitude:
51
+
52
+ 1. **amqp** by *tmm1* [http://github.com/tmm1/amqp/tree/master](http://github.com/tmm1/amqp/tree/master)
53
+ 2. **carrot** by *famoseagle* [http://github.com/famoseagle/carrot/tree/master](http://github.com/famoseagle/carrot/tree/master)
54
+
47
55
  ## LICENSE
48
56
 
49
57
  Copyright (c) 2009 Chris Duncan; Published under The MIT License, see License
data/lib/bunny/queue.rb CHANGED
@@ -16,8 +16,15 @@
16
16
 
17
17
  def pop(opts = {})
18
18
  self.delivery_tag = nil
19
+
20
+ # do we want the header?
21
+ hdr = opts.delete(:header)
22
+
19
23
  client.send_frame(
20
- Protocol::Basic::Get.new({ :queue => name, :consumer_tag => name, :no_ack => !opts.delete(:ack), :nowait => true }.merge(opts))
24
+ Protocol::Basic::Get.new({ :queue => name,
25
+ :consumer_tag => name,
26
+ :no_ack => !opts.delete(:ack),
27
+ :nowait => true }.merge(opts))
21
28
  )
22
29
  method = client.next_method
23
30
  return unless method.is_a?(Protocol::Basic::GetOk)
@@ -28,7 +35,12 @@
28
35
  msg = client.next_payload
29
36
  raise 'unexpected length' if msg.length < header.size
30
37
 
31
- msg
38
+ if hdr
39
+ [header, msg]
40
+ else
41
+ msg
42
+ end
43
+
32
44
  end
33
45
 
34
46
  def ack
@@ -61,7 +73,10 @@
61
73
  exchange = exchange.respond_to?(:name) ? exchange.name : exchange
62
74
  bindings[exchange] = opts
63
75
  client.send_frame(
64
- Protocol::Queue::Bind.new({ :queue => name, :exchange => exchange, :routing_key => opts.delete(:key), :nowait => true }.merge(opts))
76
+ Protocol::Queue::Bind.new({ :queue => name,
77
+ :exchange => exchange,
78
+ :routing_key => opts.delete(:key),
79
+ :nowait => true }.merge(opts))
65
80
  )
66
81
  end
67
82
 
@@ -70,8 +85,10 @@
70
85
  bindings.delete(exchange)
71
86
 
72
87
  client.send_frame(
73
- Protocol::Queue::Unbind.new({
74
- :queue => name, :exchange => exchange, :routing_key => opts.delete(:key), :nowait => true }.merge(opts)
88
+ Protocol::Queue::Unbind.new({ :queue => name,
89
+ :exchange => exchange,
90
+ :routing_key => opts.delete(:key),
91
+ :nowait => true }.merge(opts)
75
92
  )
76
93
  )
77
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celldee-bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan