honeybadger 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/Appraisals +20 -0
  2. data/Gemfile +1 -13
  3. data/Gemfile.lock +39 -64
  4. data/MIT-LICENSE +5 -0
  5. data/README.md +102 -3
  6. data/Rakefile +9 -134
  7. data/features/metal.feature +6 -4
  8. data/features/rack.feature +3 -4
  9. data/features/rails.feature +106 -99
  10. data/features/rake.feature +0 -2
  11. data/features/sinatra.feature +1 -3
  12. data/features/step_definitions/metal_steps.rb +2 -1
  13. data/features/step_definitions/rack_steps.rb +2 -2
  14. data/features/step_definitions/rails_steps.rb +238 -0
  15. data/features/step_definitions/rake_steps.rb +1 -1
  16. data/features/support/env.rb +7 -7
  17. data/features/support/rails.rb +41 -58
  18. data/gemfiles/rails2.3.gemfile +9 -0
  19. data/gemfiles/rails2.3.gemfile.lock +102 -0
  20. data/gemfiles/rails3.0.gemfile +8 -0
  21. data/gemfiles/rails3.0.gemfile.lock +146 -0
  22. data/gemfiles/rails3.1.gemfile +8 -0
  23. data/gemfiles/rails3.1.gemfile.lock +161 -0
  24. data/gemfiles/rails3.2.gemfile +8 -0
  25. data/gemfiles/rails3.2.gemfile.lock +160 -0
  26. data/honeybadger.gemspec +30 -24
  27. data/lib/honeybadger.rb +117 -113
  28. data/lib/honeybadger/backtrace.rb +9 -3
  29. data/lib/honeybadger/configuration.rb +22 -0
  30. data/lib/honeybadger/notice.rb +9 -0
  31. data/lib/honeybadger/rack.rb +5 -4
  32. data/lib/honeybadger/rails3_tasks.rb +20 -23
  33. data/lib/honeybadger/sender.rb +10 -4
  34. data/lib/honeybadger/shared_tasks.rb +12 -1
  35. data/lib/honeybadger/tasks.rb +6 -1
  36. data/test/test_helper.rb +71 -71
  37. data/test/unit/backtrace_test.rb +26 -23
  38. data/test/unit/capistrano_test.rb +1 -1
  39. data/test/unit/configuration_test.rb +19 -3
  40. data/test/unit/honeybadger_tasks_test.rb +1 -1
  41. data/test/unit/logger_test.rb +1 -1
  42. data/test/unit/notice_test.rb +71 -16
  43. data/test/unit/notifier_test.rb +25 -5
  44. data/test/unit/rack_test.rb +21 -1
  45. data/test/unit/rails/action_controller_catcher_test.rb +1 -1
  46. data/test/unit/rails_test.rb +1 -1
  47. data/test/unit/sender_test.rb +1 -1
  48. metadata +69 -45
  49. data/SUPPORTED_RAILS_VERSIONS +0 -37
  50. data/TESTING.md +0 -33
  51. data/features/step_definitions/file_steps.rb +0 -10
  52. data/features/step_definitions/rails_application_steps.rb +0 -394
  53. data/features/support/terminal.rb +0 -107
data/Appraisals ADDED
@@ -0,0 +1,20 @@
1
+ appraise 'rails2.3' do
2
+ gem 'rails', '2.3.14'
3
+ gem 'rake', '0.9.5'
4
+ gem 'honeybadger', :path => '../'
5
+ end
6
+
7
+ appraise 'rails3.0' do
8
+ gem 'rails', '3.0.17'
9
+ gem 'honeybadger', :path => '../'
10
+ end
11
+
12
+ appraise 'rails3.1' do
13
+ gem 'rails', '3.1.8'
14
+ gem 'honeybadger', :path => '../'
15
+ end
16
+
17
+ appraise 'rails3.2' do
18
+ gem 'rails', '3.2.9'
19
+ gem 'honeybadger', :path => '../'
20
+ end
data/Gemfile CHANGED
@@ -1,14 +1,2 @@
1
- source "https://rubygems.org"
2
-
1
+ source :rubygems
3
2
  gemspec
4
-
5
- gem 'rake'
6
-
7
- if true
8
- group :test do
9
- gem 'pry'
10
- gem 'guard'
11
- gem 'guard-test'
12
- gem 'simplecov'
13
- end
14
- end
data/Gemfile.lock CHANGED
@@ -1,57 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- honeybadger (1.3.1)
4
+ honeybadger (1.4.0)
5
5
  activesupport
6
6
  json
7
7
 
8
8
  GEM
