debugged-ruby 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/debugged-ruby.gemspec +3 -0
- data/lib/debugged-ruby/version.rb +1 -1
- data/lib/debugged-ruby.rb +51 -17
- metadata +49 -1
data/debugged-ruby.gemspec
CHANGED
@@ -13,7 +13,10 @@ Gem::Specification.new do |g|
|
|
13
13
|
g.requirements << "digest/sha1"
|
14
14
|
g.requirements << "httpclient"
|
15
15
|
g.requirements << "net/http"
|
16
|
+
g.add_dependency "logger"
|
16
17
|
g.add_dependency 'eventmachine'
|
17
18
|
g.add_dependency 'rack'
|
18
19
|
g.add_dependency 'em-http-request'
|
20
|
+
g.add_dependency 'padrino'
|
21
|
+
g.add_dependency 'sinatra'
|
19
22
|
end
|
data/lib/debugged-ruby.rb
CHANGED
@@ -8,25 +8,32 @@ require 'net/http'
|
|
8
8
|
require 'rubygems'
|
9
9
|
require 'eventmachine'
|
10
10
|
require 'em-http-request'
|
11
|
+
require 'padrino'
|
11
12
|
require 'rack'
|
13
|
+
require 'logger'
|
12
14
|
|
13
15
|
module Debugged
|
14
16
|
@@api_key = nil
|
17
|
+
@@log = Logger.new('debugged.txt')
|
18
|
+
|
19
|
+
def self.log
|
20
|
+
@@log
|
21
|
+
end
|
15
22
|
|
16
23
|
def self.api_key=(api_key)
|
17
24
|
@@api_key = api_key
|
18
|
-
p 'ffskfasdf'
|
19
25
|
end
|
20
26
|
|
21
27
|
def self.api_key
|
28
|
+
@@log.debug("API key set")
|
22
29
|
@@api_key
|
23
30
|
end
|
24
31
|
|
25
32
|
def self.report(e, data=nil)
|
26
33
|
|
27
34
|
unless data.is_a? Hash or data.nil?
|
28
|
-
#Log this
|
29
35
|
raise ArgumentError, 'Data argument is not Hash'
|
36
|
+
@@log.error("ERROR - data argument not passed as a Hash")
|
30
37
|
end
|
31
38
|
|
32
39
|
data ||= {}
|
@@ -50,8 +57,7 @@ module Debugged
|
|
50
57
|
"platform" => RUBY_PLATFORM.to_s}
|
51
58
|
}
|
52
59
|
|
53
|
-
|
54
|
-
url = "http://debugged.herokuapp.com/report"
|
60
|
+
url = "http://debugrged.herokuapp.com/report"
|
55
61
|
uri = URI(url)
|
56
62
|
|
57
63
|
req = Net::HTTP::Post.new(uri.request_uri)
|
@@ -59,21 +65,49 @@ module Debugged
|
|
59
65
|
req.body = report.to_json
|
60
66
|
|
61
67
|
pending = 1
|
68
|
+
|
62
69
|
EM.run do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
begin
|
71
|
+
http = EM::HttpRequest.new(url).post :body => report.to_json, :head => {'authorization' => [@@api_key, 'pass']}
|
72
|
+
http.callback {
|
73
|
+
pending -= 1
|
74
|
+
EM.stop if pending < 1
|
75
|
+
}
|
76
|
+
|
77
|
+
http.errback {
|
78
|
+
@@log.error(http.error)
|
79
|
+
|
80
|
+
pending -= 1
|
81
|
+
EM.stop if pending < 1
|
82
|
+
}
|
83
|
+
rescue Exception => e
|
84
|
+
@@log.error(e.backtrace)
|
85
|
+
end
|
75
86
|
end
|
76
87
|
|
77
|
-
"
|
88
|
+
"debueged.herokuapp.com/report/"+hash
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
module Rack
|
93
|
+
class Debugged
|
94
|
+
def initialize(app)
|
95
|
+
@app = app
|
96
|
+
end
|
97
|
+
|
98
|
+
def call(env)
|
99
|
+
begin
|
100
|
+
@app.call(env)
|
101
|
+
rescue Exception => e
|
102
|
+
::Debugged.report(e, {})
|
103
|
+
raise
|
104
|
+
end
|
105
|
+
|
106
|
+
e = env['sinatra.error']
|
107
|
+
if e
|
108
|
+
::Debugged.report(e, {})
|
109
|
+
raise
|
110
|
+
end
|
111
|
+
end
|
78
112
|
end
|
79
113
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debugged-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,6 +11,22 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: logger
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: eventmachine
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +75,38 @@ dependencies:
|
|
59
75
|
- - ! '>='
|
60
76
|
- !ruby/object:Gem::Version
|
61
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: padrino
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: sinatra
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
62
110
|
description: Ruby debugged
|
63
111
|
email: mitchh23@gmail.com
|
64
112
|
executables: []
|