catchex 0.0.2
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/LICENSE +20 -0
- data/README +8 -0
- data/Rakefile +51 -0
- data/bin/rake +38 -0
- data/lib/catchex/version.rb +3 -0
- data/lib/catchex.rb +99 -0
- metadata +87 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 [Braisdom]
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#
|
|
2
|
+
# To change this template, choose Tools | Templates
|
|
3
|
+
# and open the template in the editor.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require 'rubygems'
|
|
7
|
+
require 'rake'
|
|
8
|
+
require 'rake/clean'
|
|
9
|
+
require 'rake/gempackagetask'
|
|
10
|
+
require 'rake/rdoctask'
|
|
11
|
+
require 'rake/testtask'
|
|
12
|
+
require 'fileutils'
|
|
13
|
+
spec = Gem::Specification.new do |s|
|
|
14
|
+
s.name = 'catchex'
|
|
15
|
+
s.version = '0.0.2'
|
|
16
|
+
s.has_rdoc = false
|
|
17
|
+
s.bindir = 'bin'
|
|
18
|
+
s.add_dependency('rake', '>= 0.8')
|
|
19
|
+
s.rubyforge_project = 'rake'
|
|
20
|
+
s.homepage = "http://www.catchex.com"
|
|
21
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
|
22
|
+
s.summary = 'The notifier for Catchex'
|
|
23
|
+
s.description = s.summary
|
|
24
|
+
s.author = 'Braisdom'
|
|
25
|
+
s.email = 'wangyonghe@msn.com'
|
|
26
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
|
27
|
+
s.require_path = "lib"
|
|
28
|
+
s.bindir = "bin"
|
|
29
|
+
s.executables = ["rake"]
|
|
30
|
+
s.default_executable = 'rake'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Rake::GemPackageTask.new(spec) do |p|
|
|
34
|
+
p.gem_spec = spec
|
|
35
|
+
p.need_tar = true
|
|
36
|
+
p.need_zip = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
|
41
|
+
files =['README', 'LICENSE', 'lib/**/*.rb']
|
|
42
|
+
rdoc.rdoc_files.add(files)
|
|
43
|
+
rdoc.main = "README" # page to start on
|
|
44
|
+
rdoc.title = "catchex Docs"
|
|
45
|
+
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
|
46
|
+
rdoc.options << '--line-numbers'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Rake::TestTask.new do |t|
|
|
50
|
+
t.test_files = FileList['test/**/*.rb']
|
|
51
|
+
end
|
data/bin/rake
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
|
14
|
+
# all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
22
|
+
# IN THE SOFTWARE.
|
|
23
|
+
#++
|
|
24
|
+
|
|
25
|
+
begin
|
|
26
|
+
require 'rubygems'
|
|
27
|
+
rescue LoadError
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
require 'rake'
|
|
31
|
+
require "catchex"
|
|
32
|
+
|
|
33
|
+
begin
|
|
34
|
+
Rake.application.run
|
|
35
|
+
rescue Exception => e
|
|
36
|
+
CatchEx.catch(e, Rake.application.name)
|
|
37
|
+
raise e
|
|
38
|
+
end
|
data/lib/catchex.rb
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
require "catchex/version"
|
|
2
|
+
|
|
3
|
+
module CatchEx
|
|
4
|
+
require 'socket'
|
|
5
|
+
require "net/http"
|
|
6
|
+
require "rake"
|
|
7
|
+
|
|
8
|
+
@@CATCH_EX_URL = "http://www.catchex.com"
|
|
9
|
+
@@DATA_PUSH_URL = @@CATCH_EX_URL + "/service_ex"
|
|
10
|
+
@@REG_HOST_URL = @@CATCH_EX_URL + "/reg_host"
|
|
11
|
+
@@PLUGIN_VERSION = "1.0"
|
|
12
|
+
@@LANGUAGE = "Ruby"
|
|
13
|
+
|
|
14
|
+
class CatchExConfig
|
|
15
|
+
@@auth_key = ""
|
|
16
|
+
@@host_name = ""
|
|
17
|
+
|
|
18
|
+
def self.auth_key(auth_key = nil)
|
|
19
|
+
unless auth_key.nil?
|
|
20
|
+
@@auth_key = auth_key
|
|
21
|
+
else
|
|
22
|
+
return @@auth_key
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.host_name(host_name = nil)
|
|
27
|
+
unless host_name.nil?
|
|
28
|
+
@@host_name = host_name
|
|
29
|
+
else
|
|
30
|
+
return @@host_name
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
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
|
+
|
|
45
|
+
def configure
|
|
46
|
+
yield CatchExConfig
|
|
47
|
+
reg_host
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Fetch the local IP address for the hosts
|
|
51
|
+
def local_ip
|
|
52
|
+
orig = Socket.do_not_reverse_lookup
|
|
53
|
+
Socket.do_not_reverse_lookup =true # turn off reverse DNS resolution temporarily
|
|
54
|
+
UDPSocket.open do |s|
|
|
55
|
+
s.connect 'www.catchex.com', 1
|
|
56
|
+
s.addr.last
|
|
57
|
+
end
|
|
58
|
+
ensure
|
|
59
|
+
Socket.do_not_reverse_lookup = orig
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# The catch_ex is a convenient method for posting exception.
|
|
63
|
+
def catch(exception, service_name = "", from = "", url = "", params = {})
|
|
64
|
+
begin
|
|
65
|
+
Net::HTTP.post_form(URI.parse(@@DATA_PUSH_URL), {:version => @@PLUGIN_VERSION, :language => @@LANGUAGE,
|
|
66
|
+
:service_name => service_name, :auth_key => CatchExConfig.auth_key, :local_ip => local_ip, :message => exception.message,
|
|
67
|
+
:stack => exception.backtrace.join("\n"), :from => from, :url => url, :params => params.inspect})
|
|
68
|
+
rescue
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
module ActionController
|
|
74
|
+
def self.included(base) #:nodoc:
|
|
75
|
+
base.send :include, InstanceMethods
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
module InstanceMethods
|
|
79
|
+
def rescue_action(exception)
|
|
80
|
+
CatchEx.catch(exception, "Rails", request.remote_ip, request.path, params) if ENV['RAILS_ENV'] == 'production' # Posting the unrescued exception to CatchEx server.
|
|
81
|
+
super
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Instance method for posting the customized exception.
|
|
85
|
+
def catch_ex(exception)
|
|
86
|
+
CatchEx.catch(exception, "Rails", request.remote_ip, request.path, params) if ENV['RAILS_ENV'] == 'production'
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
module ActionView
|
|
92
|
+
def catchex_js app_name
|
|
93
|
+
javascript_include_tag URI.encode("http://www.catchex.com/apps/ce?auth_key=#{CatchExConfig.auth_key}&app_name=#{app_name}")
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
ActionController::Base.send :include, CatchEx::ActionController if defined? ActionController::Base
|
|
99
|
+
ActionView::Base.send :include, CatchEx::ActionView if defined? ActionView::Base
|
metadata
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: catchex
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 27
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 0
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.0.2
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Braisdom
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2011-09-03 00:00:00 +08:00
|
|
19
|
+
default_executable: rake
|
|
20
|
+
dependencies:
|
|
21
|
+
- !ruby/object:Gem::Dependency
|
|
22
|
+
name: rake
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 27
|
|
30
|
+
segments:
|
|
31
|
+
- 0
|
|
32
|
+
- 8
|
|
33
|
+
version: "0.8"
|
|
34
|
+
type: :runtime
|
|
35
|
+
version_requirements: *id001
|
|
36
|
+
description: The notifier for Catchex
|
|
37
|
+
email: wangyonghe@msn.com
|
|
38
|
+
executables:
|
|
39
|
+
- rake
|
|
40
|
+
extensions: []
|
|
41
|
+
|
|
42
|
+
extra_rdoc_files:
|
|
43
|
+
- README
|
|
44
|
+
- LICENSE
|
|
45
|
+
files:
|
|
46
|
+
- LICENSE
|
|
47
|
+
- README
|
|
48
|
+
- Rakefile
|
|
49
|
+
- bin/rake
|
|
50
|
+
- lib/catchex/version.rb
|
|
51
|
+
- lib/catchex.rb
|
|
52
|
+
has_rdoc: true
|
|
53
|
+
homepage: http://www.catchex.com
|
|
54
|
+
licenses: []
|
|
55
|
+
|
|
56
|
+
post_install_message:
|
|
57
|
+
rdoc_options: []
|
|
58
|
+
|
|
59
|
+
require_paths:
|
|
60
|
+
- lib
|
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
|
+
none: false
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
hash: 3
|
|
67
|
+
segments:
|
|
68
|
+
- 0
|
|
69
|
+
version: "0"
|
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
|
+
none: false
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
hash: 3
|
|
76
|
+
segments:
|
|
77
|
+
- 0
|
|
78
|
+
version: "0"
|
|
79
|
+
requirements: []
|
|
80
|
+
|
|
81
|
+
rubyforge_project: rake
|
|
82
|
+
rubygems_version: 1.3.7
|
|
83
|
+
signing_key:
|
|
84
|
+
specification_version: 3
|
|
85
|
+
summary: The notifier for Catchex
|
|
86
|
+
test_files: []
|
|
87
|
+
|