catchex 0.0.2 → 0.0.3
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/Rakefile +1 -1
- data/bin/rake +1 -1
- data/lib/catchex.rb +22 -31
- metadata +4 -4
data/Rakefile
CHANGED
data/bin/rake
CHANGED
data/lib/catchex.rb
CHANGED
|
@@ -6,47 +6,37 @@ module CatchEx
|
|
|
6
6
|
require "rake"
|
|
7
7
|
|
|
8
8
|
@@CATCH_EX_URL = "http://www.catchex.com"
|
|
9
|
-
@@DATA_PUSH_URL = @@CATCH_EX_URL + "/
|
|
10
|
-
@@REG_HOST_URL = @@CATCH_EX_URL + "/reg_host"
|
|
9
|
+
@@DATA_PUSH_URL = @@CATCH_EX_URL + "/ex"
|
|
11
10
|
@@PLUGIN_VERSION = "1.0"
|
|
12
11
|
@@LANGUAGE = "Ruby"
|
|
13
12
|
|
|
14
|
-
class
|
|
15
|
-
@@
|
|
16
|
-
@@
|
|
13
|
+
class Config
|
|
14
|
+
@@project_key = ""
|
|
15
|
+
@@scenario = ""
|
|
17
16
|
|
|
18
|
-
def self.
|
|
19
|
-
unless
|
|
20
|
-
@@
|
|
17
|
+
def self.project_key(project_key = nil)
|
|
18
|
+
unless project_key.nil?
|
|
19
|
+
@@project_key = project_key
|
|
21
20
|
else
|
|
22
|
-
return @@
|
|
21
|
+
return @@project_key
|
|
23
22
|
end
|
|
24
23
|
end
|
|
25
24
|
|
|
26
|
-
def self.
|
|
27
|
-
unless
|
|
28
|
-
@@
|
|
25
|
+
def self.scenario(scenario = nil)
|
|
26
|
+
unless scenario.nil?
|
|
27
|
+
@@scenario = scenario
|
|
29
28
|
else
|
|
30
|
-
return @@
|
|
29
|
+
return @@scenario
|
|
31
30
|
end
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
class << self
|
|
36
|
-
# Register the application when the rails starts.
|
|
37
|
-
def reg_host
|
|
38
|
-
begin
|
|
39
|
-
Net::HTTP.post_form(URI.parse(@@REG_HOST_URL), {:auth_key => CatchExConfig.auth_key,
|
|
40
|
-
:host_name => CatchExConfig.host_name, :local_ip => local_ip}) if ENV['RAILS_ENV'] == 'production'
|
|
41
|
-
rescue
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
35
|
|
|
45
36
|
def configure
|
|
46
|
-
yield
|
|
47
|
-
reg_host
|
|
37
|
+
yield Config
|
|
48
38
|
end
|
|
49
|
-
|
|
39
|
+
|
|
50
40
|
# Fetch the local IP address for the hosts
|
|
51
41
|
def local_ip
|
|
52
42
|
orig = Socket.do_not_reverse_lookup
|
|
@@ -60,11 +50,12 @@ module CatchEx
|
|
|
60
50
|
end
|
|
61
51
|
|
|
62
52
|
# The catch_ex is a convenient method for posting exception.
|
|
63
|
-
def catch(exception,
|
|
53
|
+
def catch(exception, from = "", url = "", params = {})
|
|
54
|
+
return if Config.project_key.blank? || Config.scenario.blank?
|
|
64
55
|
begin
|
|
65
56
|
Net::HTTP.post_form(URI.parse(@@DATA_PUSH_URL), {:version => @@PLUGIN_VERSION, :language => @@LANGUAGE,
|
|
66
|
-
:
|
|
67
|
-
:
|
|
57
|
+
:project_key => Config.project_key, :local_ip => local_ip, :message => exception.message, :scenario => Config.scenario,
|
|
58
|
+
:backtrace => exception.backtrace.join("\n"), :from => from, :url => url, :params => params.inspect})
|
|
68
59
|
rescue
|
|
69
60
|
end
|
|
70
61
|
end
|
|
@@ -77,20 +68,20 @@ module CatchEx
|
|
|
77
68
|
|
|
78
69
|
module InstanceMethods
|
|
79
70
|
def rescue_action(exception)
|
|
80
|
-
|
|
71
|
+
catch_ex(exception)
|
|
81
72
|
super
|
|
82
73
|
end
|
|
83
74
|
|
|
84
75
|
# Instance method for posting the customized exception.
|
|
85
76
|
def catch_ex(exception)
|
|
86
|
-
CatchEx.catch(exception,
|
|
77
|
+
CatchEx.catch(exception, request.remote_ip, request.url, params) if ENV['RAILS_ENV'] == 'production'
|
|
87
78
|
end
|
|
88
79
|
end
|
|
89
80
|
end
|
|
90
81
|
|
|
91
82
|
module ActionView
|
|
92
|
-
def catchex_js
|
|
93
|
-
javascript_include_tag URI.encode("http://www.catchex.com/apps/ce?
|
|
83
|
+
def catchex_js
|
|
84
|
+
javascript_include_tag URI.encode("http://www.catchex.com/apps/ce?porject_key=#{Config.prject_key}&scenario=#{Config.scenario}")
|
|
94
85
|
end
|
|
95
86
|
end
|
|
96
87
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: catchex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 25
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.0.3
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Braisdom
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2011-09-
|
|
18
|
+
date: 2011-09-20 00:00:00 +08:00
|
|
19
19
|
default_executable: rake
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|