9
- remote: https://rubygems.org/
9
+ remote: http://rubygems.org/
10
10
  specs:
11
- actionpack (2.3.14)
12
- activesupport (= 2.3.14)
13
- rack (~> 1.1.0)
14
- activerecord (2.3.14)
15
- activesupport (= 2.3.14)
16
- activesupport (2.3.14)
11
+ activesupport (3.2.9)
12
+ i18n (~> 0.6)
13
+ multi_json (~> 1.0)
14
+ appraisal (0.5.1)
15
+ bundler
16
+ rake
17
+ aruba (0.5.1)
18
+ childprocess (~> 0.3.6)
19
+ cucumber (>= 1.1.1)
20
+ rspec-expectations (>= 2.7.0)
17
21
  bourne (1.1.2)
18
22
  mocha (= 0.10.5)
19
- builder (3.0.0)
23
+ builder (3.1.4)
20
24
  capistrano (2.8.0)
21
25
  highline
22
26
  net-scp (>= 1.0.0)
23
27
  net-sftp (>= 2.0.0)
24
28
  net-ssh (>= 2.0.14)
25
29
  net-ssh-gateway (>= 1.1.0)
26
- coderay (1.0.7)
27
- cucumber (0.10.7)
30
+ childprocess (0.3.6)
31
+ ffi (~> 1.0, >= 1.0.6)
32
+ cucumber (1.2.1)
28
33
  builder (>= 2.1.2)
29
- diff-lcs (>= 1.1.2)
30
- gherkin (~> 2.4.0)
34
+ diff-lcs (>= 1.1.3)
35
+ gherkin (~> 2.11.0)
31
36
  json (>= 1.4.6)
32
- term-ansicolor (>= 1.0.5)
33
37
  diff-lcs (1.1.3)
34
38
  fakeweb (1.3.0)
35
- ffi (1.0.11)
36
- gherkin (2.4.21)
39
+ ffi (1.2.0)
40
+ gherkin (2.11.5)
37
41
  json (>= 1.4.6)
38
- guard (1.2.3)
39
- listen (>= 0.4.2)
40
- thor (>= 0.14.6)
41
- guard-test (0.5.0)
42
- guard (>= 1.1.0)
43
- test-unit (~> 2.2)
44
42
  highline (1.6.13)
43
+ i18n (0.6.1)
45
44
  json (1.7.3)
46
- listen (0.4.7)
47
- rb-fchange (~> 0.0.5)
48
- rb-fsevent (~> 0.9.1)
49
- rb-inotify (~> 0.8.8)
50
45
  metaclass (0.0.1)
51
- method_source (0.8)
52
46
  mocha (0.10.5)
53
47
  metaclass (~> 0.0.1)
54
- multi_json (1.3.6)
48
+ multi_json (1.5.0)
55
49
  net-scp (1.0.4)
56
50
  net-ssh (>= 1.99.1)
57
51
  net-sftp (2.0.5)
@@ -59,54 +53,35 @@ GEM
59
53
  net-ssh (2.5.2)
60
54
  net-ssh-gateway (1.1.0)
61
55
  net-ssh (>= 1.99.1)
62
- pry (0.9.10)
63
- coderay (~> 1.0.5)
64
- method_source (~> 0.8)
65
- slop (~> 3.3.1)
66
56
  rack (1.1.3)
67
- rake (0.9.2.2)
68
- rb-fchange (0.0.5)
69
- ffi
70
- rb-fsevent (0.9.1)
71
- rb-inotify (0.8.8)
72
- ffi (>= 0.5.0)
73
- rspec (2.6.0)
74
- rspec-core (~> 2.6.0)
75
- rspec-expectations (~> 2.6.0)
76
- rspec-mocks (~> 2.6.0)
77
- rspec-core (2.6.4)
78
- rspec-expectations (2.6.0)
79
- diff-lcs (~> 1.1.2)
80
- rspec-mocks (2.6.0)
57
+ rake (10.0.2)
58
+ rspec (2.12.0)
59
+ rspec-core (~> 2.12.0)
60
+ rspec-expectations (~> 2.12.0)
61
+ rspec-mocks (~> 2.12.0)
62
+ rspec-core (2.12.0)
63
+ rspec-expectations (2.12.0)
64
+ diff-lcs (~> 1.1.3)
65
+ rspec-mocks (2.12.0)
81
66
  sham_rack (1.3.4)
82
67
  rack
83
68
  shoulda (2.11.3)
