captivus 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -1
- data/README.md +9 -0
- data/captivus.gemspec +2 -1
- data/lib/captivus/backtrace/line.rb +14 -8
- data/lib/captivus/backtrace.rb +8 -2
- data/lib/captivus/configuration.rb +4 -2
- data/lib/captivus/notifier.rb +34 -0
- data/lib/captivus/payload.rb +70 -14
- data/lib/captivus/rack_capturer.rb +4 -8
- data/lib/captivus/rails_capturer.rb +21 -0
- data/lib/captivus/railtie.rb +35 -0
- data/lib/captivus/tasks/captivus.rake +12 -0
- data/lib/captivus/util.rb +24 -0
- data/lib/captivus/version.rb +1 -1
- data/lib/captivus.rb +30 -14
- data/rails-3.0-app/.rspec +1 -0
- data/rails-3.0-app/Gemfile +40 -0
- data/rails-3.0-app/README +256 -0
- data/rails-3.0-app/Rakefile +7 -0
- data/rails-3.0-app/app/controllers/application_controller.rb +3 -0
- data/rails-3.0-app/app/controllers/errors_controller.rb +5 -0
- data/rails-3.0-app/app/helpers/application_helper.rb +2 -0
- data/rails-3.0-app/app/views/layouts/application.html.erb +14 -0
- data/rails-3.0-app/config/application.rb +42 -0
- data/rails-3.0-app/config/boot.rb +6 -0
- data/rails-3.0-app/config/database.yml +7 -0
- data/rails-3.0-app/config/environment.rb +5 -0
- data/rails-3.0-app/config/environments/development.rb +26 -0
- data/rails-3.0-app/config/environments/production.rb +49 -0
- data/rails-3.0-app/config/environments/test.rb +35 -0
- data/rails-3.0-app/config/initializers/backtrace_silencers.rb +7 -0
- data/rails-3.0-app/config/initializers/captivus.rb +4 -0
- data/rails-3.0-app/config/initializers/inflections.rb +10 -0
- data/rails-3.0-app/config/initializers/mime_types.rb +5 -0
- data/rails-3.0-app/config/initializers/secret_token.rb +7 -0
- data/rails-3.0-app/config/initializers/session_store.rb +8 -0
- data/rails-3.0-app/config/locales/en.yml +5 -0
- data/rails-3.0-app/config/routes.rb +59 -0
- data/rails-3.0-app/config.ru +4 -0
- data/rails-3.0-app/db/seeds.rb +7 -0
- data/rails-3.0-app/public/404.html +26 -0
- data/rails-3.0-app/public/422.html +26 -0
- data/rails-3.0-app/public/500.html +26 -0
- data/rails-3.0-app/public/favicon.ico +0 -0
- data/rails-3.0-app/public/images/rails.png +0 -0
- data/rails-3.0-app/public/index.html +239 -0
- data/rails-3.0-app/public/javascripts/application.js +2 -0
- data/rails-3.0-app/public/javascripts/controls.js +965 -0
- data/rails-3.0-app/public/javascripts/dragdrop.js +974 -0
- data/rails-3.0-app/public/javascripts/effects.js +1123 -0
- data/rails-3.0-app/public/javascripts/prototype.js +6001 -0
- data/rails-3.0-app/public/javascripts/rails.js +202 -0
- data/rails-3.0-app/public/robots.txt +5 -0
- data/rails-3.0-app/script/rails +6 -0
- data/rails-3.0-app/spec/requests/events_from_rails_spec.rb +115 -0
- data/rails-3.0-app/spec/spec_helper.rb +38 -0
- data/rails-3.0-app/spec/support/captivus_api.rb +1 -0
- data/rails-3.1-app/.rspec +1 -0
- data/rails-3.1-app/Gemfile +44 -0
- data/rails-3.1-app/README +261 -0
- data/rails-3.1-app/Rakefile +7 -0
- data/rails-3.1-app/app/assets/images/rails.png +0 -0
- data/rails-3.1-app/app/assets/javascripts/application.js +9 -0
- data/rails-3.1-app/app/assets/stylesheets/application.css +7 -0
- data/rails-3.1-app/app/controllers/application_controller.rb +3 -0
- data/rails-3.1-app/app/controllers/errors_controller.rb +5 -0
- data/rails-3.1-app/app/helpers/application_helper.rb +2 -0
- data/rails-3.1-app/app/views/layouts/application.html.erb +14 -0
- data/rails-3.1-app/config/application.rb +54 -0
- data/rails-3.1-app/config/boot.rb +6 -0
- data/rails-3.1-app/config/database.yml +7 -0
- data/rails-3.1-app/config/environment.rb +5 -0
- data/rails-3.1-app/config/environments/development.rb +30 -0
- data/rails-3.1-app/config/environments/production.rb +60 -0
- data/rails-3.1-app/config/environments/test.rb +39 -0
- data/rails-3.1-app/config/initializers/backtrace_silencers.rb +7 -0
- data/rails-3.1-app/config/initializers/captivus.rb +4 -0
- data/rails-3.1-app/config/initializers/inflections.rb +10 -0
- data/rails-3.1-app/config/initializers/mime_types.rb +5 -0
- data/rails-3.1-app/config/initializers/secret_token.rb +7 -0
- data/rails-3.1-app/config/initializers/session_store.rb +8 -0
- data/rails-3.1-app/config/initializers/wrap_parameters.rb +14 -0
- data/rails-3.1-app/config/locales/en.yml +5 -0
- data/rails-3.1-app/config/routes.rb +59 -0
- data/rails-3.1-app/config.ru +4 -0
- data/rails-3.1-app/db/seeds.rb +7 -0
- data/rails-3.1-app/public/404.html +26 -0
- data/rails-3.1-app/public/422.html +26 -0
- data/rails-3.1-app/public/500.html +26 -0
- data/rails-3.1-app/public/favicon.ico +0 -0
- data/rails-3.1-app/public/index.html +241 -0
- data/rails-3.1-app/public/robots.txt +5 -0
- data/rails-3.1-app/script/rails +6 -0
- data/rails-3.1-app/spec/requests/events_from_rails_spec.rb +115 -0
- data/rails-3.1-app/spec/spec_helper.rb +38 -0
- data/rails-3.1-app/spec/support/captivus_api.rb +1 -0
- data/rails-3.2-app/.rspec +1 -0
- data/rails-3.2-app/Gemfile +47 -0
- data/rails-3.2-app/README.rdoc +261 -0
- data/rails-3.2-app/Rakefile +7 -0
- data/rails-3.2-app/app/assets/images/rails.png +0 -0
- data/rails-3.2-app/app/assets/javascripts/application.js +15 -0
- data/rails-3.2-app/app/assets/stylesheets/application.css +13 -0
- data/rails-3.2-app/app/controllers/application_controller.rb +3 -0
- data/rails-3.2-app/app/controllers/errors_controller.rb +5 -0
- data/rails-3.2-app/app/helpers/application_helper.rb +2 -0
- data/rails-3.2-app/app/views/layouts/application.html.erb +14 -0
- data/rails-3.2-app/config/application.rb +68 -0
- data/rails-3.2-app/config/boot.rb +6 -0
- data/rails-3.2-app/config/database.yml +7 -0
- data/rails-3.2-app/config/environment.rb +5 -0
- data/rails-3.2-app/config/environments/development.rb +37 -0
- data/rails-3.2-app/config/environments/production.rb +67 -0
- data/rails-3.2-app/config/environments/test.rb +37 -0
- data/rails-3.2-app/config/initializers/backtrace_silencers.rb +7 -0
- data/rails-3.2-app/config/initializers/captivus.rb +4 -0
- data/rails-3.2-app/config/initializers/inflections.rb +15 -0
- data/rails-3.2-app/config/initializers/mime_types.rb +5 -0
- data/rails-3.2-app/config/initializers/secret_token.rb +7 -0
- data/rails-3.2-app/config/initializers/session_store.rb +8 -0
- data/rails-3.2-app/config/initializers/wrap_parameters.rb +14 -0
- data/rails-3.2-app/config/locales/en.yml +5 -0
- data/rails-3.2-app/config/routes.rb +59 -0
- data/rails-3.2-app/config.ru +4 -0
- data/rails-3.2-app/db/schema.rb +16 -0
- data/rails-3.2-app/db/seeds.rb +7 -0
- data/rails-3.2-app/public/404.html +26 -0
- data/rails-3.2-app/public/422.html +26 -0
- data/rails-3.2-app/public/500.html +25 -0
- data/rails-3.2-app/public/favicon.ico +0 -0
- data/rails-3.2-app/public/index.html +241 -0
- data/rails-3.2-app/public/robots.txt +5 -0
- data/rails-3.2-app/script/rails +6 -0
- data/rails-3.2-app/spec/requests/events_from_rails_spec.rb +115 -0
- data/rails-3.2-app/spec/spec_helper.rb +38 -0
- data/rails-3.2-app/spec/support/captivus_api.rb +1 -0
- data/spec/captivus/backtrace/line_spec.rb +20 -10
- data/spec/captivus/backtrace_spec.rb +1 -3
- data/spec/captivus/configuration_spec.rb +3 -1
- data/spec/captivus/notifier_spec.rb +73 -0
- data/spec/captivus/payload_spec.rb +293 -28
- data/spec/captivus/rack_capturer_spec.rb +32 -15
- data/spec/captivus/rails_capturer_spec.rb +59 -0
- data/spec/captivus_spec.rb +50 -29
- data/spec/integration/events_from_rack_spec.rb +112 -74
- data/spec/spec_helper.rb +6 -29
- data/spec/support/captivus_api.rb +29 -0
- data/spec/support/delorean.rb +5 -0
- metadata +154 -4
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -27,3 +27,12 @@ TODO: Write usage instructions here
|
|
27
27
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
28
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
29
|
5. Create new Pull Request
|
30
|
+
|
31
|
+
# Rails testing setup
|
32
|
+
* rails _3.1.8_ new rails-3.1-app -G -d postgresql -T --old-style-hash
|
33
|
+
* setup error controller
|
34
|
+
* setup database.yml
|
35
|
+
* setup captivus config
|
36
|
+
* add specs
|
37
|
+
* setup Gemfile
|
38
|
+
* setup routes
|
data/captivus.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_dependency "faraday", '~> 0.8.4'
|
21
|
-
gem.add_dependency "multi_json", "~> 1.
|
21
|
+
gem.add_dependency "multi_json", "~> 1.2.0"
|
22
22
|
gem.add_dependency "captivus-auth_hmac", "0.0.2"
|
23
|
+
gem.add_dependency "json-schema", "~> 1.0.10"
|
23
24
|
end
|
@@ -1,21 +1,27 @@
|
|
1
1
|
module Captivus
|
2
2
|
class Backtrace
|
3
3
|
class Line
|
4
|
-
PATTERN = /^(
|
4
|
+
PATTERN = /^(.+?):(\d+)(?::in `([^']+)')?$/
|
5
5
|
|
6
6
|
def initialize(raw_line)
|
7
7
|
if match_data = PATTERN.match(raw_line)
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
:method => match_data[3]
|
12
|
-
}
|
8
|
+
@file = match_data[1]
|
9
|
+
@number = match_data[2].to_i
|
10
|
+
@method = match_data[3]
|
13
11
|
else
|
14
|
-
raise ArgumentError, "Unrecognized format"
|
12
|
+
raise ArgumentError, "Unrecognized format: #{raw_line.inspect}"
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
|
-
|
16
|
+
def as_json(*)
|
17
|
+
hash = {'file' => file, 'number' => number}
|
18
|
+
hash['method'] = method if method
|
19
|
+
hash
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :file, :number, :method
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
data/lib/captivus/backtrace.rb
CHANGED
@@ -6,9 +6,15 @@ module Captivus
|
|
6
6
|
unless exception.respond_to?(:backtrace)
|
7
7
|
raise ArgumentError, "#{exception} must respond to `backtrace`"
|
8
8
|
end
|
9
|
-
@
|
9
|
+
@exception = exception
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
def as_json(*)
|
13
|
+
Array(exception.backtrace).map { |line| Line.new(line).as_json }
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :exception
|
13
19
|
end
|
14
20
|
end
|
@@ -3,12 +3,14 @@ module Captivus
|
|
3
3
|
def initialize(attrs = {}, &block)
|
4
4
|
defaults = {
|
5
5
|
:scheme => 'http',
|
6
|
-
:host => 'api.captiv.us'
|
6
|
+
:host => 'api.captiv.us',
|
7
|
+
:environment => 'production',
|
8
|
+
:development_environments => %w[development test]
|
7
9
|
}
|
8
10
|
configure defaults.merge(attrs), &block
|
9
11
|
end
|
10
12
|
|
11
|
-
attr_accessor :host, :scheme, :api_key, :api_secret_key
|
13
|
+
attr_accessor :host, :scheme, :api_key, :api_secret_key, :environment, :development_environments
|
12
14
|
|
13
15
|
def configure(attrs = {})
|
14
16
|
attrs.each { |attr, value| send "#{attr}=", value }
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'captivus/util'
|
2
|
+
require 'faraday'
|
3
|
+
require 'faraday/request/hmac_authentication'
|
4
|
+
|
5
|
+
module Captivus
|
6
|
+
class Notifier
|
7
|
+
def initialize(config)
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def notify(payload)
|
12
|
+
return if config.development_environments.include?(config.environment)
|
13
|
+
|
14
|
+
connection = Faraday.new(:url => "#{config.scheme}://#{config.host}") do |faraday|
|
15
|
+
faraday.request :hmac_authentication, config.api_key, config.api_secret_key, {:service_id => 'Captivus'}
|
16
|
+
faraday.adapter :net_http
|
17
|
+
end
|
18
|
+
|
19
|
+
connection.post do |request|
|
20
|
+
request.headers['Content-Type'] = 'application/json; charset=UTF-8'
|
21
|
+
request.url '/events'
|
22
|
+
request.body = Captivus::Util.hash_to_json(payload)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def ==(other)
|
27
|
+
other.is_a?(Notifier) && config == other.config
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
attr_reader :config
|
33
|
+
end
|
34
|
+
end
|
data/lib/captivus/payload.rb
CHANGED
@@ -1,22 +1,78 @@
|
|
1
|
-
require 'captivus/
|
1
|
+
require 'captivus/util'
|
2
|
+
require 'json-schema'
|
2
3
|
|
3
4
|
module Captivus
|
4
5
|
class Payload
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
SCHEMA = {
|
7
|
+
'type' => 'object',
|
8
|
+
'properties' => {
|
9
|
+
'notifier' => {
|
10
|
+
'type' => 'object',
|
11
|
+
'required' => true,
|
12
|
+
'properties' => {
|
13
|
+
'name' => {'type' => 'string', 'required' => true},
|
14
|
+
'version' => {'type' => 'string', 'required' => true},
|
15
|
+
'language' => {'type' => 'string', 'required' => true}
|
16
|
+
}
|
17
|
+
},
|
18
|
+
'event' => {
|
19
|
+
'type' => 'object',
|
20
|
+
'required' => true,
|
21
|
+
'properties' => {
|
22
|
+
'type' => {'type' => 'string', 'required' => true},
|
23
|
+
'message' => {'type' => 'string', 'required' => true},
|
24
|
+
'timestamp' => {'type' => 'string', 'required' => true, 'format' => 'date-time'}
|
25
|
+
}
|
26
|
+
},
|
27
|
+
'backtrace' => {
|
28
|
+
'type' => 'array',
|
29
|
+
'required' => true,
|
30
|
+
'items' => {
|
31
|
+
'type' => 'object',
|
32
|
+
'properties' => {
|
33
|
+
'file' => {'type' => 'string', 'required' => true},
|
34
|
+
'number' => { 'type' => 'integer', 'required' => true},
|
35
|
+
'method' => {'type' => 'string'}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
},
|
39
|
+
'context' => {
|
40
|
+
'type' => 'object',
|
41
|
+
'properties' => {
|
42
|
+
'controller' => {'type' => 'string'},
|
43
|
+
'action' => {'type' => 'string'},
|
44
|
+
'params' => {'type' => 'object'}
|
45
|
+
}
|
46
|
+
},
|
47
|
+
'environment' => {
|
48
|
+
'type' => 'object',
|
49
|
+
'required' => true,
|
50
|
+
'properties' => {
|
51
|
+
'name' => {'type' => 'string', 'required' => true}
|
52
|
+
}
|
14
53
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
def initialize(json)
|
58
|
+
JSON::Validator.validate! SCHEMA, json
|
59
|
+
@json = json
|
60
|
+
end
|
61
|
+
|
62
|
+
def as_json(*)
|
63
|
+
Captivus::Util.json_to_hash json
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_json(*)
|
67
|
+
json.dup
|
68
|
+
end
|
69
|
+
|
70
|
+
def ==(other)
|
71
|
+
other.is_a?(Payload) && json == other.json
|
18
72
|
end
|
19
73
|
|
20
|
-
|
74
|
+
protected
|
75
|
+
|
76
|
+
attr_reader :json
|
21
77
|
end
|
22
78
|
end
|
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'captivus'
|
2
|
-
require 'faraday'
|
3
|
-
require 'multi_json'
|
4
2
|
|
5
3
|
module Captivus
|
6
4
|
class RackCapturer
|
@@ -9,12 +7,10 @@ module Captivus
|
|
9
7
|
end
|
10
8
|
|
11
9
|
def call(env)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
raise
|
17
|
-
end
|
10
|
+
@app.call env
|
11
|
+
rescue Exception => exception
|
12
|
+
Captivus.notify exception, :context => {:params => Rack::Request.new(env).params}
|
13
|
+
raise
|
18
14
|
end
|
19
15
|
|
20
16
|
private
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'captivus'
|
2
|
+
require 'captivus/rack_capturer'
|
3
|
+
|
4
|
+
module Captivus
|
5
|
+
class RailsCapturer < RackCapturer
|
6
|
+
def call(env)
|
7
|
+
@app.call env
|
8
|
+
rescue Exception => exception
|
9
|
+
controller = env['action_controller.instance']
|
10
|
+
params = controller.request.filtered_parameters
|
11
|
+
params.delete 'controller'
|
12
|
+
params.delete 'action'
|
13
|
+
Captivus.notify exception, 'context' => {
|
14
|
+
'controller' => controller.controller_name,
|
15
|
+
'action' => controller.action_name,
|
16
|
+
'params' => params
|
17
|
+
}
|
18
|
+
raise
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'captivus/rails_capturer'
|
3
|
+
|
4
|
+
module Captivus
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
rake_tasks { load "captivus/tasks/captivus.rake" }
|
7
|
+
|
8
|
+
config.before_initialize do
|
9
|
+
Captivus.configure do |config|
|
10
|
+
config.environment = Rails.env
|
11
|
+
end
|
12
|
+
# announce here?
|
13
|
+
end
|
14
|
+
|
15
|
+
initializer "captivus.use_rack_middleware" do |app|
|
16
|
+
app.config.middleware.use "Captivus::RailsCapturer"
|
17
|
+
end
|
18
|
+
|
19
|
+
# config.after_initialize do
|
20
|
+
# ::ActionController::Base.send :include, RailsControllerMethods
|
21
|
+
|
22
|
+
# if defined?(::ActionDispatch::DebugExceptions)
|
23
|
+
# # We should catch the exceptions in ActionDispatch::DebugExceptions in Rails 3.2.x.
|
24
|
+
# require 'crash_log/rails/middleware/debug_exception_catcher'
|
25
|
+
# ::ActionDispatch::DebugExceptions.__send__(:include, CrashLog::Rails::Middleware::DebugExceptionCatcher)
|
26
|
+
# elsif defined?(::ActionDispatch::ShowExceptions)
|
27
|
+
|
28
|
+
# # ActionDispatch::DebugExceptions is not defined in Rails 3.0.x and 3.1.x so
|
29
|
+
# # catch the exceptions in ShowExceptions.
|
30
|
+
# require 'crash_log/rails/middleware/debug_exception_catcher'
|
31
|
+
# ::ActionDispatch::ShowExceptions.send(:include, CrashLog::Rails::Middleware::DebugExceptionCatcher)
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :captivus do
|
2
|
+
desc "Send a test exception to Captivus"
|
3
|
+
task :test => :environment do
|
4
|
+
class Captivus::TestException < Exception; end
|
5
|
+
|
6
|
+
begin
|
7
|
+
raise Captivus::TestException, "This is a test exception"
|
8
|
+
rescue Captivus::TestException => exception
|
9
|
+
Captivus.notify exception
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
|
3
|
+
# TODO: test
|
4
|
+
module Captivus
|
5
|
+
module Util
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def hash_to_json(hash)
|
9
|
+
if MultiJson.respond_to?(:adapter)
|
10
|
+
MultiJson.dump hash
|
11
|
+
else
|
12
|
+
MultiJson.encode hash
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def json_to_hash(json)
|
17
|
+
if MultiJson.respond_to?(:adapter)
|
18
|
+
MultiJson.load json
|
19
|
+
else
|
20
|
+
MultiJson.decode json
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/captivus/version.rb
CHANGED
data/lib/captivus.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'captivus/util'
|
1
2
|
require "captivus/version"
|
2
3
|
require 'captivus/configuration'
|
3
|
-
require '
|
4
|
+
require 'captivus/notifier'
|
5
|
+
require 'captivus/backtrace'
|
6
|
+
require 'captivus/payload'
|
4
7
|
|
5
8
|
module Captivus
|
6
9
|
class << self
|
@@ -12,22 +15,35 @@ module Captivus
|
|
12
15
|
config.configure *args, &block
|
13
16
|
end
|
14
17
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def notifier
|
19
|
+
@notifier ||= Notifier.new config
|
20
|
+
end
|
21
|
+
|
22
|
+
def notify(exception, data = {})
|
23
|
+
notifier.notify build_payload(exception, data)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
20
27
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
28
|
+
def build_payload(exception, data = {})
|
29
|
+
if exception.respond_to?(:class) && exception.class.respond_to?(:name) && exception.respond_to?(:message)
|
30
|
+
event_json = {
|
31
|
+
'type' => exception.class.name,
|
32
|
+
'message' => exception.message,
|
33
|
+
'timestamp' => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
|
34
|
+
}
|
35
|
+
else
|
36
|
+
raise ArgumentError, "Unexpected exception: #{exception.inspect}"
|
25
37
|
end
|
38
|
+
|
39
|
+
Payload.new(Captivus::Util.hash_to_json({
|
40
|
+
'notifier' => {'name' => 'captivus', 'version' => Captivus::VERSION, 'language' => 'Ruby'},
|
41
|
+
'event' => event_json,
|
42
|
+
'backtrace' => Backtrace.new(exception).as_json,
|
43
|
+
'environment' => {'name' => config.environment}
|
44
|
+
}.merge(data)))
|
26
45
|
end
|
27
46
|
end
|
28
47
|
end
|
29
48
|
|
30
|
-
require 'captivus/
|
31
|
-
require 'captivus/backtrace'
|
32
|
-
require 'captivus/payload'
|
33
|
-
require 'captivus/rack_capturer'
|
49
|
+
require 'captivus/railtie' if defined?(Rails::Railtie)
|
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -0,0 +1,40 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.0.17'
|
4
|
+
|
5
|
+
# Bundle edge Rails instead:
|
6
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
+
|
8
|
+
gem 'pg'
|
9
|
+
|
10
|
+
# Use unicorn as the web server
|
11
|
+
# gem 'unicorn'
|
12
|
+
|
13
|
+
# Deploy with Capistrano
|
14
|
+
# gem 'capistrano'
|
15
|
+
|
16
|
+
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
17
|
+
# gem 'ruby-debug'
|
18
|
+
# gem 'ruby-debug19', :require => 'ruby-debug'
|
19
|
+
|
20
|
+
# Bundle the extra gems:
|
21
|
+
# gem 'bj'
|
22
|
+
# gem 'nokogiri'
|
23
|
+
# gem 'sqlite3-ruby', :require => 'sqlite3'
|
24
|
+
# gem 'aws-s3', :require => 'aws/s3'
|
25
|
+
|
26
|
+
# Bundle gems for the local environment. Make sure to
|
27
|
+
# put test-only gems in this group so their generators
|
28
|
+
# and rake tasks are available in development mode:
|
29
|
+
# group :development, :test do
|
30
|
+
# gem 'webrat'
|
31
|
+
# end
|
32
|
+
|
33
|
+
gem 'captivus', :path => '..'
|
34
|
+
|
35
|
+
group :test do
|
36
|
+
gem "rspec-rails", "~> 2.11.4"
|
37
|
+
gem "capybara", "~> 1.1.2"
|
38
|
+
gem "sham_rack", "~> 1.3"
|
39
|
+
gem "timecop", '~> 0.5'
|
40
|
+
end
|