Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

WIP: Hoptoad -> Airbrake

  • Loading branch information...
commit ceb0feb7ad1ec154df836cd7445d78cbd81825b4 1 parent 02220b1
Jon Yurek jyurek authored
Showing with 759 additions and 746 deletions.
  1. +6 −6 Rakefile
  2. +5 −5 hoptoad_notifier.gemspec → airbrake.gemspec
  3. +5 −5 features/metal.feature
  4. +5 −5 features/rack.feature
  5. +81 −81 features/rails.feature
  6. +15 −15 features/rails_with_js_notifier.feature
  7. +11 −11 features/rake.feature
  8. +5 −5 features/sinatra.feature
  9. +2 −2 features/{support/hoptoad_shim.rb.template → step_definitions/airbrake_shim.rb.template}
  10. +1 −1  features/step_definitions/rack_steps.rb
  11. +27 −27 features/step_definitions/rails_application_steps.rb
  12. +5 −5 features/step_definitions/rake_steps.rb
  13. +15 −0 features/support/airbrake_shim.rb.template
  14. +13 −13 features/support/rake/Rakefile
  15. +16 −16 features/user_informer.feature
  16. +21 −21 generators/{hoptoad/hoptoad_generator.rb → airbrake/airbrake_generator.rb}
  17. 0  generators/{hoptoad → airbrake}/lib/insert_commands.rb
  18. 0  generators/{hoptoad → airbrake}/lib/rake_commands.rb
  19. +7 −7 generators/{hoptoad/templates/hoptoad_notifier_tasks.rake → airbrake/templates/airbrake_tasks.rake}
  20. +6 −0 generators/airbrake/templates/capistrano_hook.rb
  21. +2 −2 generators/{hoptoad → airbrake}/templates/initializer.rb
  22. +0 −6 generators/hoptoad/templates/capistrano_hook.rb
  23. +25 −27 lib/{hoptoad_notifier.rb → airbrake.rb}
  24. +1 −1  lib/{hoptoad_notifier → airbrake}/backtrace.rb
  25. +21 −0 lib/airbrake/capistrano.rb
  26. +18 −18 lib/{hoptoad_notifier → airbrake}/configuration.rb
  27. +3 −3 lib/{hoptoad_notifier → airbrake}/notice.rb
  28. +42 −0 lib/airbrake/rack.rb
  29. +14 −14 lib/{hoptoad_notifier → airbrake}/rails.rb
  30. +10 −10 lib/{hoptoad_notifier → airbrake}/rails/action_controller_catcher.rb
  31. +16 −16 lib/{hoptoad_notifier → airbrake}/rails/controller_methods.rb
  32. +9 −9 lib/{hoptoad_notifier → airbrake}/rails/error_lookup.rb
  33. +8 −8 lib/{hoptoad_notifier → airbrake}/rails/javascript_notifier.rb
  34. +14 −14 lib/{hoptoad_notifier → airbrake}/rails3_tasks.rb
  35. +33 −0 lib/airbrake/railtie.rb
  36. +10 −10 lib/{hoptoad_notifier → airbrake}/rake_handler.rb
  37. +8 −8 lib/{hoptoad_notifier → airbrake}/sender.rb
  38. +6 −6 lib/{hoptoad_notifier → airbrake}/shared_tasks.rb
  39. +17 −17 lib/{hoptoad_notifier → airbrake}/tasks.rb
  40. +4 −4 lib/{hoptoad_notifier → airbrake}/user_informer.rb
  41. +1 −1  lib/{hoptoad_notifier → airbrake}/version.rb
  42. +11 −11 lib/{hoptoad_tasks.rb → airbrake_tasks.rb}
  43. +0 −21 lib/hoptoad_notifier/capistrano.rb
  44. +0 −42 lib/hoptoad_notifier/rack.rb
  45. +0 −33 lib/hoptoad_notifier/railtie.rb
  46. +21 −21 lib/rails/generators/{hoptoad/hoptoad_generator.rb → airbrake/airbrake_generator.rb}
  47. +4 −4 lib/templates/javascript_notifier.erb
  48. +6 −6 lib/templates/rescue.erb
  49. +1 −1  rails/init.rb
  50. +6 −6 script/integration_test.rb
  51. 0  test/{hoptoad_2_2.xsd → airbrake_2_2.xsd}
  52. +21 −21 test/{hoptoad_tasks_test.rb → airbrake_tasks_test.rb}
  53. +20 −20 test/backtrace_test.rb
  54. +23 −23 test/catcher_test.rb
  55. +24 −24 test/configuration_test.rb
  56. +18 −18 test/helper.rb
  57. +5 −5 test/javascript_notifier_test.rb
  58. +10 −10 test/logger_test.rb
  59. +10 −10 test/notice_test.rb
  60. +31 −31 test/notifier_test.rb
  61. +7 −7 test/rack_test.rb
  62. +8 −8 test/rails_initializer_test.rb
  63. +1 −1  test/recursion_test.rb
  64. +14 −14 test/sender_test.rb
  65. +10 −10 test/user_informer_test.rb