84
- simplecov (0.6.4)
85
- multi_json (~> 1.0)
86
- simplecov-html (~> 0.5.3)
87
- simplecov-html (0.5.3)
88
- slop (3.3.2)
89
- term-ansicolor (1.0.7)
90
- test-unit (2.5.1)
91
- thor (0.15.4)
69
+ sinatra (1.0)
70
+ rack (>= 1.0)
92
71
 
93
72
  PLATFORMS
94
73
  ruby
95
74
 
96
75
  DEPENDENCIES
97
- actionpack (~> 2.3.8)
98
- activerecord (~> 2.3.8)
99
- activesupport (~> 2.3.8)
76
+ appraisal
77
+ aruba
100
78
  bourne (>= 1.0)
101
- capistrano (~> 2.8.0)
102
- cucumber (~> 0.10.6)
79
+ capistrano
80
+ cucumber (~> 1.2.1)
103
81
  fakeweb (~> 1.3.0)
104
- guard
105
- guard-test
106
82
  honeybadger!
107
- pry
108
83
  rake
109
- rspec (~> 2.6.0)
84
+ rspec (~> 2.12.0)
110
85
  sham_rack (~> 1.3.0)
111
86
  shoulda (~> 2.11.3)
112
- simplecov
87
+ sinatra
data/MIT-LICENSE CHANGED
@@ -1,6 +1,9 @@
1
1
  Copyright (c) 2007 - 2012, Exceptional DBA Airbrake.io
2
2
  Portions Copyright (c) 2012, Honeybadger Industries LLC
3
3
 
4
+ NOTE: All code contained herein that is copyright Exceptional DBA Airbrake.io was available
5
+ under the MIT license (listed below) on or before November 6, 2012.
6
+
4
7
  Permission is hereby granted, free of charge, to any person
5
8
  obtaining a copy of this software and associated documentation
6
9
  files (the "Software"), to deal in the Software without
@@ -21,3 +24,5 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
24
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
25
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
26
  OTHER DEALINGS IN THE SOFTWARE.
