fotonauts-amqp 0.6.1 → 0.6.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.
data/amqp.gemspec CHANGED
@@ -1,7 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'amqp'
3
- s.version = '0.6.1'
4
-
3
+ s.version = '0.6.4'
5
4
  s.date = '2009-01-09'
6
5
  s.summary = 'AMQP client implementation in Ruby/EventMachine'
7
6
  s.email = "amqp@tmm1.net"
data/lib/amqp/client.rb CHANGED
@@ -9,7 +9,7 @@ module AMQP
9
9
  mq.process_frame(frame)
10
10
  return
11
11
  end
12
-
12
+
13
13
  case frame
14
14
  when Frame::Method
15
15
  case method = frame.payload
@@ -49,7 +49,7 @@ module AMQP
49
49
  def self.client
50
50
  @client ||= BasicClient
51
51
  end
52
-
52
+
53
53
  def self.client= mod
54
54
  mod.__send__ :include, AMQP
55
55
  @client = mod
@@ -66,6 +66,8 @@ module AMQP
66
66
 
67
67
  timeout @settings[:timeout] if @settings[:timeout]
68
68
  errback{ @on_disconnect.call } unless @reconnecting
69
+
70
+ @connected = false
69
71
  end
70
72
 
71
73
  def connection_completed
@@ -73,16 +75,25 @@ module AMQP
73
75
  log 'connected'
74
76
  # @on_disconnect = proc{ raise Error, 'Disconnected from server' }
75
77
  unless @closing
76
- @on_disconnect = method(:reconnect)
78
+ @on_disconnect = method(:disconnected)
77
79
  @reconnecting = false
78
80
  end
81
+
82
+ @connected = true
83
+ @connection_status.call(:connected) if @connection_status
84
+
79
85
  @buf = Buffer.new
80
86
  send_data HEADER
81
87
  send_data [1, 1, VERSION_MAJOR, VERSION_MINOR].pack('C4')
82
88
  end
83
89
 
90
+ def connected?
91
+ @connected
92
+ end
93
+
84
94
  def unbind
85
95
  log 'disconnected'
96
+ @connected = false
86
97
  EM.next_tick{ @on_disconnect.call }
87
98
  end
88
99
 
@@ -96,7 +107,7 @@ module AMQP
96
107
  def channels
97
108
  @channels ||= {}
98
109
  end
99
-
110
+
100
111
  def receive_data data
101
112
  # log 'receive_data', data
102
113
  @buf << data
@@ -111,7 +122,7 @@ module AMQP
111
122
  # this is a stub meant to be
112
123
  # replaced by the module passed into initialize
113
124
  end
114
-
125
+
115
126
  def send data, opts = {}
116
127
  channel = opts[:channel] ||= 0
117
128
  data = data.to_frame(channel) unless data.is_a? Frame
@@ -177,9 +188,18 @@ module AMQP
177
188
  opts = AMQP.settings.merge(opts)
178
189
  EM.connect opts[:host], opts[:port], self, opts
179
190
  end
180
-
191
+
192
+ def connection_status &blk
193
+ @connection_status = blk
194
+ end
195
+
181
196
  private
182
-
197
+
198
+ def disconnected
199
+ @connection_status.call(:disconnected) if @connection_status
200
+ reconnect
201
+ end
202
+
183
203
  def log *args
184
204
  return unless @settings[:logging] or AMQP.logging
185
205
  require 'pp'
data/lib/amqp/protocol.rb CHANGED
@@ -32,7 +32,7 @@ module AMQP
32
32
 
33
33
  def to_binary
34
34
  buf = Buffer.new
35
- buf.write :short, self.class.parent.id
35
+ buf.write :short, self.class.section.id
36
36
  buf.write :short, self.class.id
37
37
 
38
38
  bits = []
data/lib/amqp/spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  #:stopdoc:
3
- # this file was autogenerated on Sat Jan 03 14:05:57 -0600 2009
3
+ # this file was autogenerated on Thu Jul 09 15:17:33 -0700 2009
4
4
  # using amqp-0.8.json (mtime: Sat Jan 03 08:58:13 -0600 2009)
5
5
  #
6
6
  # DO NOT EDIT! (edit protocol/codegen.rb instead, and run `rake codegen`)
@@ -96,9 +96,9 @@ module AMQP
96
96
 
97
97
  def arguments() @arguments ||= [] end
98
98
 
99
- def parent() Protocol.const_get(self.to_s[/Protocol::(.+?)::/,1]) end
100
- def id() self::ID end
101
- def name() self::NAME end
99
+ def section() Protocol.const_get(self.to_s[/Protocol::(.+?)::/,1]) end
100
+ def id() self::ID end
101
+ def name() self::NAME end
102
102
  end
103
103
 
104
104
  def == b
@@ -117,8 +117,8 @@ module AMQP
117
117
  def self.inherited klass
118
118
  klass.const_set(:ID, #{id})
119
119
  klass.const_set(:NAME, :#{name.to_s})
120
- klass.parent.methods[#{id}] = klass
121
- klass.parent.methods[klass::NAME] = klass
120
+ klass.section.methods[#{id}] = klass
121
+ klass.section.methods[klass::NAME] = klass
122
122
  end
123
123
  ]
124
124
  end
data/protocol/codegen.rb CHANGED
@@ -90,9 +90,9 @@ puts ERB.new(%q[
90
90
 
91
91
  def arguments() @arguments ||= [] end
92
92
 
93
- def parent() Protocol.const_get(self.to_s[/Protocol::(.+?)::/,1]) end
94
- def id() self::ID end
95
- def name() self::NAME end
93
+ def section() Protocol.const_get(self.to_s[/Protocol::(.+?)::/,1]) end
94
+ def id() self::ID end
95
+ def name() self::NAME end
96
96
  end
97
97
 
98
98
  def == b
@@ -111,8 +111,8 @@ puts ERB.new(%q[
111
111
  def self.inherited klass
112
112
  klass.const_set(:ID, #{id})
113
113
  klass.const_set(:NAME, :#{name.to_s})
114
- klass.parent.methods[#{id}] = klass
115
- klass.parent.methods[klass::NAME] = klass
114
+ klass.section.methods[#{id}] = klass
115
+ klass.section.methods[klass::NAME] = klass
116
116
  end
117
117
  ]
118
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fotonauts-amqp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
@@ -93,6 +93,7 @@ files:
93
93
  - research/primes-threaded.rb
94
94
  has_rdoc: true
95
95
  homepage: http://amqp.rubyforge.org/
96
+ licenses:
96
97
  post_install_message:
97
98
  rdoc_options:
98
99
  - --include=examples
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  requirements: []
114
115
 
115
116
  rubyforge_project:
116
- rubygems_version: 1.2.0
117
+ rubygems_version: 1.3.5
117
118
  signing_key:
118
119
  specification_version: 2
119
120
  summary: AMQP client implementation in Ruby/EventMachine