12 Rakefile
View
@@ -16,7 +16,7 @@ task :clean do
exec "rm -rf tmp"
end
-desc 'Test the hoptoad_notifier gem.'
+desc 'Test the airbrake gem.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
@@ -27,7 +27,7 @@ namespace :changeling do
desc "Bumps the version by a minor or patch version, depending on what was passed in."
task :bump, :part do |t, args|
# Thanks, Jeweler!
- if HoptoadNotifier::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
+ if Airbrake::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
major = $1.to_i
minor = $2.to_i
patch = $3.to_i
@@ -48,9 +48,9 @@ namespace :changeling do
version = [major, minor, patch, build].compact.join('.')
- File.open(File.join("lib", "hoptoad_notifier", "version.rb"), "w") do |f|
+ File.open(File.join("lib", "airbrake", "notifier", "version.rb"), "w") do |f|
f.write <<EOF
-module HoptoadNotifier
+module Airbrake
VERSION = "#{version}".freeze
end
EOF
@@ -59,10 +59,10 @@ EOF
desc "Writes out the new CHANGELOG and prepares the release"
task :change do
- load 'lib/hoptoad_notifier/version.rb'
+ load 'lib/airbrake/version.rb'
file = "CHANGELOG"
old = File.read(file)
- version = HoptoadNotifier::VERSION
+ version = Airbrake::VERSION
message = "Bumping to version #{version}"
File.open(file, "w") do |f|
10 hoptoad_notifier.gemspec → airbrake.gemspec
View
@@ -1,10 +1,10 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
-require "hoptoad_notifier/version"
+require "airbrake/version"
Gem::Specification.new do |s|
- s.name = %q{hoptoad_notifier}
- s.version = HoptoadNotifier::VERSION.dup
+ s.name = %q{airbrake}
+ s.version = Airbrake::VERSION.dup
s.summary = %q{Send your application errors to our hosted service and reclaim your inbox.}
s.require_paths = ["lib"]
@@ -26,8 +26,8 @@ Gem::Specification.new do |s|
s.add_development_dependency("shoulda", "~> 2.11.3")
s.authors = ["thoughtbot, inc"]
- s.email = %q{support@hoptoadapp.com}
- s.homepage = "http://www.hoptoadapp.com"
+ s.email = %q{support@airbrakeapp.com}
+ s.homepage = "http://www.airbrakeapp.com"
s.platform = Gem::Platform::RUBY
end
10 features/metal.feature
View
@@ -1,11 +1,11 @@
Feature: Rescue errors in Rails middleware
Background:
- Given I have built and installed the "hoptoad_notifier" gem
+ Given I have built and installed the "airbrake" gem
And I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run "script/generate hoptoad -k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run "script/generate airbrake -k myapikey"
Scenario: Rescue an exception in the dispatcher
When I define a Metal endpoint called "Exploder":
@@ -15,7 +15,7 @@ Feature: Rescue errors in Rails middleware
end
"""
When I perform a request to "http://example.com:123/metal/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| error message | RuntimeError: Explode |
| error class | RuntimeError |
| parameters | param: value |
10 features/rack.feature
View
@@ -1,25 +1,25 @@
Feature: Use the notifier in a plain Rack app
Background:
- Given I have built and installed the "hoptoad_notifier" gem
+ Given I have built and installed the "airbrake" gem
Scenario: Rescue and exception in a Rack app
Given the following Rack app:
"""
require 'rack'
- require 'hoptoad_notifier'
+ require 'airbrake'
- HoptoadNotifier.configure do |config|
+ Airbrake.configure do |config|
config.api_key = 'my_api_key'
end
app = Rack::Builder.app do
- use HoptoadNotifier::Rack
+ use Airbrake::Rack
run lambda { |env| raise "Rack down" }
end
"""
When I perform a Rack request to "http://example.com:123/test/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| error message | RuntimeError: Rack down |
| error class | RuntimeError |
| parameters | param: value |
162 features/rails.feature
View
@@ -1,43 +1,43 @@
Feature: Install the Gem in a Rails application
Background:
- Given I have built and installed the "hoptoad_notifier" gem
+ Given I have built and installed the "airbrake" gem
Scenario: Use the gem without vendoring the gem in a Rails application
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
Then the command should have run successfully
- And I should receive a Hoptoad notification
+ And I should receive a Airbrake notification
And I should see the Rails version
Scenario: vendor the gem and uninstall
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I unpack the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I unpack the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
Then the command should have run successfully
- When I uninstall the "hoptoad_notifier" gem
+ When I uninstall the "airbrake" gem
And I install cached gems
- And I run "rake hoptoad:test"
- Then I should see "** [Hoptoad] Success: Net::HTTPOK"
- And I should receive two Hoptoad notifications
+ And I run "rake airbrake:test"
+ Then I should see "** [Airbrake] Success: Net::HTTPOK"
+ And I should receive two Airbrake notifications
Scenario: Configure the notifier by hand
When I generate a new Rails application
- And I configure the Hoptoad shim
+ And I configure the Airbrake shim
And I configure the notifier to use "myapikey" as an API key
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with ""
- Then I should receive a Hoptoad notification
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with ""
+ Then I should receive a Airbrake notification
Scenario: Configuration within initializer isn't overridden by Railtie
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
Then the command should have run successfully
When I configure the notifier to use the following configuration lines:
"""
@@ -51,50 +51,50 @@ Feature: Install the Gem in a Rails application
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| project-root | argle/bargle |
Scenario: Try to install without an api key
When I generate a new Rails application
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with ""
- Then I should see "Must pass --api-key or --heroku or create config/initializers/hoptoad.rb"
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with ""
+ Then I should see "Must pass --api-key or --heroku or create config/initializers/airbrake.rb"
Scenario: Configure and deploy using only installed gem
When I generate a new Rails application
And I run "capify ."
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
And I run "cap -T"
- Then I should see "deploy:notify_hoptoad"
+ Then I should see "deploy:notify_airbrake"
Scenario: Configure and deploy using only vendored gem
When I generate a new Rails application
And I run "capify ."
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I unpack the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
- And I uninstall the "hoptoad_notifier" gem
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I unpack the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
+ And I uninstall the "airbrake" gem
And I install cached gems
And I run "cap -T"
- Then I should see "deploy:notify_hoptoad"
+ Then I should see "deploy:notify_airbrake"
- Scenario: Try to install when the hoptoad_notifier plugin still exists
+ Scenario: Try to install when the airbrake plugin still exists
When I generate a new Rails application
- And I install the "hoptoad_notifier" plugin
- And I configure the Hoptoad shim
+ And I install the "airbrake" plugin
+ And I configure the Airbrake shim
And I configure the notifier to use "myapikey" as an API key
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with ""
- Then I should see "You must first remove the hoptoad_notifier plugin. Please run: script/plugin remove hoptoad_notifier"
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with ""
+ Then I should see "You must first remove the airbrake plugin. Please run: script/plugin remove airbrake"
Scenario: Rescue an exception in a controller
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
And I define a response for "TestController#index":
"""
session[:value] = "test"
@@ -102,7 +102,7 @@ Feature: Install the Gem in a Rails application
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| component | test |
| action | index |
| error message | RuntimeError: some message |
@@ -113,56 +113,56 @@ Feature: Install the Gem in a Rails application
Scenario: The gem should not be considered a framework gem
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
And I run "rake gems"
- Then I should see that "hoptoad_notifier" is not considered a framework gem
+ Then I should see that "airbrake" is not considered a framework gem
Scenario: The app uses Vlad instead of Capistrano
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
And I run "touch config/deploy.rb"
And I run "rm Capfile"
- And I run the hoptoad generator with "-k myapikey"
+ And I run the airbrake generator with "-k myapikey"
Then "config/deploy.rb" should not contain "capistrano"
Scenario: Support the Heroku addon in the generator
When I generate a new Rails application
- And I configure the Hoptoad shim
+ And I configure the Airbrake shim
And I configure the Heroku rake shim
And I configure the Heroku gem shim with "myapikey"
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "--heroku"
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "--heroku"
Then the command should have run successfully
- And I should receive a Hoptoad notification
+ And I should receive a Airbrake notification
And I should see the Rails version
- And my Hoptoad configuration should contain the following line:
+ And my Airbrake configuration should contain the following line:
"""
- config.api_key = ENV['HOPTOAD_API_KEY']
+ config.api_key = ENV['AIRBRAKE_API_KEY']
"""
Scenario: Support the --app option for the Heroku addon in the generator
When I generate a new Rails application
- And I configure the Hoptoad shim
+ And I configure the Airbrake shim
And I configure the Heroku rake shim
And I configure the Heroku gem shim with "myapikey" and multiple app support
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "--heroku -a myapp"
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "--heroku -a myapp"
Then the command should have run successfully
- And I should receive a Hoptoad notification
+ And I should receive a Airbrake notification
And I should see the Rails version
- And my Hoptoad configuration should contain the following line:
+ And my Airbrake configuration should contain the following line:
"""
- config.api_key = ENV['HOPTOAD_API_KEY']
+ config.api_key = ENV['AIRBRAKE_API_KEY']
"""
Scenario: Filtering parameters in a controller
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
When I configure the notifier to use the following configuration lines:
"""
config.api_key = "myapikey"
@@ -175,7 +175,7 @@ Feature: Install the Gem in a Rails application
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| component | test |
| action | index |
| error message | RuntimeError: some message |
@@ -185,9 +185,9 @@ Feature: Install the Gem in a Rails application
Scenario: Filtering session in a controller
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
When I configure the notifier to use the following configuration lines:
"""
config.api_key = "myapikey"
@@ -200,7 +200,7 @@ Feature: Install the Gem in a Rails application
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| component | test |
| action | index |
| error message | RuntimeError: some message |
@@ -210,9 +210,9 @@ Feature: Install the Gem in a Rails application
Scenario: Filtering session and params based on Rails parameter filters
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
And I configure the application to filter parameter "secret"
And I define a response for "TestController#index":
"""
@@ -222,7 +222,7 @@ Feature: Install the Gem in a Rails application
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| component | test |
| action | index |
| error message | RuntimeError: some message |
@@ -231,20 +231,20 @@ Feature: Install the Gem in a Rails application
| session | secret: [FILTERED] |
| url | http://example.com:123/test/index?param=value |
- Scenario: Notify hoptoad within the controller
+ Scenario: Notify airbrake within the controller
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
And I define a response for "TestController#index":
"""
session[:value] = "test"
- notify_hoptoad(RuntimeError.new("some message"))
+ notify_airbrake(RuntimeError.new("some message"))
render :nothing => true
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| component | test |
| action | index |
| error message | RuntimeError: some message |
30 features/rails_with_js_notifier.feature
View
@@ -1,53 +1,53 @@
Feature: Install the Gem in a Rails application and enable the JavaScript notifier
Background:
- Given I have built and installed the "hoptoad_notifier" gem
+ Given I have built and installed the "airbrake" gem
Scenario: Include the Javascript notifier when enabled
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
When I configure the notifier to use the following configuration lines:
"""
config.api_key = "myapikey"
"""
And I define a response for "TestController#index":
"""
- render :inline => '<html><head profile="http://example.com"><%= hoptoad_javascript_notifier %></head><body></body></html>'
+ render :inline => '<html><head profile="http://example.com"><%= airbrake_javascript_notifier %></head><body></body></html>'
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index"
Then I should see the notifier JavaScript for the following:
| api_key | environment | host |
- | myapikey | production | hoptoadapp.com |
+ | myapikey | production | airbrakeapp.com |
And the notifier JavaScript should provide the following errorDefaults:
| url | component | action |
| http://example.com:123/test/index | test | index |
Scenario: Include the Javascript notifier when enabled using custom configuration settings
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
When I configure the notifier to use the following configuration lines:
"""
config.api_key = "myapikey!"
- config.host = "myhoptoad.com"
+ config.host = "myairbrake.com"
config.port = 3001
"""
And I define a response for "TestController#index":
"""
- render :inline => '<html><head><%= hoptoad_javascript_notifier %></head><body></body></html>'
+ render :inline => '<html><head><%= airbrake_javascript_notifier %></head><body></body></html>'
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index"
Then I should see the notifier JavaScript for the following:
| api_key | environment | host |
- | myapikey! | production | myhoptoad.com:3001 |
+ | myapikey! | production | myairbrake.com:3001 |
Scenario: Don't include the Javascript notifier by default
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
When I configure the notifier to use the following configuration lines:
"""
config.api_key = "myapikey!"
@@ -62,8 +62,8 @@ Feature: Install the Gem in a Rails application and enable the JavaScript notifi
Scenario: Don't include the Javascript notifier when enabled in non-public environments
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
When I configure the notifier to use the following configuration lines:
"""
config.api_key = "myapikey!"
@@ -71,7 +71,7 @@ Feature: Install the Gem in a Rails application and enable the JavaScript notifi
"""
And I define a response for "TestController#index":
"""
- render :inline => '<html><head><%= hoptoad_javascript_notifier %></head><body></body></html>'
+ render :inline => '<html><head><%= airbrake_javascript_notifier %></head><body></body></html>'
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index" in the "test" environment
22 features/rake.feature
View
@@ -1,23 +1,23 @@
Feature: Use the Gem to catch errors in a Rake application
Background:
- Given I have built and installed the "hoptoad_notifier" gem
+ Given I have built and installed the "airbrake" gem
Scenario: Catching exceptions in Rake
- When I run rake with hoptoad
- Then Hoptoad should catch the exception
+ When I run rake with airbrake
+ Then Airbrake should catch the exception
Scenario: Disabling Rake exception catcher
- When I run rake with hoptoad disabled
- Then Hoptoad should not catch the exception
+ When I run rake with airbrake disabled
+ Then Airbrake should not catch the exception
Scenario: Autodetect, running from terminal
- When I run rake with hoptoad autodetect from terminal
- Then Hoptoad should not catch the exception
+ When I run rake with airbrake autodetect from terminal
+ Then Airbrake should not catch the exception
Scenario: Autodetect, not running from terminal
- When I run rake with hoptoad autodetect not from terminal
- Then Hoptoad should catch the exception
+ When I run rake with airbrake autodetect not from terminal
+ Then Airbrake should catch the exception
Scenario: Sendind the correct component name
- When I run rake with hoptoad
- Then Hoptoad should send the rake command line as the component name
+ When I run rake with airbrake
+ Then Airbrake should send the rake command line as the component name
10 features/sinatra.feature
View
@@ -1,20 +1,20 @@
Feature: Use the notifier in a Sinatra app
Background:
- Given I have built and installed the "hoptoad_notifier" gem
+ Given I have built and installed the "airbrake" gem
Scenario: Rescue an exception in a Sinatra app
Given the following Rack app:
"""
require 'sinatra/base'
- require 'hoptoad_notifier'
+ require 'airbrake'
- HoptoadNotifier.configure do |config|
+ Airbrake.configure do |config|
config.api_key = 'my_api_key'
end
class FontaneApp < Sinatra::Base
- use HoptoadNotifier::Rack
+ use Airbrake::Rack
enable :raise_errors
get "/test/index" do
@@ -25,7 +25,7 @@ Feature: Use the notifier in a Sinatra app
app = FontaneApp
"""
When I perform a Rack request to "http://example.com:123/test/index?param=value"
- Then I should receive the following Hoptoad notification:
+ Then I should receive the following Airbrake notification:
| error message | RuntimeError: Sinatra has left the building |
| error class | RuntimeError |
| parameters | param: value |
4 features/support/hoptoad_shim.rb.template → features/step_definitions/airbrake_shim.rb.template
View
@@ -1,13 +1,13 @@
require 'sham_rack'
-ShamRack.at("hoptoadapp.com") do |env|
+ShamRack.at("airbrakeapp.com") do |env|
xml = env['rack.input'].read
puts "Recieved the following exception:\n#{xml}"
response = <<-end_xml
<?xml version="1.0" encoding="UTF-8"?>
<notice>
<error-id type="integer">3799307</error-id>
- <url>http://sample.hoptoadapp.com/errors/3799307/notices/643732254</url>
+ <url>http://sample.airbrakeapp.com/errors/3799307/notices/643732254</url>
<id type="integer">643732254</id>
</notice>
end_xml
2  features/step_definitions/rack_steps.rb
View
@@ -3,7 +3,7 @@
end
When /^I perform a Rack request to "([^\"]*)"$/ do |url|
- shim_file = File.join(PROJECT_ROOT, 'features', 'support', 'hoptoad_shim.rb.template')
+ shim_file = File.join(PROJECT_ROOT, 'features', 'support', 'airbrake_shim.rb.template')
request_file = File.join(TEMP_DIR, 'rack_request.rb')
File.open(request_file, 'w') do |file|
file.puts "require 'rubygems'"
54 features/step_definitions/rails_application_steps.rb
View
@@ -29,11 +29,11 @@
config_gem_dependencies unless rails3
end
-When /^I run the hoptoad generator with "([^\"]*)"$/ do |generator_args|
+When /^I run the airbrake generator with "([^\"]*)"$/ do |generator_args|
if rails3?
- When %{I run "script/rails generate hoptoad #{generator_args}"}
+ When %{I run "script/rails generate airbrake #{generator_args}"}
else
- When %{I run "script/generate hoptoad #{generator_args}"}
+ When %{I run "script/generate airbrake #{generator_args}"}
end
end
@@ -57,8 +57,8 @@
else
File.open(environment_path, 'a') do |file|
file.puts
- file.puts("require 'hoptoad_notifier'")
- file.puts("require 'hoptoad_notifier/rails'")
+ file.puts("require 'airbrake'")
+ file.puts("require 'airbrake/rails'")
end
unless rails_finds_generators_in_gems?
@@ -72,22 +72,22 @@
@terminal.run(command)
end
-Then /^I should receive a Hoptoad notification$/ do
- Then %{I should see "[Hoptoad] Success: Net::HTTPOK"}
+Then /^I should receive a Airbrake notification$/ do
+ Then %{I should see "[Airbrake] Success: Net::HTTPOK"}
end
-Then /^I should receive two Hoptoad notifications$/ do
- @terminal.output.scan(/\[Hoptoad\] Success: Net::HTTPOK/).size.should == 2
+Then /^I should receive two Airbrake notifications$/ do
+ @terminal.output.scan(/\[Airbrake\] Success: Net::HTTPOK/).size.should == 2
end
-When /^I configure the Hoptoad shim$/ do
+When /^I configure the Airbrake shim$/ do
if bundler_manages_gems?
bundle_gem("sham_rack")
end
- shim_file = File.join(PROJECT_ROOT, 'features', 'support', 'hoptoad_shim.rb.template')
+ shim_file = File.join(PROJECT_ROOT, 'features', 'support', 'airbrake_shim.rb.template')
if rails_supports_initializers?
- target = File.join(rails_root, 'config', 'initializers', 'hoptoad_shim.rb')
+ target = File.join(rails_root, 'config', 'initializers', 'airbrake_shim.rb')
FileUtils.cp(shim_file, target)
else
File.open(environment_path, 'a') do |file|
@@ -110,12 +110,12 @@
if rails_manages_gems?
requires = ''
else
- requires = "require 'hoptoad_notifier'"
+ requires = "require 'airbrake'"
end
initializer_code = <<-EOF
#{requires}
- HoptoadNotifier.configure do |config|
+ Airbrake.configure do |config|
#{configuration_lines}
end
EOF
@@ -132,11 +132,11 @@
end
def rails_initializer_file
- File.join(rails_root, 'config', 'initializers', 'hoptoad.rb')
+ File.join(rails_root, 'config', 'initializers', 'airbrake.rb')
end
-def rails_non_initializer_hoptoad_config_file
- File.join(rails_root, 'config', 'hoptoad.rb')
+def rails_non_initializer_airbrake_config_file
+ File.join(rails_root, 'config', 'airbrake.rb')
end
Then /^I should see "([^\"]*)"$/ do |expected_text|
@@ -215,7 +215,7 @@ def rails_non_initializer_hoptoad_config_file
end
end
-Then /^I should receive the following Hoptoad notification:$/ do |table|
+Then /^I should receive the following Airbrake notification:$/ do |table|
exceptions = @terminal.output.scan(%r{Recieved the following exception:\n([^\n]*)\n}m)
exceptions.should_not be_empty
@@ -280,11 +280,11 @@ def rails_non_initializer_hoptoad_config_file
end
end
-Then /^my Hoptoad configuration should contain the following line:$/ do |line|
+Then /^my Airbrake configuration should contain the following line:$/ do |line|
configuration_file = if rails_supports_initializers?
rails_initializer_file
else
- rails_non_initializer_hoptoad_config_file
+ rails_non_initializer_airbrake_config_file
# environment_path
end
@@ -308,14 +308,14 @@ def rails_non_initializer_hoptoad_config_file
heroku_script = File.join(heroku_script_bin, "heroku")
single_app_script = <<-SINGLE
#!/bin/bash
- if [[ $1 == 'console' && $2 == 'puts ENV[%{HOPTOAD_API_KEY}]' ]]; then
+ if [[ $1 == 'console' && $2 == 'puts ENV[%{AIRBRAKE_API_KEY}]' ]]; then
echo #{api_key}
fi
SINGLE
multi_app_script = <<-MULTI
#!/bin/bash
- if [[ $1 == 'console' && $2 == '--app' && $4 == 'puts ENV[%{HOPTOAD_API_KEY}]' ]]; then
+ if [[ $1 == 'console' && $2 == '--app' && $4 == 'puts ENV[%{AIRBRAKE_API_KEY}]' ]]; then
echo #{api_key}
fi
MULTI
@@ -363,7 +363,7 @@ def rails_non_initializer_hoptoad_config_file
Then /^I should see the notifier JavaScript for the following:$/ do |table|
hash = table.hashes.first
- host = hash['host'] || 'hoptoadapp.com'
+ host = hash['host'] || 'airbrakeapp.com'
secure = hash['secure'] || false
api_key = hash['api_key']
environment = hash['environment'] || 'production'
@@ -374,9 +374,9 @@ def rails_non_initializer_hoptoad_config_file
response = Nokogiri::HTML.parse(document_body)
response.css("script[type='text/javascript']:last-child").each do |element|
content = element.content
- content.should include("Hoptoad.setKey('#{api_key}');")
- content.should include("Hoptoad.setHost('#{host}');")
- content.should include("Hoptoad.setEnvironment('#{environment}');")
+ content.should include("Airbrake.setKey('#{api_key}');")
+ content.should include("Airbrake.setHost('#{host}');")
+ content.should include("Airbrake.setEnvironment('#{environment}');")
end
end
@@ -390,7 +390,7 @@ def rails_non_initializer_hoptoad_config_file
content = element.content
hash.each do |key, value|
- content.should =~ %r{Hoptoad\.setErrorDefaults.*#{key}: "#{value}}m
+ content.should =~ %r{Airbrake\.setErrorDefaults.*#{key}: "#{value}}m
end
end
end
10 features/step_definitions/rake_steps.rb
View
@@ -3,15 +3,15 @@
@rake_result = `cd features/support/rake && GEM_HOME=#{BUILT_GEM_ROOT} #{@rake_command} 2>&1`
end
-Then /Hoptoad should (|not) ?catch the exception/ do |condition|
+Then /Airbrake should (|not) ?catch the exception/ do |condition|
if condition=='not'
- @rake_result.should_not =~ /^hoptoad/
+ @rake_result.should_not =~ /^airbrake/
else
- @rake_result.should =~ /^hoptoad/
+ @rake_result.should =~ /^airbrake/
end
end
-Then /Hoptoad should send the rake command line as the component name/ do
- component = @rake_result.match(/^hoptoad (.*)$/)[1]
+Then /Airbrake should send the rake command line as the component name/ do
+ component = @rake_result.match(/^airbrake (.*)$/)[1]
component.should == @rake_command
end
15 features/support/airbrake_shim.rb.template
View
@@ -0,0 +1,15 @@
+require 'sham_rack'
+
+ShamRack.at("airbrakeapp.com") do |env|
+ xml = env['rack.input'].read
+ puts "Recieved the following exception:\n#{xml}"
+ response = <<-end_xml
+<?xml version="1.0" encoding="UTF-8"?>
+<notice>
+ <error-id type="integer">3799307</error-id>
+ <url>http://sample.airbrakeapp.com/errors/3799307/notices/643732254</url>
+ <id type="integer">643732254</id>
+</notice>
+ end_xml
+ ["200 OK", { "Content-type" => "text/xml" }, response]
+end
26 features/support/rake/Rakefile
View
@@ -2,44 +2,44 @@
#
require 'rake'
require 'rubygems'
-require 'hoptoad_notifier'
-require 'hoptoad_notifier/rake_handler'
+require 'airbrake'
+require 'airbrake/rake_handler'
-HoptoadNotifier.configure do |c|
+Airbrake.configure do |c|
end
# Should catch exception
-task :hoptoad do
- HoptoadNotifier.configuration.rescue_rake_exceptions = true
+task :airbrake do
+ Airbrake.configuration.rescue_rake_exceptions = true
stub_tty_output(true)
raise_exception
end
# Should not catch exception
-task :hoptoad_disabled do
- HoptoadNotifier.configuration.rescue_rake_exceptions = false
+task :airbrake_disabled do
+ Airbrake.configuration.rescue_rake_exceptions = false
stub_tty_output(true)
raise_exception
end
# Should not catch exception as tty_output is true
-task :hoptoad_autodetect_from_terminal do
- HoptoadNotifier.configuration.rescue_rake_exceptions = nil
+task :airbrake_autodetect_from_terminal do
+ Airbrake.configuration.rescue_rake_exceptions = nil
stub_tty_output(true)
raise_exception
end
# Should catch exception as tty_output is false
-task :hoptoad_autodetect_not_from_terminal do
- HoptoadNotifier.configuration.rescue_rake_exceptions = nil
+task :airbrake_autodetect_not_from_terminal do
+ Airbrake.configuration.rescue_rake_exceptions = nil
stub_tty_output(false)
raise_exception
end
-module HoptoadNotifier
+module Airbrake
def self.notify(*args)
# TODO if you need to check more params, you'll have to use json.dump or something
- $stderr.puts "hoptoad #{args[1][:component]}"
+ $stderr.puts "airbrake #{args[1][:component]}"
end
end
32 features/user_informer.feature
View
@@ -1,41 +1,41 @@
-Feature: Inform the user of the hoptoad notice that was just created
+Feature: Inform the user of the airbrake notice that was just created
Background:
- Given I have built and installed the "hoptoad_notifier" gem
+ Given I have built and installed the "airbrake" gem
Scenario: Rescue an exception in a controller
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
- And I run the hoptoad generator with "-k myapikey"
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
+ And I run the airbrake generator with "-k myapikey"
And I define a response for "TestController#index":
"""
raise RuntimeError, "some message"
"""
And the response page for a "500" error is
"""
- <!-- HOPTOAD ERROR -->
+ <!-- AIRBRAKE ERROR -->
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
- Then I should see "Hoptoad Error 3799307"
+ Then I should see "Airbrake Error 3799307"
Scenario: Rescue an exception in a controller with a custom error string
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
And I configure the notifier to use the following configuration lines:
"""
config.user_information = 'Error #{{ error_id }}'
"""
- And I run the hoptoad generator with "-k myapikey"
+ And I run the airbrake generator with "-k myapikey"
And I define a response for "TestController#index":
"""
raise RuntimeError, "some message"
"""
And the response page for a "500" error is
"""
- <!-- HOPTOAD ERROR -->
+ <!-- AIRBRAKE ERROR -->
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
@@ -43,21 +43,21 @@ Feature: Inform the user of the hoptoad notice that was just created
Scenario: Don't inform them user
When I generate a new Rails application
- And I configure the Hoptoad shim
- And I configure my application to require the "hoptoad_notifier" gem
+ And I configure the Airbrake shim
+ And I configure my application to require the "airbrake" gem
And I configure the notifier to use the following configuration lines:
"""
config.user_information = false
"""
- And I run the hoptoad generator with "-k myapikey"
+ And I run the airbrake generator with "-k myapikey"
And I define a response for "TestController#index":
"""
raise RuntimeError, "some message"
"""
And the response page for a "500" error is
"""
- <!-- HOPTOAD ERROR -->
+ <!-- AIRBRAKE ERROR -->
"""
And I route "/test/index" to "test#index"
And I perform a request to "http://example.com:123/test/index?param=value"
- Then I should not see "Hoptoad Error 3799307"
+ Then I should not see "Airbrake Error 3799307"
42 generators/hoptoad/hoptoad_generator.rb → generators/airbrake/airbrake_generator.rb
View
@@ -1,40 +1,40 @@
require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
require File.expand_path(File.dirname(__FILE__) + "/lib/rake_commands.rb")
-class HoptoadGenerator < Rails::Generator::Base
+class AirbrakeGenerator < Rails::Generator::Base
def add_options!(opt)
- opt.on('-k', '--api-key=key', String, "Your Hoptoad API key") { |v| options[:api_key] = v}
- opt.on('-h', '--heroku', "Use the Heroku addon to provide your Hoptoad API key") { |v| options[:heroku] = v}
+ opt.on('-k', '--api-key=key', String, "Your Airbrake API key") { |v| options[:api_key] = v}
+ opt.on('-h', '--heroku', "Use the Heroku addon to provide your Airbrake API key") { |v| options[:heroku] = v}
opt.on('-a', '--app=myapp', String, "Your Heroku app name (only required if deploying to >1 Heroku app)") { |v| options[:app] = v}
end
def manifest
if !api_key_configured? && !options[:api_key] && !options[:heroku]
- puts "Must pass --api-key or --heroku or create config/initializers/hoptoad.rb"
+ puts "Must pass --api-key or --heroku or create config/initializers/airbrake.rb"
exit
end
if plugin_is_present?
- puts "You must first remove the hoptoad_notifier plugin. Please run: script/plugin remove hoptoad_notifier"
+ puts "You must first remove the airbrake plugin. Please run: script/plugin remove airbrake"
exit
end
record do |m|
m.directory 'lib/tasks'
- m.file 'hoptoad_notifier_tasks.rake', 'lib/tasks/hoptoad_notifier_tasks.rake'
+ m.file 'airbrake_tasks.rake', 'lib/tasks/airbrake_tasks.rake'
if ['config/deploy.rb', 'Capfile'].all? { |file| File.exists?(file) }
m.append_to 'config/deploy.rb', capistrano_hook
end
if api_key_expression
if use_initializer?
- m.template 'initializer.rb', 'config/initializers/hoptoad.rb',
+ m.template 'initializer.rb', 'config/initializers/airbrake.rb',
:assigns => {:api_key => api_key_expression}
else
- m.template 'initializer.rb', 'config/hoptoad.rb',
+ m.template 'initializer.rb', 'config/airbrake.rb',
:assigns => {:api_key => api_key_expression}
- m.append_to 'config/environment.rb', "require 'config/hoptoad'"
+ m.append_to 'config/environment.rb', "require 'config/airbrake'"
end
end
determine_api_key if heroku?
- m.rake "hoptoad:test --trace", :generate_only => true
+ m.rake "airbrake:test --trace", :generate_only => true
end
end
@@ -42,33 +42,33 @@ def api_key_expression
s = if options[:api_key]
"'#{options[:api_key]}'"
elsif options[:heroku]
- "ENV['HOPTOAD_API_KEY']"
+ "ENV['AIRBRAKE_API_KEY']"
end
end
def determine_api_key
puts "Attempting to determine your API Key from Heroku..."
- ENV['HOPTOAD_API_KEY'] = heroku_api_key
- if ENV['HOPTOAD_API_KEY'].blank?
+ ENV['AIRBRAKE_API_KEY'] = heroku_api_key
+ if ENV['AIRBRAKE_API_KEY'].blank?
puts "... Failed."
- puts "WARNING: We were unable to detect the Hoptoad API Key from your Heroku environment."
+ puts "WARNING: We were unable to detect the Airbrake API Key from your Heroku environment."
puts "Your Heroku application environment may not be configured correctly."
exit 1
else
puts "... Done."
- puts "Heroku's Hoptoad API Key is '#{ENV['HOPTOAD_API_KEY']}'"
+ puts "Heroku's Airbrake API Key is '#{ENV['AIRBRAKE_API_KEY']}'"
end
end
def heroku_api_key
app = options[:app] ? " --app #{options[:app]}" : ''
- `heroku console#{app} 'puts ENV[%{HOPTOAD_API_KEY}]'`.split("\n").first
+ `heroku console#{app} 'puts ENV[%{AIRBRAKE_API_KEY}]'`.split("\n").first
end
def heroku?
options[:heroku] ||
- system("grep HOPTOAD_API_KEY config/initializers/hoptoad.rb") ||
- system("grep HOPTOAD_API_KEY config/environment.rb")
+ system("grep AIRBRAKE_API_KEY config/initializers/airbrake.rb") ||
+ system("grep AIRBRAKE_API_KEY config/environment.rb")
end
def use_initializer?
@@ -76,8 +76,8 @@ def use_initializer?
end
def api_key_configured?
- File.exists?('config/initializers/hoptoad.rb') ||
- system("grep HoptoadNotifier config/environment.rb")
+ File.exists?('config/initializers/airbrake.rb') ||
+ system("grep Airbrake config/environment.rb")
end
def capistrano_hook
@@ -85,6 +85,6 @@ def capistrano_hook
end
def plugin_is_present?
- File.exists?('vendor/plugins/hoptoad_notifier')
+ File.exists?('vendor/plugins/airbrake')
end
end
0  generators/hoptoad/lib/insert_commands.rb → generators/airbrake/lib/insert_commands.rb
View
File renamed without changes
0  generators/hoptoad/lib/rake_commands.rb → generators/airbrake/lib/rake_commands.rb
View
File renamed without changes
14 ...ors/hoptoad/templates/hoptoad_notifier_tasks.rake → generators/airbrake/templates/airbrake_tasks.rake
View
@@ -1,21 +1,21 @@
# Don't load anything when running the gems:* tasks.
-# Otherwise, hoptoad_notifier will be considered a framework gem.
+# Otherwise, airbrake will be considered a framework gem.
# https://thoughtbot.lighthouseapp.com/projects/14221/tickets/629
unless ARGV.any? {|a| a =~ /^gems/}
- Dir[File.join(RAILS_ROOT, 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier|
+ Dir[File.join(RAILS_ROOT, 'vendor', 'gems', 'airbrake-*')].each do |vendored_notifier|
$: << File.join(vendored_notifier, 'lib')
end
begin
- require 'hoptoad_notifier/tasks'
+ require 'airbrake/tasks'
rescue LoadError => exception
- namespace :hoptoad do
+ namespace :airbrake do
%w(deploy test log_stdout).each do |task_name|
- desc "Missing dependency for hoptoad:#{task_name}"
+ desc "Missing dependency for airbrake:#{task_name}"
task task_name do
- $stderr.puts "Failed to run hoptoad:#{task_name} because of missing dependency."
- $stderr.puts "You probably need to run `rake gems:install` to install the hoptoad_notifier gem"
+ $stderr.puts "Failed to run airbrake:#{task_name} because of missing dependency."
+ $stderr.puts "You probably need to run `rake gems:install` to install the airbrake gem"
abort exception.inspect
end
end
6 generators/airbrake/templates/capistrano_hook.rb
View
@@ -0,0 +1,6 @@
+
+Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'airbrake-*')].each do |vendored_notifier|
+ $: << File.join(vendored_notifier, 'lib')
+end
+
+require 'airbrake/capistrano'
4 generators/hoptoad/templates/initializer.rb → generators/airbrake/templates/initializer.rb
View
@@ -1,6 +1,6 @@
<% if Rails::VERSION::MAJOR < 3 && Rails::VERSION::MINOR < 2 -%>
-require 'hoptoad_notifier/rails'
+require 'airbrake/rails'
<% end -%>
-HoptoadNotifier.configure do |config|
+Airbrake.configure do |config|
config.api_key = <%= api_key_expression %>
end
6 generators/hoptoad/templates/capistrano_hook.rb
View
@@ -1,6 +0,0 @@
-
-Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier|
- $: << File.join(vendored_notifier, 'lib')
-end
-
-require 'hoptoad_notifier/capistrano'
52 lib/hoptoad_notifier.rb → lib/airbrake.rb
View
@@ -8,21 +8,20 @@
require 'activesupport'
require 'activesupport/core_ext'
end
-require 'hoptoad_notifier/version'
-require 'hoptoad_notifier/configuration'
-require 'hoptoad_notifier/notice'
-require 'hoptoad_notifier/sender'
-require 'hoptoad_notifier/backtrace'
-require 'hoptoad_notifier/rack'
-require 'hoptoad_notifier/user_informer'
-
-require 'hoptoad_notifier/railtie' if defined?(Rails::Railtie)
-
-# Gem for applications to automatically post errors to the Hoptoad of their choice.
-module HoptoadNotifier
-
+require 'airbrake/version'
+require 'airbrake/configuration'
+require 'airbrake/notice'
+require 'airbrake/sender'
+require 'airbrake/backtrace'
+require 'airbrake/rack'
+require 'airbrake/user_informer'
+
+require 'airbrake/railtie' if defined?(Rails::Railtie)
+
+# Gem for applications to automatically post errors to the Airbrake of their choice.
+module Airbrake
API_VERSION = "2.0"
- LOG_PREFIX = "** [Hoptoad] "
+ LOG_PREFIX = "** [Airbrake] "
HEADERS = {
'Content-type' => 'text/xml',
@@ -30,12 +29,12 @@ module HoptoadNotifier
}
class << self
- # The sender object is responsible for delivering formatted data to the Hoptoad server.
- # Must respond to #send_to_hoptoad. See HoptoadNotifier::Sender.
+ # The sender object is responsible for delivering formatted data to the Airbrake server.
+ # Must respond to #send_to_airbrake. See Airbrake::Sender.
attr_accessor :sender
- # A Hoptoad configuration object. Must act like a hash and return sensible
- # values for all Hoptoad configuration options. See HoptoadNotifier::Configuration.
+ # A Airbrake configuration object. Must act like a hash and return sensible
+ # values for all Airbrake configuration options. See Airbrake::Configuration.
attr_accessor :configuration
# Tell the log that the Notifier is good to go
@@ -48,9 +47,9 @@ def report_environment_info
write_verbose_log("Environment Info: #{environment_info}")
end
- # Prints out the response body from Hoptoad for debugging help
+ # Prints out the response body from Airbrake for debugging help
def report_response_body(response)
- write_verbose_log("Response from Hoptoad: \n#{response}")
+ write_verbose_log("Response from Airbrake: \n#{response}")
end
# Returns the Ruby version, Rails version, and current Rails environment
@@ -73,7 +72,7 @@ def logger
# Call this method to modify defaults in your initializers.
#
# @example
- # HoptoadNotifier.configure do |config|
+ # Airbrake.configure do |config|
# config.api_key = '1234567890abcdef'
# config.secure = false
# end
@@ -86,10 +85,10 @@ def configure(silent = false)
# Sends an exception manually using this method, even when you are not in a controller.
#
- # @param [Exception] exception The exception you want to notify Hoptoad about.
- # @param [Hash] opts Data that will be sent to Hoptoad.
+ # @param [Exception] exception The exception you want to notify Airbrake about.
+ # @param [Hash] opts Data that will be sent to Airbrake.
#
- # @option opts [String] :api_key The API key for this project. The API key is a unique identifier that Hoptoad uses for identification.
+ # @option opts [String] :api_key The API key for this project. The API key is a unique identifier that Airbrake uses for identification.
# @option opts [String] :error_message The error returned by the exception (or the message you want to log).
# @option opts [String] :backtrace A backtrace, usually obtained with +caller+.
# @option opts [String] :rack_env The Rack environment.
@@ -100,7 +99,7 @@ def notify(exception, opts = {})
end
# Sends the notice unless it is one of the default ignored exceptions
- # @see HoptoadNotifier.notify
+ # @see Airbrake.notify
def notify_or_ignore(exception, opts = {})
notice = build_notice_for(exception, opts)
send_notice(notice) unless notice.ignore?
@@ -127,7 +126,7 @@ def build_lookup_hash_for(exception, options = {})
def send_notice(notice)
if configuration.public?
- sender.send_to_hoptoad(notice.to_xml)
+ sender.send_to_airbrake(notice.to_xml)
end
end
@@ -149,4 +148,3 @@ def unwrap_exception(exception)
end
end
end
-
2  lib/hoptoad_notifier/backtrace.rb → lib/airbrake/backtrace.rb
View
@@ -1,4 +1,4 @@
-module HoptoadNotifier
+module Airbrake
# Front end to parsing the backtrace for each notice
class Backtrace
21 lib/airbrake/capistrano.rb
View
@@ -0,0 +1,21 @@
+# Defines deploy:notify_airbrake which will send information about the deploy to Airbrake.
+
+Capistrano::Configuration.instance(:must_exist).load do
+ after "deploy", "deploy:notify_airbrake"
+ after "deploy:migrations", "deploy:notify_airbrake"
+
+ namespace :deploy do
+ desc "Notify Airbrake of the deployment"
+ task :notify_airbrake, :except => { :no_release => true } do
+ rails_env = fetch(:airbrake_env, fetch(:rails_env, "production"))
+ local_user = ENV['USER'] || ENV['USERNAME']
+ executable = RUBY_PLATFORM.downcase.include?('mswin') ? fetch(:rake, 'rake.bat') : fetch(:rake, 'rake')
+ notify_command = "#{executable} airbrake:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
+ notify_command << " DRY_RUN=true" if dry_run
+ notify_command << " API_KEY=#{ENV['API_KEY']}" if ENV['API_KEY']
+ puts "Notifying Airbrake of Deploy (#{notify_command})"
+ `#{notify_command}`
+ puts "Airbrake Notification Complete."
+ end
+ end
+end
36 lib/hoptoad_notifier/configuration.rb → lib/airbrake/configuration.rb
View
@@ -1,4 +1,4 @@
-module HoptoadNotifier
+module Airbrake
# Used to set up and modify settings for the notifier.
class Configuration
@@ -13,10 +13,10 @@ class Configuration
# The API key for your project, found on the project edit form.
attr_accessor :api_key
- # The host to connect to (defaults to hoptoadapp.com).
+ # The host to connect to (defaults to airbrakeapp.com).
attr_accessor :host
- # The port on which your Hoptoad server runs (defaults to 443 for secure
+ # The port on which your Airbrake server runs (defaults to 443 for secure
# connections, 80 for insecure connections).
attr_accessor :port
@@ -41,7 +41,7 @@ class Configuration
# The password to use when logging into your proxy server (if using a proxy)
attr_accessor :proxy_pass
- # A list of parameters that should be filtered out of what is sent to Hoptoad.
+ # A list of parameters that should be filtered out of what is sent to Airbrake.
# By default, all "password" attributes will have their contents replaced.
attr_reader :params_filters
@@ -69,7 +69,7 @@ class Configuration
# The path to the project in which the error occurred, such as the RAILS_ROOT
attr_accessor :project_root
- # The name of the notifier library being used to send notifications (such as "Hoptoad Notifier")
+ # The name of the notifier library being used to send notifications (such as "Airbrake Notifier")
attr_accessor :notifier_name
# The version of the notifier library being used to send notifications (such as "1.0.2")
@@ -78,16 +78,16 @@ class Configuration
# The url of the notifier library being used to send notifications
attr_accessor :notifier_url
- # The logger used by HoptoadNotifier
+ # The logger used by Airbrake
attr_accessor :logger
# The text that the placeholder is replaced with. {{error_id}} is the actual error number.
attr_accessor :user_information
- # The framework HoptoadNotifier is configured to use
+ # The framework Airbrake is configured to use
attr_accessor :framework
- # Should HoptoadNotifier catch exceptions from Rake tasks?
+ # Should Airbrake catch exceptions from Rake tasks?
# (boolean or nil; set to nil to catch exceptions when rake isn't running from a terminal; default is nil)
attr_accessor :rescue_rake_exceptions
@@ -95,8 +95,8 @@ class Configuration
DEFAULT_BACKTRACE_FILTERS = [
lambda { |line|
- if defined?(HoptoadNotifier.configuration.project_root) && HoptoadNotifier.configuration.project_root.to_s != ''
- line.sub(/#{HoptoadNotifier.configuration.project_root}/, "[PROJECT_ROOT]")
+ if defined?(Airbrake.configuration.project_root) && Airbrake.configuration.project_root.to_s != ''
+ line.sub(/#{Airbrake.configuration.project_root}/, "[PROJECT_ROOT]")
else
line
end
@@ -109,7 +109,7 @@ class Configuration
end
end
},
- lambda { |line| line if line !~ %r{lib/hoptoad_notifier} }
+ lambda { |line| line if line !~ %r{lib/airbrake} }
].freeze
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
@@ -123,7 +123,7 @@ class Configuration
def initialize
@secure = false
- @host = 'hoptoadapp.com'
+ @host = 'airbrakeapp.com'
@http_open_timeout = 2
@http_read_timeout = 5
@params_filters = DEFAULT_PARAMS_FILTERS.dup
@@ -133,11 +133,11 @@ def initialize
@ignore_user_agent = []
@development_environments = %w(development test cucumber)
@development_lookup = true
- @notifier_name = 'Hoptoad Notifier'
+ @notifier_name = 'Airbrake Notifier'
@notifier_version = VERSION
- @notifier_url = 'http://hoptoadapp.com'
+ @notifier_url = 'http://airbrakeapp.com'
@framework = 'Standalone'
- @user_information = 'Hoptoad Error {{error_id}}'
+ @user_information = 'Airbrake Error {{error_id}}'
@rescue_rake_exceptions = nil
end
@@ -164,8 +164,8 @@ def filter_backtrace(&block)
# end
#
# @param [Proc] block The new ignore filter
- # @yieldparam [Hash] data The exception data given to +HoptoadNotifier.notify+
- # @yieldreturn [Boolean] If the block returns true the exception will be ignored, otherwise it will be processed by hoptoad.
+ # @yieldparam [Hash] data The exception data given to +Airbrake.notify+
+ # @yieldreturn [Boolean] If the block returns true the exception will be ignored, otherwise it will be processed by airbrake.
def ignore_by_filter(&block)
self.ignore_by_filters << block
end
@@ -224,7 +224,7 @@ def protocol
end
def js_notifier=(*args)
- warn '[HOPTOAD] config.js_notifier has been deprecated and has no effect. You should use <%= hoptoad_javascript_notifier %> directly at the top of your layouts. Be sure to place it before all other javascript.'
+ warn '[AIRBRAKE] config.js_notifier has been deprecated and has no effect. You should use <%= airbrake_javascript_notifier %> directly at the top of your layouts. Be sure to place it before all other javascript.'
end
def environment_filters
6 lib/hoptoad_notifier/notice.rb → lib/airbrake/notice.rb
View
@@ -1,7 +1,7 @@
require 'builder'
require 'socket'
-module HoptoadNotifier
+module Airbrake
class Notice
# The exception that caused this notice, if any
@@ -57,7 +57,7 @@ class Notice
# See Configuration#ignore_by_filters
attr_reader :ignore_by_filters
- # The name of the notifier library sending this notice, such as "Hoptoad Notifier"
+ # The name of the notifier library sending this notice, such as "Airbrake Notifier"
attr_reader :notifier_name
# The version number of the notifier library sending this notice, such as "2.1.3"
@@ -111,7 +111,7 @@ def initialize(args)
def to_xml
builder = Builder::XmlMarkup.new
builder.instruct!
- xml = builder.notice(:version => HoptoadNotifier::API_VERSION) do |notice|
+ xml = builder.notice(:version => Airbrake::API_VERSION) do |notice|
notice.tag!("api-key", api_key)
notice.notifier do |notifier|
notifier.name(notifier_name)
42 lib/airbrake/rack.rb
View
@@ -0,0 +1,42 @@
+module Airbrake
+ # Middleware for Rack applications. Any errors raised by the upstream
+ # application will be delivered to Airbrake and re-raised.
+ #
+ # Synopsis:
+ #
+ # require 'rack'
+ # require 'airbrake'
+ #
+ # Airbrake.configure do |config|
+ # config.api_key = 'my_api_key'
+ # end
+ #
+ # app = Rack::Builder.app do
+ # use Airbrake::Rack
+ # run lambda { |env| raise "Rack down" }
+ # end
+ #
+ # Use a standard Airbrake.configure call to configure your api key.
+ class Rack
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ begin
+ response = @app.call(env)
+ rescue Exception => raised
+ error_id = Airbrake.notify_or_ignore(raised, :rack_env => env)
+ env['airbrake.error_id'] = error_id
+ raise
+ end
+
+ if env['rack.exception']
+ error_id = Airbrake.notify_or_ignore(env['rack.exception'], :rack_env => env)
+ env['airbrake.error_id'] = error_id
+ end
+
+ response
+ end
+ end
+end
28 lib/hoptoad_notifier/rails.rb → lib/airbrake/rails.rb
View
@@ -1,17 +1,17 @@
-require 'hoptoad_notifier'
-require 'hoptoad_notifier/rails/controller_methods'
-require 'hoptoad_notifier/rails/action_controller_catcher'
-require 'hoptoad_notifier/rails/error_lookup'
-require 'hoptoad_notifier/rails/javascript_notifier'
+require 'airbrake'
+require 'airbrake/rails/controller_methods'
+require 'airbrake/rails/action_controller_catcher'
+require 'airbrake/rails/error_lookup'
+require 'airbrake/rails/javascript_notifier'
-module HoptoadNotifier
+module Airbrake
module Rails
def self.initialize
if defined?(ActionController::Base)
- ActionController::Base.send(:include, HoptoadNotifier::Rails::ActionControllerCatcher)
- ActionController::Base.send(:include, HoptoadNotifier::Rails::ErrorLookup)
- ActionController::Base.send(:include, HoptoadNotifier::Rails::ControllerMethods)
- ActionController::Base.send(:include, HoptoadNotifier::Rails::JavascriptNotifier)
+ ActionController::Base.send(:include, Airbrake::Rails::ActionControllerCatcher)
+ ActionController::Base.send(:include, Airbrake::Rails::ErrorLookup)
+ ActionController::Base.send(:include, Airbrake::Rails::ControllerMethods)
+ ActionController::Base.send(:include, Airbrake::Rails::JavascriptNotifier)
end
rails_logger = if defined?(::Rails.logger)
@@ -22,12 +22,12 @@ def self.initialize
if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
::Rails.configuration.middleware.insert_after 'ActionController::Failsafe',
- HoptoadNotifier::Rack
+ Airbrake::Rack
::Rails.configuration.middleware.insert_after 'Rack::Lock',
- HoptoadNotifier::UserInformer
+ Airbrake::UserInformer
end
- HoptoadNotifier.configure(true) do |config|
+ Airbrake.configure(true) do |config|
config.logger = rails_logger
config.environment_name = RAILS_ENV if defined?(RAILS_ENV)
config.project_root = RAILS_ROOT if defined?(RAILS_ROOT)
@@ -37,5 +37,5 @@ def self.initialize
end
end
-HoptoadNotifier::Rails.initialize
+Airbrake::Rails.initialize
20 ...ptoad_notifier/rails/action_controller_catcher.rb → lib/airbrake/rails/action_controller_catcher.rb
View
@@ -1,29 +1,29 @@
-module HoptoadNotifier
+module Airbrake
module Rails
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_hoptoad, :rescue_action_in_public)
- base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_hoptoad)
+ base.send(:alias_method, :rescue_action_in_public_without_airbrake, :rescue_action_in_public)
+ base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_airbrake)
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_hoptoad(exception)
- unless hoptoad_ignore_user_agent?
- error_id = HoptoadNotifier.notify_or_ignore(exception, hoptoad_request_data)
- request.env['hoptoad.error_id'] = error_id
+ def rescue_action_in_public_with_airbrake(exception)
+ unless airbrake_ignore_user_agent?
+ error_id = Airbrake.notify_or_ignore(exception, airbrake_request_data)
+ request.env['airbrake.error_id'] = error_id
end
- rescue_action_in_public_without_hoptoad(exception)
+ rescue_action_in_public_without_airbrake(exception)
end
- def hoptoad_ignore_user_agent? #:nodoc:
+ def airbrake_ignore_user_agent? #:nodoc:
# Rails 1.2.6 doesn't have request.user_agent, so check for it here
user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"]
- HoptoadNotifier.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
+ Airbrake.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
end
end
end
32 lib/hoptoad_notifier/rails/controller_methods.rb → lib/airbrake/rails/controller_methods.rb
View
@@ -1,17 +1,17 @@
-module HoptoadNotifier
+module Airbrake
module Rails
module ControllerMethods
private
# This method should be used for sending manual notifications while you are still
- # inside the controller. Otherwise it works like HoptoadNotifier.notify.
- def notify_hoptoad(hash_or_exception)
- unless hoptoad_local_request?
- HoptoadNotifier.notify(hash_or_exception, hoptoad_request_data)
+ # inside the controller. Otherwise it works like Airbrake.notify.
+ def notify_airbrake(hash_or_exception)
+ unless airbrake_local_request?
+ Airbrake.notify(hash_or_exception, airbrake_request_data)
end
end
- def hoptoad_local_request?
+ def airbrake_local_request?
if defined?(::Rails.application.config)
::Rails.application.config.consider_all_requests_local || request.local?
else
@@ -19,22 +19,22 @@ def hoptoad_local_request?
end
end
- def hoptoad_ignore_user_agent? #:nodoc:
+ def airbrake_ignore_user_agent? #:nodoc:
# Rails 1.2.6 doesn't have request.user_agent, so check for it here
user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"]
- HoptoadNotifier.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
+ Airbrake.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
end
- def hoptoad_request_data
- { :parameters => hoptoad_filter_if_filtering(params.to_hash),
- :session_data => hoptoad_filter_if_filtering(hoptoad_session_data),
+ def airbrake_request_data
+ { :parameters => airbrake_filter_if_filtering(params.to_hash),
+ :session_data => airbrake_filter_if_filtering(airbrake_session_data),
:controller => params[:controller],
:action => params[:action],
- :url => hoptoad_request_url,
- :cgi_data => hoptoad_filter_if_filtering(request.env) }
+ :url => airbrake_request_url,
+ :cgi_data => airbrake_filter_if_filtering(request.env) }
end
- def hoptoad_filter_if_filtering(hash)
+ def airbrake_filter_if_filtering(hash)
return hash if ! hash.is_a?(Hash)
if respond_to?(:filter_parameters)
@@ -44,7 +44,7 @@ def hoptoad_filter_if_filtering(hash)
end
end
- def hoptoad_session_data
+ def airbrake_session_data
if session.respond_to?(:to_hash)
session.to_hash
else
@@ -52,7 +52,7 @@ def hoptoad_session_data
end
end
- def hoptoad_request_url
+ def airbrake_request_url
url = "#{request.protocol}#{request.host}"
unless [80, 443].include?(request.port)
18 lib/hoptoad_notifier/rails/error_lookup.rb → lib/airbrake/rails/error_lookup.rb
View
@@ -1,27 +1,27 @@
-module HoptoadNotifier
+module Airbrake
module Rails
module ErrorLookup
# Sets up an alias chain to catch exceptions when Rails does
def self.included(base) #:nodoc:
- base.send(:alias_method, :rescue_action_locally_without_hoptoad, :rescue_action_locally)
- base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_hoptoad)
+ base.send(:alias_method, :rescue_action_locally_without_airbrake, :rescue_action_locally)
+ base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_airbrake)
end
private
- def rescue_action_locally_with_hoptoad(exception)
- result = rescue_action_locally_without_hoptoad(exception)
+ def rescue_action_locally_with_airbrake(exception)
+ result = rescue_action_locally_without_airbrake(exception)
- if HoptoadNotifier.configuration.development_lookup
+ if Airbrake.configuration.development_lookup
path = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'rescue.erb')
- notice = HoptoadNotifier.build_lookup_hash_for(exception, hoptoad_request_data)
+ notice = Airbrake.build_lookup_hash_for(exception, airbrake_request_data)
result << @template.render(
:file => path,
:use_full_path => false,
- :locals => { :host => HoptoadNotifier.configuration.host,
- :api_key => HoptoadNotifier.configuration.api_key,
+ :locals => { :host => Airbrake.configuration.host,
+ :api_key => Airbrake.configuration.api_key,
:notice => notice })
end
16 lib/hoptoad_notifier/rails/javascript_notifier.rb → lib/airbrake/rails/javascript_notifier.rb
View
@@ -1,18 +1,18 @@
-module HoptoadNotifier
+module Airbrake
module Rails
module JavascriptNotifier
def self.included(base) #:nodoc:
- base.send :helper_method, :hoptoad_javascript_notifier
+ base.send :helper_method, :airbrake_javascript_notifier
end
private
- def hoptoad_javascript_notifier
- return unless HoptoadNotifier.configuration.public?
+ def airbrake_javascript_notifier
+ return unless Airbrake.configuration.public?
path = File.join File.dirname(__FILE__), '..', '..', 'templates', 'javascript_notifier.erb'
- host = HoptoadNotifier.configuration.host.dup
- port = HoptoadNotifier.configuration.port
+ host = Airbrake.configuration.host.dup
+ port = Airbrake.configuration.port
host << ":#{port}" unless [80, 443].include?(port)
options = {
@@ -21,8 +21,8 @@ def hoptoad_javascript_notifier
:use_full_path => false,
:locals => {
:host => host,
- :api_key => HoptoadNotifier.configuration.api_key,
- :environment => HoptoadNotifier.configuration.environment_name,
+ :api_key => Airbrake.configuration.api_key,
+ :environment => Airbrake.configuration.environment_name,
:action_name => action_name,
:controller_name => controller_name,
:url => request.url
28 lib/hoptoad_notifier/rails3_tasks.rb → lib/airbrake/rails3_tasks.rb
View
@@ -1,28 +1,28 @@
-require 'hoptoad_notifier'
+require 'airbrake'
require File.join(File.dirname(__FILE__), 'shared_tasks')
-namespace :hoptoad do
- desc "Verify your gem installation by sending a test exception to the hoptoad service"
+namespace :airbrake do
+ desc "Verify your gem installation by sending a test exception to the airbrake service"
task :test => [:environment] do
Rails.logger = Logger.new(STDOUT)
Rails.logger.level = Logger::DEBUG
- HoptoadNotifier.configure(true) do |config|
+ Airbrake.configure(true) do |config|
config.logger = Rails.logger
end
require './app/controllers/application_controller'
- class HoptoadTestingException < RuntimeError; end
+ class AirbrakeTestingException < RuntimeError; end
- unless HoptoadNotifier.configuration.api_key
- puts "Hoptoad needs an API key configured! Check the README to see how to add it."
+ unless Airbrake.configuration.api_key
+ puts "Airbrake needs an API key configured! Check the README to see how to add it."
exit
end
- HoptoadNotifier.configuration.development_environments = []
+ Airbrake.configuration.development_environments = []
puts "Configuration:"
- HoptoadNotifier.configuration.to_hash.each do |key, value|
+ Airbrake.configuration.to_hash.each do |key, value|
puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
end
@@ -34,10 +34,10 @@ class HoptoadTestingException < RuntimeError; end
puts 'Setting up the Controller.'
class ApplicationController
# This is to bypass any filters that may prevent access to the action.
- prepend_before_filter :test_hoptoad
- def test_hoptoad
+ prepend_before_filter :test_airbrake
+ def test_airbrake
puts "Raising '#{exception_class.name}' to simulate application failure."
- raise exception_class.new, 'Testing hoptoad via "rake hoptoad:test". If you can see this, it works.'
+ raise exception_class.new, 'Testing airbrake via "rake airbrake:test". If you can see this, it works.'
end
# def rescue_action(exception)
@@ -56,7 +56,7 @@ def verify; end
# end
def exception_class
- exception_name = ENV['EXCEPTION'] || "HoptoadTestingException"
+ exception_name = ENV['EXCEPTION'] || "AirbrakeTestingException"
Object.const_get(exception_name)
rescue
Object.const_set(exception_name, Class.new(Exception))
@@ -66,7 +66,7 @@ def logger
nil
end
end
- class HoptoadVerificationController < ApplicationController; end
+ class AirbrakeVerificationController < ApplicationController; end
Rails.application.routes_reloader.execute_if_updated
Rails.application.routes.draw do
33 lib/airbrake/railtie.rb
View
@@ -0,0 +1,33 @@
+require 'airbrake'
+require 'rails'
+
+module Airbrake
+ class Railtie < Rails::Railtie
+ rake_tasks do
+ require 'airbrake/rake_handler'
+ require "airbrake/rails3_tasks"
+ end
+
+ initializer "airbrake.use_rack_middleware" do |app|
+ app.config.middleware.use "Airbrake::Rack"
+ app.config.middleware.insert 0, "Airbrake::UserInformer"
+ end
+
+ config.after_initialize do
+ Airbrake.configure(true) do |config|
+ config.logger ||= Rails.logger
+ config.environment_name ||= Rails.env
+ config.project_root ||= Rails.root
+ config.framework = "Rails: #{::Rails::VERSION::STRING}"
+ end
+
+ if defined?(::ActionController::Base)
+ require 'airbrake/rails/javascript_notifier'
+ require 'airbrake/rails/controller_methods'
+
+ ::ActionController::Base.send(:include, Airbrake::Rails::ControllerMethods)
+ ::ActionController::Base.send(:include, Airbrake::Rails::JavascriptNotifier)
+ end
+ end
+ end
+end
20 lib/hoptoad_notifier/rake_handler.rb → lib/airbrake/rake_handler.rb
View
@@ -1,21 +1,21 @@
-# Patch Rake::Application to handle errors with Hoptoad
-module HoptoadNotifier::RakeHandler
+# Patch Rake::Application to handle errors with Airbrake
+module Airbrake::RakeHandler
def self.included(klass)
klass.class_eval do
include Rake087Methods unless defined?(Rake::VERSION) && Rake::VERSION >= '0.9.0'
- alias_method :display_error_message_without_hoptoad, :display_error_message
- alias_method :display_error_message, :display_error_message_with_hoptoad
+ alias_method :display_error_message_without_airbrake, :display_error_message
+ alias_method :display_error_message, :display_error_message_with_airbrake
end
end
- def display_error_message_with_hoptoad(ex)
- if HoptoadNotifier.configuration.rescue_rake_exceptions ||
- (HoptoadNotifier.configuration.rescue_rake_exceptions===nil && !self.tty_output?)
+ def display_error_message_with_airbrake(ex)
+ if Airbrake.configuration.rescue_rake_exceptions ||
+ (Airbrake.configuration.rescue_rake_exceptions===nil && !self.tty_output?)
- HoptoadNotifier.notify(ex, :component => reconstruct_command_line, :cgi_data => ENV)
+ Airbrake.notify(ex, :component => reconstruct_command_line, :cgi_data => ENV)
end
- display_error_message_without_hoptoad(ex)
+ display_error_message_without_airbrake(ex)
end
def reconstruct_command_line
@@ -59,7 +59,7 @@ def display_error_message(ex)
Rake.application.instance_eval do
class << self
- include HoptoadNotifier::RakeHandler
+ include Airbrake::RakeHandler
end
end
16 lib/hoptoad_notifier/sender.rb → lib/airbrake/sender.rb
View
@@ -1,5 +1,5 @@
-module HoptoadNotifier
- # Sends out the notice to Hoptoad
+module Airbrake
+ # Sends out the notice to Airbrake
class Sender
NOTICES_URI = '/notifier_api/v2/notices/'.freeze
@@ -19,10 +19,10 @@ def initialize(options = {})
end
end
- # Sends the notice data off to Hoptoad for processing.
+ # Sends the notice data off to Airbrake for processing.
#
# @param [String] data The XML notice to be sent off
- def send_to_hoptoad(data)
+ def send_to_airbrake(data)
logger.debug { "Sending request to #{url.to_s}:\n#{data}" } if logger
http =
@@ -43,7 +43,7 @@ def send_to_hoptoad(data)
response = begin
http.post(url.path, data, HEADERS)
rescue *HTTP_ERRORS => e
- log :error, "Timeout while contacting the Hoptoad server."
+ log :error, "Timeout while contacting the Airbrake server."
nil
end
@@ -71,12 +71,12 @@ def url
def log(level, message, response = nil)
logger.send level, LOG_PREFIX + message if logger
- HoptoadNotifier.report_environment_info
- HoptoadNotifier.report_response_body(response.body) if response && response.respond_to?(:body)
+ Airbrake.report_environment_info
+ Airbrake.report_response_body(response.body) if response && response.respond_to?(:body)
end
def logger
- HoptoadNotifier.logger
+ Airbrake.logger
end
end
12 lib/hoptoad_notifier/shared_tasks.rb → lib/airbrake/shared_tasks.rb
View
@@ -1,8 +1,8 @@
-namespace :hoptoad do
- desc "Notify Hoptoad of a new deploy."
+namespace :airbrake do
+ desc "Notify Airbrake of a new deploy."
task :deploy => :environment do
- require 'hoptoad_tasks'
- HoptoadTasks.deploy(:rails_env => ENV['TO'],
+ require 'airbrake_tasks'
+ AirbrakeTasks.deploy(:rails_env => ENV['TO'],
:scm_revision => ENV['REVISION'],
:scm_repository => ENV['REPO'],
:local_username => ENV['USER'],
@@ -18,10 +18,10 @@
namespace :heroku do
desc "Install Heroku deploy notifications addon"
task :add_deploy_notification => [:environment] do
- heroku_api_key = `heroku console 'puts ENV[%{HOPTOAD_API_KEY}]' | head -n 1`.strip
+ heroku_api_key = `heroku console 'puts ENV[%{AIRBRAKE_API_KEY}]' | head -n 1`.strip
heroku_rails_env = `heroku console 'puts RAILS_ENV' | head -n 1`.strip
- command = %Q(heroku addons:add deployhooks:http url="http://hoptoadapp.com/deploys.txt?deploy[rails_env]=#{heroku_rails_env}&api_key=#{heroku_api_key}")
+ command = %Q(heroku addons:add deployhooks:http url="http://airbrakeapp.com/deploys.txt?deploy[rails_env]=#{heroku_rails_env}&api_key=#{heroku_api_key}")
puts "\nRunning:\n#{command}\n"
puts `#{command}`
34 lib/hoptoad_notifier/tasks.rb → lib/airbrake/tasks.rb
View
@@ -1,25 +1,25 @@
-require 'hoptoad_notifier'
+require 'airbrake'
require File.join(File.dirname(__FILE__), 'shared_tasks')
-namespace :hoptoad do
- desc "Verify your gem installation by sending a test exception to the hoptoad service"
- task :test => ['hoptoad:log_stdout', :environment] do
+namespace :airbrake do
+ desc