resque-aps 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.9.1 (2010-07-07)
2
+
3
+ * Minor changes to ease Application use with other outside classes, including the future feedback class.
4
+
1
5
  ## 0.9.0 (2010-07-05)
2
6
 
3
7
  * Initial code
@@ -33,8 +33,8 @@ module ResqueAps
33
33
  socket.write(n.formatted)
34
34
  app.after_aps_write n
35
35
  rescue
36
- logger.error application_exception($!) if logger
37
- app.failed_aps_write n
36
+ logger.error Application.application_exception($!, name) if logger
37
+ app.failed_aps_write n, $!
38
38
  end
39
39
  count += 1
40
40
  end
@@ -45,9 +45,7 @@ module ResqueAps
45
45
  #
46
46
  # Create the TCP and SSL sockets for sending the notification
47
47
  #
48
- def self.create_sockets(cert_file, passphrase, host, port)
49
- cert = File.read(cert_file)
50
-
48
+ def self.create_sockets(cert, passphrase, host, port)
51
49
  ctx = OpenSSL::SSL::SSLContext.new
52
50
  ctx.key = OpenSSL::PKey::RSA.new(cert, passphrase)
53
51
  ctx.cert = OpenSSL::X509::Certificate.new(cert)
@@ -80,23 +78,32 @@ module ResqueAps
80
78
  end
81
79
  end
82
80
 
81
+ def self.application_exception(exception, name)
82
+ exc = Exception.new("#{exception} (#{name})")
83
+ exc.set_backtrace(exception.backtrace)
84
+ return exc
85
+ end
86
+
83
87
  def initialize(attributes)
84
88
  attributes.each do |k, v|
85
89
  respond_to?(:"#{k}=") ? send(:"#{k}=", v) : raise(ResqueAps::UnknownAttributeError, "unknown attribute: #{k}")
86
90
  end
87
91
  end
88
92
 
89
- def socket(&block)
93
+ def socket(cert = nil, certp = nil, host = nil, port = nil, &block)
90
94
  logger.debug("resque-aps: ssl_socket(#{name})") if logger
91
95
  exc = nil
92
96
 
93
- socket, ssl_socket = Application.create_sockets(cert_file, cert_passwd, Resque.aps_gateway_host, Resque.aps_gateway_port)
97
+ socket, ssl_socket = Application.create_sockets(cert || File.read(cert_file),
98
+ certp || cert_passwd,
99
+ host || Resque.aps_gateway_host,
100
+ port || Resque.aps_gateway_port)
94
101
 
95
102
  begin
96
103
  ssl_socket.connect
97
104
  yield ssl_socket, self if block_given?
98
105
  rescue
99
- exc = application_exception($!)
106
+ exc = Application.application_exception($!, name)
100
107
  if $! =~ /^SSL_connect .* certificate (expired|revoked)/
101
108
  notify_aps_admin exc
102
109
  end
@@ -108,12 +115,6 @@ module ResqueAps
108
115
  exc
109
116
  end
110
117
 
111
- def application_exception(exception)
112
- exc = Exception.new("#{exception} (#{name})")
113
- exc.set_backtrace(exception.backtrace)
114
- return exc
115
- end
116
-
117
118
  def to_hash
118
119
  {'name' => name, 'cert_file' => cert_file, 'cert_passwd' => cert_passwd}
119
120
  end
@@ -128,7 +129,7 @@ module ResqueAps
128
129
  def after_aps_write(notification)
129
130
  end
130
131
 
131
- def failed_aps_write(notification)
132
+ def failed_aps_write(notification, exception)
132
133
  end
133
134
 
134
135
  def notify_aps_admin(exception)
@@ -1,3 +1,3 @@
1
1
  module ResqueAps
2
- Version = '0.9.0'
2
+ Version = '0.9.1'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 0
9
- version: 0.9.0
8
+ - 1
9
+ version: 0.9.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ashley Martens