toadhopper 1.3 → 2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +8 -7
 - data/lib/toadhopper.rb +7 -7
 - data/lib/toadhopper/capistrano.rb +8 -8
 - data/test/helper.rb +1 -1
 - data/test/test_deploy_tracking.rb +1 -1
 - data/test/test_posting.rb +2 -2
 - data/toadhopper.gemspec +2 -3
 - metadata +6 -6
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            A base library for [ 
     | 
| 
      
 1 
     | 
    
         
            +
            A base library for [Airbrake](http://www.airbrakeapp.com/) error reporting.
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            Toadhopper can be used to report plain old Ruby exceptions, or to build a framework-specific gem such as [toadhopper-sinatra](http://github.com/toolmantim/toadhopper-sinatra).
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
         @@ -15,17 +15,17 @@ You can install it via rubygems: 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            ## Deploy tracking
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            You can use Toadhopper to notify  
     | 
| 
      
 18 
     | 
    
         
            +
            You can use Toadhopper to notify Airbrake of deployments:
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                Toadhopper('YOURAPIKEY').deploy!
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            The method accepts options to set the environment, SCM revision, etc.
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
            There is Capistrano support for deploy tracking. Simply require `toadhopper/capistrano` in your deploy config and set the variable ` 
     | 
| 
      
 24 
     | 
    
         
            +
            There is Capistrano support for deploy tracking. Simply require `toadhopper/capistrano` in your deploy config and set the variable `airbrake_api_key`:
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                require 'toadhopper/capistrano'
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                set : 
     | 
| 
      
 28 
     | 
    
         
            +
                set :airbrake_api_key, 'YOURAPIKEY'
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
            ## Development
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
         @@ -36,9 +36,9 @@ Install Bundler 0.9.x, then: 
     | 
|
| 
       36 
36 
     | 
    
         
             
                % bundle install
         
     | 
| 
       37 
37 
     | 
    
         
             
                % bundle exec rake test
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
            If you set a ` 
     | 
| 
      
 39 
     | 
    
         
            +
            If you set a `AIRBRAKE_API_KEY` environment variable it'll test actually posting to the Airbrake API. For example:
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                % bundle exec rake test  
     | 
| 
      
 41 
     | 
    
         
            +
                % bundle exec rake test AIRBRAKE_API_KEY=abc123
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
            To generate the docs:
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
         @@ -55,4 +55,5 @@ To build the gem: 
     | 
|
| 
       55 
55 
     | 
    
         
             
            * [Corey Donohoe](http://github.com/atmos)
         
     | 
| 
       56 
56 
     | 
    
         
             
            * [Andre Arko](http://github.com/indirect)
         
     | 
| 
       57 
57 
     | 
    
         
             
            * [Loren Segal](http://github.com/lsegal)
         
     | 
| 
       58 
     | 
    
         
            -
            * [Theo Hultberg](http://github.com/iconara)
         
     | 
| 
      
 58 
     | 
    
         
            +
            * [Theo Hultberg](http://github.com/iconara)
         
     | 
| 
      
 59 
     | 
    
         
            +
            * [Ben Klang](http://github.com/bklang)
         
     | 
    
        data/lib/toadhopper.rb
    CHANGED
    
    | 
         @@ -2,19 +2,19 @@ require 'net/http' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'erb'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'ostruct'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            # Posts errors to the  
     | 
| 
      
 5 
     | 
    
         
            +
            # Posts errors to the Airbrake API
         
     | 
| 
       6 
6 
     | 
    
         
             
            class Toadhopper
         
     | 
| 
       7 
     | 
    
         
            -
              VERSION = " 
     | 
| 
      
 7 
     | 
    
         
            +
              VERSION = "2.0"
         
     | 
| 
       8 
8 
     | 
    
         
             
              FILTER_REPLACEMENT = "[FILTERED]"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
              #  
     | 
| 
      
 10 
     | 
    
         
            +
              # Airbrake API response
         
     | 
| 
       11 
11 
     | 
    
         
             
              class Response < Struct.new(:status, :body, :errors); end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              attr_reader :api_key
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              def initialize(api_key, params = {})
         
     | 
| 
       16 
16 
     | 
    
         
             
                @api_key     = api_key
         
     | 
| 
       17 
     | 
    
         
            -
                @notify_host = params.delete(:notify_host) || "http:// 
     | 
| 
      
 17 
     | 
    
         
            +
                @notify_host = params.delete(:notify_host) || "http://airbrakeapp.com"
         
     | 
| 
       18 
18 
     | 
    
         
             
                @error_url   = params.delete(:error_url)   || "#{@notify_host}/notifier_api/v2/notices"
         
     | 
| 
       19 
19 
     | 
    
         
             
                @deploy_url  = params.delete(:deploy_url)  || "#{@notify_host}/deploys.txt"
         
     | 
| 
       20 
20 
     | 
    
         
             
              end
         
     | 
| 
         @@ -24,7 +24,7 @@ class Toadhopper 
     | 
|
| 
       24 
24 
     | 
    
         
             
                @filters = filters.flatten
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
              # Posts an exception to  
     | 
| 
      
 27 
     | 
    
         
            +
              # Posts an exception to Airbrake.
         
     | 
| 
       28 
28 
     | 
    
         
             
              #
         
     | 
| 
       29 
29 
     | 
    
         
             
              # @param [Exception] error the error to post
         
     | 
| 
       30 
30 
     | 
    
         
             
              #
         
     | 
| 
         @@ -47,12 +47,12 @@ class Toadhopper 
     | 
|
| 
       47 
47 
     | 
    
         
             
              # @example
         
     | 
| 
       48 
48 
     | 
    
         
             
              #   Toadhopper('apikey').post! error,
         
     | 
| 
       49 
49 
     | 
    
         
             
              #                              {:action => 'show', :controller => 'Users'},
         
     | 
| 
       50 
     | 
    
         
            -
              #                              {'X- 
     | 
| 
      
 50 
     | 
    
         
            +
              #                              {'X-Airbrake-Client-Name' => 'My Awesome Notifier'}
         
     | 
| 
       51 
51 
     | 
    
         
             
              #
         
     | 
| 
       52 
52 
     | 
    
         
             
              # @return [Response]
         
     | 
| 
       53 
53 
     | 
    
         
             
              def post!(error, options={}, http_headers={})
         
     | 
| 
       54 
54 
     | 
    
         
             
                options[:notifier_name] ||= 'Toadhopper'
         
     | 
| 
       55 
     | 
    
         
            -
                post_document(document_for(error, options), {'X- 
     | 
| 
      
 55 
     | 
    
         
            +
                post_document(document_for(error, options), {'X-Airbrake-Client-Name' => options[:notifier_name]})
         
     | 
| 
       56 
56 
     | 
    
         
             
              end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
              # Posts a deployment notification
         
     | 
| 
         @@ -2,18 +2,18 @@ require 'toadhopper' 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            Capistrano::Configuration.instance(:must_exist).load do
         
     | 
| 
       5 
     | 
    
         
            -
              after 'deploy',            'deploy: 
     | 
| 
       6 
     | 
    
         
            -
              after 'deploy:migrations', 'deploy: 
     | 
| 
      
 5 
     | 
    
         
            +
              after 'deploy',            'deploy:notify_airbrake'
         
     | 
| 
      
 6 
     | 
    
         
            +
              after 'deploy:migrations', 'deploy:notify_airbrake'
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
              namespace :deploy do
         
     | 
| 
       9 
     | 
    
         
            -
                desc 'Notify  
     | 
| 
       10 
     | 
    
         
            -
                task : 
     | 
| 
       11 
     | 
    
         
            -
                  framework_env = fetch(:rails_env, fetch(: 
     | 
| 
       12 
     | 
    
         
            -
                  api_key = fetch(:hoptoad_api_key)
         
     | 
| 
       13 
     | 
    
         
            -
                  puts 'Notifying  
     | 
| 
      
 9 
     | 
    
         
            +
                desc 'Notify Airbrake of the deployment'
         
     | 
| 
      
 10 
     | 
    
         
            +
                task :notify_airbrake, :except => {:no_release => true} do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  framework_env = fetch(:rails_env, fetch(:airbrake_env, 'production'))
         
     | 
| 
      
 12 
     | 
    
         
            +
                  api_key = fetch(:airbrake_api_key) || fetch(:hoptoad_api_key)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  puts 'Notifying Airbrake of deploy'
         
     | 
| 
       14 
14 
     | 
    
         
             
                  options = {:framework_env => framework_env, :scm_revision => current_revision, :scm_repository => repository}
         
     | 
| 
       15 
15 
     | 
    
         
             
                  Toadhopper(api_key).deploy!(options)
         
     | 
| 
       16 
     | 
    
         
            -
                  puts ' 
     | 
| 
      
 16 
     | 
    
         
            +
                  puts 'Airbrake notification complete'
         
     | 
| 
       17 
17 
     | 
    
         
             
                end
         
     | 
| 
       18 
18 
     | 
    
         
             
              end
         
     | 
| 
       19 
19 
     | 
    
         
             
            end
         
     | 
    
        data/test/helper.rb
    CHANGED
    
    | 
         @@ -6,7 +6,7 @@ require 'toadhopper' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            FakeWeb.allow_net_connect = true
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            def toadhopper
         
     | 
| 
       9 
     | 
    
         
            -
              @toadhopper ||= Toadhopper.new(ENV['HOPTOAD_API_KEY'] || "test api key")
         
     | 
| 
      
 9 
     | 
    
         
            +
              @toadhopper ||= Toadhopper.new(ENV['AIRBRAKE_API_KEY'] || ENV['HOPTOAD_API_KEY'] || "test api key")
         
     | 
| 
       10 
10 
     | 
    
         
             
            end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            def error
         
     | 
| 
         @@ -4,7 +4,7 @@ require 'fakeweb' 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            class Toadhopper::TestDeployTracking < Test::Unit::TestCase
         
     | 
| 
       6 
6 
     | 
    
         
             
              def test_deploy
         
     | 
| 
       7 
     | 
    
         
            -
                FakeWeb.register_uri(:post, 'http:// 
     | 
| 
      
 7 
     | 
    
         
            +
                FakeWeb.register_uri(:post, 'http://airbrakeapp.com/deploys.txt', :status => ['200', 'Ok'])
         
     | 
| 
       8 
8 
     | 
    
         
             
                options = {:framework_env => 'test', :scm_revision => 3, :scm_repository => 'some/where', :username => 'phil'}
         
     | 
| 
       9 
9 
     | 
    
         
             
                response = Toadhopper('bogus key').deploy!(options)
         
     | 
| 
       10 
10 
     | 
    
         
             
                request = FakeWeb.last_request
         
     | 
    
        data/test/test_posting.rb
    CHANGED
    
    | 
         @@ -7,9 +7,9 @@ class Toadhopper::TestPosting < Test::Unit::TestCase 
     | 
|
| 
       7 
7 
     | 
    
         
             
                assert_equal ['No project exists with the given API key.'], response.errors
         
     | 
| 
       8 
8 
     | 
    
         
             
              end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
              if ENV[' 
     | 
| 
      
 10 
     | 
    
         
            +
              if ENV['AIRBRAKE_API_KEY']
         
     | 
| 
       11 
11 
     | 
    
         
             
                def test_posting_integration
         
     | 
| 
       12 
     | 
    
         
            -
                  toadhopper.filters = " 
     | 
| 
      
 12 
     | 
    
         
            +
                  toadhopper.filters = "AIRBRAKE_API_KEY", "ROOT_PASSWORD"
         
     | 
| 
       13 
13 
     | 
    
         
             
                  response = toadhopper.post!(error)
         
     | 
| 
       14 
14 
     | 
    
         
             
                  assert_equal 200, response.status
         
     | 
| 
       15 
15 
     | 
    
         
             
                  assert_equal [], response.errors
         
     | 
    
        data/toadhopper.gemspec
    CHANGED
    
    | 
         @@ -4,7 +4,6 @@ $: << File.expand_path('../lib', __FILE__) 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            require 'toadhopper'
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
7 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       9 
8 
     | 
    
         
             
              s.name        = 'toadhopper'
         
     | 
| 
       10 
9 
     | 
    
         
             
              s.version     = Toadhopper::VERSION
         
     | 
| 
         @@ -12,8 +11,8 @@ Gem::Specification.new do |s| 
     | 
|
| 
       12 
11 
     | 
    
         
             
              s.authors     = ['Tim Lucas', 'Samuel Tesla', 'Corey Donohoe', 'Andre Arko', 'Theo Hultberg']
         
     | 
| 
       13 
12 
     | 
    
         
             
              s.email       = ['t.lucas@toolmantim.com']
         
     | 
| 
       14 
13 
     | 
    
         
             
              s.homepage    = 'http://github.com/toolmantim/toadhopper'
         
     | 
| 
       15 
     | 
    
         
            -
              s.summary     = %q{Post error notifications to  
     | 
| 
       16 
     | 
    
         
            -
              s.description = %q{A base library for  
     | 
| 
      
 14 
     | 
    
         
            +
              s.summary     = %q{Post error notifications to Airbrake}
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.description = %q{A base library for Airbrake error reporting}
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
17 
     | 
    
         
             
              s.rubyforge_project = 'toadhopper'
         
     | 
| 
       19 
18 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            name: toadhopper
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
4 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       5 
     | 
    
         
            -
              version: " 
     | 
| 
      
 5 
     | 
    
         
            +
              version: "2.0"
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors: 
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Tim Lucas
         
     | 
| 
         @@ -14,7 +14,7 @@ autorequire: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2011- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2011-07-26 00:00:00 Z
         
     | 
| 
       18 
18 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       19 
19 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       20 
20 
     | 
    
         
             
              name: rake
         
     | 
| 
         @@ -49,7 +49,7 @@ dependencies: 
     | 
|
| 
       49 
49 
     | 
    
         
             
              type: :development
         
     | 
| 
       50 
50 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       51 
51 
     | 
    
         
             
              version_requirements: *id003
         
     | 
| 
       52 
     | 
    
         
            -
            description: A base library for  
     | 
| 
      
 52 
     | 
    
         
            +
            description: A base library for Airbrake error reporting
         
     | 
| 
       53 
53 
     | 
    
         
             
            email: 
         
     | 
| 
       54 
54 
     | 
    
         
             
            - t.lucas@toolmantim.com
         
     | 
| 
       55 
55 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -88,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       88 
88 
     | 
    
         
             
              requirements: 
         
     | 
| 
       89 
89 
     | 
    
         
             
              - - ">="
         
     | 
| 
       90 
90 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
       91 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 91 
     | 
    
         
            +
                  hash: 384563062547314553
         
     | 
| 
       92 
92 
     | 
    
         
             
                  segments: 
         
     | 
| 
       93 
93 
     | 
    
         
             
                  - 0
         
     | 
| 
       94 
94 
     | 
    
         
             
                  version: "0"
         
     | 
| 
         @@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       97 
97 
     | 
    
         
             
              requirements: 
         
     | 
| 
       98 
98 
     | 
    
         
             
              - - ">="
         
     | 
| 
       99 
99 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
       100 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 100 
     | 
    
         
            +
                  hash: 384563062547314553
         
     | 
| 
       101 
101 
     | 
    
         
             
                  segments: 
         
     | 
| 
       102 
102 
     | 
    
         
             
                  - 0
         
     | 
| 
       103 
103 
     | 
    
         
             
                  version: "0"
         
     | 
| 
         @@ -107,7 +107,7 @@ rubyforge_project: toadhopper 
     | 
|
| 
       107 
107 
     | 
    
         
             
            rubygems_version: 1.8.5
         
     | 
| 
       108 
108 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       109 
109 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       110 
     | 
    
         
            -
            summary: Post error notifications to  
     | 
| 
      
 110 
     | 
    
         
            +
            summary: Post error notifications to Airbrake
         
     | 
| 
       111 
111 
     | 
    
         
             
            test_files: 
         
     | 
| 
       112 
112 
     | 
    
         
             
            - test/helper.rb
         
     | 
| 
       113 
113 
     | 
    
         
             
            - test/test_convenience_constructor.rb
         
     |