27
+
28
+
data/README.md CHANGED
@@ -3,7 +3,7 @@ Honeybadger
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/honeybadger-io/honeybadger-ruby.png?branch=master)](http://travis-ci.org/honeybadger-io/honeybadger-ruby)
5
5
 
6
- This is the notifier gem for integrating apps with [Honeybadger](http://honeybadger.io).
6
+ This is the notifier gem for integrating apps with :zap: [Honeybadger](http://honeybadger.io).
7
7
 
8
8
  When an uncaught exception occurs, Honeybadger will POST the relevant data
9
9
  to the Honeybadger server specified in your environment.
@@ -146,6 +146,86 @@ request's life cycle. Honeybadger will discard the data when a
146
146
  request completes, so that the next request will start with a blank
147
147
  slate.
148
148
 
149
+ ## Notifying Honeybadger asynchronously
150
+
151
+ Want to send notices in a thread, or even use Resque or Sidekiq to
152
+ deliver notifications? The 'badger has you covered.
153
+
154
+ To get started, you'll need to configure Honeybadger to accept a
155
+ handler. A handler can be any object that responds to `#call` (usually a
156
+ `Proc`) and accepts one argument (a `Honeybadger::Notice` instance). The
157
+ handler can be set directly by setting the `async` configuration option,
158
+ or by passing a block to `config.async` (in this case, a Proc instance
159
+ will be created for you):
160
+
161
+ Honeybadger.configure do |config|
162
+ ...
163
+
164
+ # Configuring handler directly:
165
+ config.async do |notice|
166
+ # Delivers notification immediately
167
+ notice.deliver # => 'qwer-asdf-zxcv'
168
+ end
169
+
170
+ # Using your own handler (identical behavior):
171
+ config.async = Proc.new { |n| n.deliver }
172
+ end
173
+
174
+ We've left the implementation mostly up to you, but here are a few
175
+ examples of notifying Honeybadger asynchronously:
176
+
177
+ ### Using thread
178
+
179
+ Honeybadger.configure do |config|
180
+ config.async do |notice|
181
+ Thread.new { notice.deliver }
182
+ end
183
+ end
184
+
185
+ ### Using Resque
186
+
187
+ Honeybadger.configure do |config|
188
+ config.async do |notice|
189
+ Resque.enqueue(WorkingBadger, notice)
190
+ end
191
+ end
192
+
193
+ class WorkingBadger
194
+ @queue = :cobra_alert
195
+
196
+ def self.perform(notice)
197
+ Honeybadger.sender.send_to_honeybadger(notice)
198
+ end
199
+ end
200
+
201
+ ### Using Sidekiq
202
+
203
+ Honeybadger.configure do |config|
204
+ config.async do |notice|
205
+ WorkingBadger.perform_async(notice)
206
+ end
207
+ end
208
+
209
+ class WorkingBadger
210
+ include Sidekiq::Worker
211
+
212
+ def perform(notice)
213
+ Honeybadger.sender.send_to_honeybadger(notice)
214
+ end
215
+ end
216
+
217
+ ### Using GirlFriday
218
+
219
+ COBRA_QUEUE = GirlFriday::WorkQueue.new(:honeybadger_notices, :size => 7) do |notice|
220
+ notice.deliver
221
+ end
222
+
223
+ Honeybadger.configure do |config|
224
+ config.async do |notice|
225
+ COBRA_QUEUE.push(notice)
226
+ end
227
+ end
228
+
149
229
  ## Going beyond exceptions
150
230
 
151
231
  You can also pass a hash to `Honeybadger.notify` method and store whatever you want,
@@ -285,7 +365,26 @@ added the following information to your Honeybadger configuration block.
285
365
 
286
366
  ## Supported Rails versions
287
367
 
288
- Honeybadger supports Rails 3.0.0 through rails 3.2.6.
368
+ Honeybadger supports Rails 2.3.14 through rails 3.2.9.
369
+
370
+ ## Contributing
371
+
372
+ 1. Fork it.
373
+ 2. Create a topic branch `git checkout -b my_branch`
374
+ 3. Commit your changes `git commit -am "Boom"`
375
+ 3. Push to your branch `git push origin my_branch`
376
+ 4. Send a [pull request](https://github.com/honeybadger-io/honeybadger-ruby/pulls)
377
+
378
+ ### Running the tests
379
+
380
+ We're using the
381
+ [appraisal](https://github.com/thoughtbot/appraisal) gem to run our test
382
+ suite against multiple versions of Rails. To run the Cucumber features,
383
+ use `rake appraisal cucumber`. Type `rake -T` for a complete list of
384
+ available tasks.
385
+
386
+ The unit tests are undergoing some changes, but for now can be run with
387
+ `rake appraisal:rails2.3 test`.
289
388
 
290
389
  ## Credits
291
390
 
@@ -298,5 +397,5 @@ The nifty custom data (`Honeybadger.context()`) feature was inspired by Exceptio
298
397
 
299
398
  ## License
300
399
 
301
- Honeybadger is Copyright 2012 © Honeybadger. It is free software, and
400
+ Honeybadger is Copyright 2012 © Honeybadger Industries LLC. It is free software, and
302
401
  may be redistributed under the terms specified in the MIT-LICENSE file.
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'rubygems'
2
- require 'rake'
2
+ require 'bundler/setup'
3
+ require 'appraisal'
3
4
  require 'date'
4
5
  require 'json'
6
+
5
7
  begin
6
8
  require 'cucumber/rake/task'
7
9
  rescue LoadError
@@ -11,7 +13,7 @@ end
11
13
 
12
14
  #############################################################################
13
15
  #
14
- # Helper functions
16
+ # Helper methods
15
17
  #
16
18
  #############################################################################
17
19
 
@@ -57,6 +59,11 @@ Rake::TestTask.new(:test) do |test|
57
59
  test.verbose = true
58
60
  end
59
61
 
62
+ Cucumber::Rake::Task.new(:cucumber) do |t|
63
+ t.fork = true
64
+ t.cucumber_opts = ['--format', 'progress', '--tags', '~@pending']
65
+ end
66
+
60
67
  desc "Generate RCov test coverage and open in your browser"
61
68
  task :coverage do
62
69
  require 'rcov'
@@ -65,143 +72,11 @@ task :coverage do
65
72
  sh "open coverage/index.html"
66
73
  end
67
74
 
68
- require 'rake/rdoctask'
69
- Rake::RDocTask.new do |rdoc|
70
- rdoc.rdoc_dir = 'rdoc'
71
- rdoc.title = "#{name} #{version}"
72
- rdoc.rdoc_files.include('README*')
73
- rdoc.rdoc_files.include('lib/**/*.rb')
74
- end
75
-
76
75
  desc "Open an irb session preloaded with this library"
77
76
  task :console do
78
77
  sh "irb -rubygems -r ./lib/#{name}.rb"
79
78
  end
80
79
 
81
- #############################################################################
82
- #
83
- # Custom tasks (add your own tasks here)
84
- #
85
- #############################################################################
86
-
87
- FEATURES = ['sinatra', 'rack', 'metal']
88
-
89
- desc 'Default: run unit & acceptance tests.'
90
- task :default => [:test, :vendor_test_gems , "cucumber:rails:all"] + FEATURES
91
-
92
- GEM_ROOT = File.dirname(__FILE__).freeze
93
-
94
- LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
95
- RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n")
96
- LOCAL_GEMS =
97
- [
98
- ['rake', nil],
99
- ['rack','1.3.2']
100
- ] +
101
- RAILS_VERSIONS.collect { |version| ['rails', version] } +
102
- [
103
- ['sham_rack', nil],
104
- ['capistrano', nil],
105
- ['sqlite3-ruby', nil],
106
- ['therubyracer',nil],
107
- ['sinatra',nil]
108
- ]
109
-
110
- desc "Vendor test gems: Run this once to prepare your test environment"
111
- task :vendor_test_gems do
112
- old_gem_path = ENV['GEM_PATH']
113
- old_gem_home = ENV['GEM_HOME']
114
- ENV['GEM_PATH'] = LOCAL_GEM_ROOT
115
- ENV['GEM_HOME'] = LOCAL_GEM_ROOT
116
-
117
- LOCAL_GEMS.each do |gem_name, version|
118
- gem_file_pattern = [gem_name, version || '*'].compact.join('-')
119
- version_option = version ? "-v #{version}" : ''
120
- pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}")
121
- existing = Dir.glob(pattern).first
122
- if existing
123
- puts "\nskipping #{gem_name} since it's already vendored," +
124
- "remove it from the tmp directory first."
125
- next
126
- end
127
-
128
- command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
129
- puts "Vendoring #{gem_file_pattern}..."
130
- unless system("#{command} 2>&1")
131
- puts "Command failed: #{command}"
132
- exit(1)
133
- end
134
- end
135
-
136
- ENV['GEM_PATH'] = old_gem_path
137
- ENV['GEM_HOME'] = old_gem_home
138
- end
139
-
140
- Cucumber::Rake::Task.new(:cucumber) do |t|
141
- t.fork = true
142
- t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
143
- end
144
-
145
- task :cucumber => [:vendor_test_gems]
146
-
147
- def run_rails_cucumber_task(version, additional_cucumber_args)
148
- puts "Testing Rails #{version}"
149
- if version.empty?
150
- raise "No Rails version specified - make sure ENV['RAILS_VERSION'] is set, e.g. with `rake cucumber:rails:all`"
151
- end
152
- ENV['RAILS_VERSION'] = version
153
- cmd = "cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature"
154
- puts "Running command: #{cmd}"
155
- system(cmd)
156
- end
157
-
158
- def define_rails_cucumber_tasks(additional_cucumber_args = '')
159
- namespace :rails do
160
- RAILS_VERSIONS.each do |version|
161
- desc "Test integration of the gem with Rails #{version}"
162
- task version => [:vendor_test_gems] do
163
- exit 1 unless run_rails_cucumber_task(version, additional_cucumber_args)
164
- end
165
- end
166
-
167
- desc "Test integration of the gem with all Rails versions"
168
- task :all do
169
- results = RAILS_VERSIONS.map do |version|
170
- run_rails_cucumber_task(version, additional_cucumber_args)
171
- end
172
-
173
- exit 1 unless results.all?
174
- end
175
- end
176
- end
177
-
178
- namespace :cucumber do
179
- namespace :wip do
180
- define_rails_cucumber_tasks('--tags @wip')
181
- end
182
-
183
- define_rails_cucumber_tasks
184
-
185
- rule /#{"(" + FEATURES.join("|") + ")"}/ do |t|
186
- framework = t.name
187
- desc "Test integration of the gem with #{framework}"
188
- task framework.to_sym do
189
- puts "Testing #{framework.split(":").last}..."
190
- cmd = "cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features/#{framework.split(":").last}.feature"
191
- puts "Running command: #{cmd}"
192
- system(cmd)
193
- end
194
- end
195
- end
196
-
197
- desc "Update supported versions: Run this to pull down latest rails versions from rubygems"
198
- task :update_supported_versions do
199
- down_to = Gem::Version.new('2.3.14')
200
- versions = JSON.parse `curl https://rubygems.org/api/v1/versions/rails.json 2> /dev/null`
201
- supported_versions = versions.map { |v| Gem::Version.new(v['number']) }.reject { |v| v < down_to || v.prerelease? }.sort
202
- `echo '#{supported_versions.join("\n")}' > SUPPORTED_RAILS_VERSIONS`
203
- end
204
-
205
80
  #############################################################################
206
81
  #
207
82
  # Packaging tasks