Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e6cfbcd
Showing
45 changed files
with
10,037 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.bundle/ | ||
log/*.log | ||
pkg/ | ||
spec/dummy/db/*.sqlite3 | ||
spec/dummy/log/*.log | ||
spec/dummy/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source "http://rubygems.org" | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
whoops_rails_notifier (0.0.1) | ||
rails (~> 3) | ||
whoops_notifier | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
abstract (1.0.0) | ||
actionmailer (3.0.7) | ||
actionpack (= 3.0.7) | ||
mail (~> 2.2.15) | ||
actionpack (3.0.7) | ||
activemodel (= 3.0.7) | ||
activesupport (= 3.0.7) | ||
builder (~> 2.1.2) | ||
erubis (~> 2.6.6) | ||
i18n (~> 0.5.0) | ||
rack (~> 1.2.1) | ||
rack-mount (~> 0.6.14) | ||
rack-test (~> 0.5.7) | ||
tzinfo (~> 0.3.23) | ||
activemodel (3.0.7) | ||
activesupport (= 3.0.7) | ||
builder (~> 2.1.2) | ||
i18n (~> 0.5.0) | ||
activerecord (3.0.7) | ||
activemodel (= 3.0.7) | ||
activesupport (= 3.0.7) | ||
arel (~> 2.0.2) | ||
tzinfo (~> 0.3.23) | ||
activeresource (3.0.7) | ||
activemodel (= 3.0.7) | ||
activesupport (= 3.0.7) | ||
activesupport (3.0.7) | ||
arel (2.0.10) | ||
builder (2.1.2) | ||
capybara (0.4.0) | ||
celerity (>= 0.7.9) | ||
culerity (>= 0.2.4) | ||
mime-types (>= 1.16) | ||
nokogiri (>= 1.3.3) | ||
rack (>= 1.0.0) | ||
rack-test (>= 0.5.4) | ||
selenium-webdriver (>= 0.0.27) | ||
xpath (~> 0.1.2) | ||
celerity (0.8.9) | ||
childprocess (0.1.9) | ||
ffi (~> 1.0.6) | ||
columnize (0.3.2) | ||
culerity (0.2.15) | ||
diff-lcs (1.1.2) | ||
erubis (2.6.6) | ||
abstract (>= 1.0.0) | ||
ffi (1.0.9) | ||
i18n (0.5.0) | ||
json (1.5.1) | ||
json_pure (1.5.1) | ||
linecache (0.43) | ||
mail (2.2.19) | ||
activesupport (>= 2.3.6) | ||
i18n (>= 0.4.0) | ||
mime-types (~> 1.16) | ||
treetop (~> 1.4.8) | ||
mime-types (1.16) | ||
nokogiri (1.4.4) | ||
polyglot (0.3.1) | ||
rack (1.2.3) | ||
rack-mount (0.6.14) | ||
rack (>= 1.0.0) | ||
rack-test (0.5.7) | ||
rack (>= 1.0) | ||
rails (3.0.7) | ||
actionmailer (= 3.0.7) | ||
actionpack (= 3.0.7) | ||
activerecord (= 3.0.7) | ||
activeresource (= 3.0.7) | ||
activesupport (= 3.0.7) | ||
bundler (~> 1.0) | ||
railties (= 3.0.7) | ||
railties (3.0.7) | ||
actionpack (= 3.0.7) | ||
activesupport (= 3.0.7) | ||
rake (>= 0.8.7) | ||
thor (~> 0.14.4) | ||
rake (0.9.1) | ||
rspec (2.1.0) | ||
rspec-core (~> 2.1.0) | ||
rspec-expectations (~> 2.1.0) | ||
rspec-mocks (~> 2.1.0) | ||
rspec-core (2.1.0) | ||
rspec-expectations (2.1.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.1.0) | ||
rspec-rails (2.1.0) | ||
rspec (~> 2.1.0) | ||
ruby-debug (0.10.4) | ||
columnize (>= 0.1) | ||
ruby-debug-base (~> 0.10.4.0) | ||
ruby-debug-base (0.10.4) | ||
linecache (>= 0.3) | ||
rubyzip (0.9.4) | ||
selenium-webdriver (0.2.1) | ||
childprocess (>= 0.1.7) | ||
ffi (>= 1.0.7) | ||
json_pure | ||
rubyzip | ||
thor (0.14.6) | ||
treetop (1.4.9) | ||
polyglot (>= 0.3.1) | ||
tzinfo (0.3.27) | ||
whoops_notifier (0.0.2) | ||
json | ||
xpath (0.1.4) | ||
nokogiri (~> 1.3) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
capybara (= 0.4.0) | ||
rails (~> 3) | ||
rspec (= 2.1.0) | ||
rspec-rails | ||
ruby-debug | ||
whoops_notifier | ||
whoops_rails_notifier! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright 2011 YOURNAME | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= WhoopsRailsNotifier | ||
|
||
This project rocks and uses MIT-LICENSE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# encoding: UTF-8 | ||
require 'rubygems' | ||
begin | ||
require 'bundler/setup' | ||
rescue LoadError | ||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks' | ||
end | ||
|
||
require 'rake' | ||
require 'rake/rdoctask' | ||
|
||
require 'rspec/core' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec | ||
|
||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'WhoopsRailsNotifier' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README.rdoc') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require "digest" | ||
require "whoops_notifier" | ||
require "whoops_rails_notifier/action_controller_catcher" | ||
require "whoops_rails_notifier/controller_methods" | ||
require "whoops_rails_notifier/railtie" | ||
|
||
module WhoopsRailsNotifier | ||
def self.initialize | ||
configure | ||
create_controller_strategy | ||
end | ||
|
||
def self.configure | ||
WhoopsNotifier.config.logger = Rails.logger | ||
end | ||
|
||
def self.create_controller_strategy | ||
strategy = WhoopsNotifier::Strategy.new(:rails) | ||
strategy.add_report_modifier(:create_report_from_evidence) do |report, evidence| | ||
exception = evidence[:exception] | ||
request = evidence[:request] | ||
params = evidence[:params] | ||
environment = evidence[:environment] | ||
|
||
report.event_type = "exception" | ||
report.service = Rails.application.name | ||
report.environment = Rails.env | ||
report.message = exception.message | ||
report.event_time = Time.now | ||
report.details = evidence.except(:exception) | ||
end | ||
|
||
strategy.add_report_modifier(:create_event_group_identifier) do |report, evidence| | ||
identifer = "#{evidence[:controller]}##{evidence[:action]}" | ||
identifier << evidence[:exception].backtrace.collect{|l| l.sub(Rails.root, "")}.join("\n") | ||
report.event_group_identifier = Digest::MD5.hexdigest(identifier) | ||
end | ||
end | ||
|
||
def self.create_rack_strategy | ||
end | ||
end | ||
|
||
WhoopsRailsNotifier.initialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module WhoopsRails | ||
module ActionControllerCatcher | ||
# Sets up an alias chain to catch exceptions when Rails does | ||
def self.included(base) #:nodoc: | ||
base.send(:alias_method, :rescue_action_in_public_without_whoops, :rescue_action_in_public) | ||
base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_whoops) | ||
end | ||
|
||
private | ||
|
||
# Overrides the rescue_action method in ActionController::Base, but does not inhibit | ||
# any custom processing that is defined with Rails 2's exception helpers. | ||
def rescue_action_in_public_with_whoops(exception) | ||
evidence = {:exception => exception}.merge(whoops_request_data) | ||
WhoopsNotifierRails.notify(evidence) | ||
rescue_action_in_public_without_whoops(exception) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module WhoopsNotifierRails | ||
module ControllerMethods | ||
private | ||
|
||
# This method should be used for sending manual notifications while you are still | ||
# inside the controller. Otherwise it works like WhoopsNotifierRails.notify. | ||
def notify_whoops(exception) | ||
evidence = {:exception => exception}.merge(whoops_request_data) | ||
WhoopsNotifierRails.notify(:rails, evidence) | ||
end | ||
|
||
def whoops_request_data | ||
{ :parameters => whoops_filter_if_filtering(params.to_hash), | ||
:session_data => whoops_filter_if_filtering(whoops_session_data), | ||
:controller => params[:controller], | ||
:action => params[:action], | ||
:url => whoops_request_url, | ||
:cgi_data => whoops_filter_if_filtering(request.env) } | ||
end | ||
|
||
def whoops_filter_if_filtering(hash) | ||
return hash if ! hash.is_a?(Hash) | ||
|
||
if respond_to?(:filter_parameters) | ||
filter_parameters(hash) rescue hash | ||
else | ||
hash | ||
end | ||
end | ||
|
||
def whoops_session_data | ||
if session.respond_to?(:to_hash) | ||
session.to_hash | ||
else | ||
session.data | ||
end | ||
end | ||
|
||
def whoops_request_url | ||
url = "#{request.protocol}#{request.host}" | ||
|
||
unless [80, 443].include?(request.port) | ||
url << ":#{request.port}" | ||
end | ||
|
||
url << request.request_uri | ||
url | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module WhoopsRailsNotifier | ||
class Railtie < Rails::Railtie | ||
config.app_middleware.insert_after "ActionDispatch::Callbacks" | ||
initializer "whoops_rails_notifier.extend_action_controller_base" do | ||
ActionController::Base.send(:include, WhoopsRailsNotifier::ActionControllerCatcher) | ||
ActionController::Base.send(:include, WhoopsRailsNotifier::ControllerMethods) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
require 'rake' | ||
|
||
Dummy::Application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ApplicationHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Dummy</title> | ||
<%= stylesheet_link_tag :all %> | ||
<%= javascript_include_tag :defaults %> | ||
<%= csrf_meta_tag %> | ||
</head> | ||
<body> | ||
|
||
<%= yield %> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This file is used by Rack-based servers to start the application. | ||
|
||
require ::File.expand_path('../config/environment', __FILE__) | ||
run Dummy::Application |
Oops, something went wrong.