canary_notifier 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/canary_notifier.gemspec +2 -4
- data/lib/canary_notifier.rb +18 -1
- metadata +13 -2
data/canary_notifier.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'canary_notifier'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.3'
|
4
4
|
s.authors = ["Henry Scudder"]
|
5
5
|
s.date = %q{2011-10-27}
|
6
6
|
s.summary = "Exception notification to Canary for Rails apps"
|
@@ -9,7 +9,5 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.files = `git ls-files`.split("\n")
|
10
10
|
s.require_path = 'lib'
|
11
11
|
|
12
|
-
|
13
|
-
#s.add_development_dependency "rails", ">= 3.0.4"
|
14
|
-
#s.add_development_dependency "sqlite3", ">= 1.3.4"
|
12
|
+
s.add_dependency("rest-client")
|
15
13
|
end
|
data/lib/canary_notifier.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
|
1
3
|
class CanaryNotifier
|
2
4
|
def initialize(app, options = {})
|
3
5
|
@app, @options = app, options
|
@@ -6,8 +8,23 @@ class CanaryNotifier
|
|
6
8
|
def call(env)
|
7
9
|
@app.call(env)
|
8
10
|
rescue Exception => exception
|
9
|
-
#Notifier.exception_notification(env, exception).deliver
|
10
11
|
puts "CANARY!!!"
|
12
|
+
url = 'http://stark:abc123@bugdrop.canary.io/notify'
|
13
|
+
first_line = e.backtrace.first
|
14
|
+
(file_name, line_number, method) = first_line.split(':')
|
15
|
+
data = {}
|
16
|
+
data["app_name"] = "Tester"
|
17
|
+
data["bug_name"] = "#{e.class.name}: #{e.to_s}"
|
18
|
+
data["bug_class"] = e.class.name
|
19
|
+
data["file_name"] = file_name
|
20
|
+
data["line_number"] = line_number.to_i
|
21
|
+
data["bug_method"] = method.split.last
|
22
|
+
data["language"] = 'ruby'
|
23
|
+
data["backtrace"] = e.backtrace.join("\n\t")
|
24
|
+
data["code_sample"] = File.readlines(file_name)[line_number.to_i - 4..line_number.to_i+2].join
|
25
|
+
data["code_sample_line_start"] = line_number.to_i - 3
|
26
|
+
RestClient.post url, data.to_json
|
27
|
+
|
11
28
|
raise exception
|
12
29
|
end
|
13
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canary_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,18 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2011-10-27 00:00:00.000000000Z
|
13
|
-
dependencies:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: &70189114815580 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70189114815580
|
14
25
|
description:
|
15
26
|
email: support@canaryhq.com
|
16
27
|
executables: []
|