lichtamberg-Lighthouse_Exception_Logger 0.0.1 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -1,5 +1,3 @@
1
- THIS GEM IS IN PROGRESS - ITS NOT WORKING AT THE MOMENT!
2
-
3
1
  = LighthouseExe
4
2
 
5
3
  * FIX (url)
@@ -7,7 +7,7 @@ require 'lighthouse'
7
7
  # Plugin for applications to automatically post errors to the Hoptoad of their choice.
8
8
  module LighthouseExceptionLogger
9
9
 
10
- VERSION = '0.0.1'
10
+ VERSION = '0.1'
11
11
  IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
12
12
  'ActionController::RoutingError',
13
13
  'ActionController::InvalidAuthenticityToken',
@@ -101,7 +101,7 @@ module LighthouseExceptionLogger
101
101
  end
102
102
 
103
103
  # This method should be used for sending manual notifications while you are still
104
- # inside the controller. Otherwise it works like LighthouseExceptionLogger.notify.
104
+ # inside the controller. Otherwise it works like HoptoadNotifier.notify.
105
105
  def notify_lighthouse hash_or_exception
106
106
  if public_environment?
107
107
  notice = normalize_notice(hash_or_exception)
@@ -127,7 +127,7 @@ module LighthouseExceptionLogger
127
127
  end
128
128
 
129
129
  def ignore?(exception) #:nodoc:
130
- ignore_these = LighthouseExceptionLogger.ignore.flatten
130
+ ignore_these = HoptoadNotifier.ignore.flatten
131
131
  ignore_these.include?(exception.class) || ignore_these.include?(exception.class.name)
132
132
  end
133
133
 
@@ -181,16 +181,29 @@ module LighthouseExceptionLogger
181
181
  end
182
182
 
183
183
  def send_to_LighthouseExceptionLogger data #:nodoc:
184
- Lighthouse.account = LIGHTHOUSE_ACCOUNT
185
- if defined?(LIGHTHOUSE_TOKEN)
186
- Lighthouse.token = LIGHTHOUSE_TOKEN
187
- else
188
- Lighthouse.authenticate(LIGHTHOUSE_USERNAME, LIGHTHOUSE_PASSWORD)
189
- end
190
184
 
191
- act_project = Project.find(LIGHTHOUSE_PROJETCT_ID)
192
- if act_project.tickets.count(:conditions => {["subject like ?", data.hashcode]})
193
- act_project.tickets.new(data).save
185
+ ## Hier alles einfügen
186
+ url = HoptoadNotifier.url
187
+ Net::HTTP.start(url.host, url.port) do |http|
188
+ headers = {
189
+ 'Content-type' => 'application/x-yaml',
190
+ 'Accept' => 'text/xml, application/xml'
191
+ }
192
+ http.read_timeout = 5 # seconds
193
+ http.open_timeout = 2 # seconds
194
+ http.use_ssl = !!HoptoadNotifier.secure
195
+ response = begin
196
+ http.post(url.path, stringify_keys(data).to_yaml, headers)
197
+ rescue TimeoutError => e
198
+ logger.error "Timeout while contacting the Hoptoad server."
199
+ nil
200
+ end
201
+ case response
202
+ when Net::HTTPSuccess then
203
+ logger.info "Hoptoad Success: #{response.class}"
204
+ else
205
+ logger.error "Hoptoad Failure: #{response.class}\n#{response.body if response.respond_to? :body}"
206
+ end
194
207
  end
195
208
  end
196
209
 
@@ -200,7 +213,7 @@ module LighthouseExceptionLogger
200
213
  end
201
214
 
202
215
  backtrace.to_a.map do |line|
203
- LighthouseExceptionLogger.backtrace_filters.inject(line) do |line, proc|
216
+ HoptoadNotifier.backtrace_filters.inject(line) do |line, proc|
204
217
  proc.call(line)
205
218
  end
206
219
  end
@@ -208,7 +221,7 @@ module LighthouseExceptionLogger
208
221
 
209
222
  def clean_LighthouseExceptionLogger_params params #:nodoc:
210
223
  params.each do |k, v|
211
- params[k] = "[FILTERED]" if LighthouseExceptionLogger.params_filters.any? do |filter|
224
+ params[k] = "[FILTERED]" if HoptoadNotifier.params_filters.any? do |filter|
212
225
  k.to_s.match(/#{filter}/)
213
226
  end
214
227
  end
@@ -216,7 +229,7 @@ module LighthouseExceptionLogger
216
229
 
217
230
  def clean_LighthouseExceptionLogger_environment env #:nodoc:
218
231
  env.each do |k, v|
219
- env[k] = "[FILTERED]" if LighthouseExceptionLogger.environment_filters.any? do |filter|
232
+ env[k] = "[FILTERED]" if HoptoadNotifier.environment_filters.any? do |filter|
220
233
  k.to_s.match(/#{filter}/)
221
234
  end
222
235
  end
@@ -247,6 +260,6 @@ module LighthouseExceptionLogger
247
260
  def rescue_action_in_public(exception)
248
261
  end
249
262
 
250
- include LighthouseExceptionLogger::Catcher
263
+ include HoptoadNotifier::Catcher
251
264
  end
252
265
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lichtamberg-Lighthouse_Exception_Logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: "0.1"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Lampesberger