honeybadger 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/Appraisals +25 -1
  2. data/CHANGELOG.md +47 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +7 -8
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +117 -6
  7. data/Rakefile +15 -0
  8. data/features/rack.feature +2 -2
  9. data/features/rails.feature +79 -15
  10. data/features/step_definitions/metal_steps.rb +4 -4
  11. data/features/step_definitions/rack_steps.rb +0 -4
  12. data/features/step_definitions/rails_steps.rb +49 -32
  13. data/features/support/honeybadger_failure_shim.rb.template +5 -0
  14. data/features/support/rails.rb +17 -5
  15. data/gemfiles/rack.gemfile +8 -0
  16. data/gemfiles/rack.gemfile.lock +92 -0
  17. data/gemfiles/rails2.3.gemfile +1 -1
  18. data/gemfiles/rails2.3.gemfile.lock +6 -2
  19. data/gemfiles/rails3.0.gemfile +2 -1
  20. data/gemfiles/rails3.0.gemfile.lock +12 -3
  21. data/gemfiles/rails3.1.gemfile +2 -1
  22. data/gemfiles/rails3.1.gemfile.lock +12 -3
  23. data/gemfiles/rails3.2.gemfile +3 -2
  24. data/gemfiles/rails3.2.gemfile.lock +45 -36
  25. data/gemfiles/rails4.gemfile +9 -0
  26. data/gemfiles/rails4.gemfile.lock +174 -0
  27. data/gemfiles/rake.gemfile +8 -0
  28. data/gemfiles/rake.gemfile.lock +91 -0
  29. data/gemfiles/sinatra.gemfile +8 -0
  30. data/gemfiles/sinatra.gemfile.lock +91 -0
  31. data/generators/honeybadger/honeybadger_generator.rb +5 -5
  32. data/honeybadger.gemspec +12 -3
  33. data/lib/honeybadger.rb +7 -14
  34. data/lib/honeybadger/configuration.rb +10 -1
  35. data/lib/honeybadger/notice.rb +38 -20
  36. data/lib/honeybadger/rack.rb +0 -1
  37. data/lib/honeybadger/rails/controller_methods.rb +5 -4
  38. data/lib/honeybadger/rails3_tasks.rb +16 -4
  39. data/lib/honeybadger/sender.rb +10 -19
  40. data/lib/honeybadger/shared_tasks.rb +2 -3
  41. data/lib/honeybadger/tasks.rb +16 -9
  42. data/lib/honeybadger_tasks.rb +2 -3
  43. data/lib/rails/generators/honeybadger/honeybadger_generator.rb +5 -5
  44. data/test/test_helper.rb +2 -7
  45. data/test/unit/backtrace_test.rb +19 -19
  46. data/test/unit/configuration_test.rb +11 -5
  47. data/test/unit/notice_test.rb +21 -3
  48. data/test/unit/rails/action_controller_catcher_test.rb +250 -241
  49. data/test/unit/sender_test.rb +22 -2
  50. metadata +13 -19
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra"
6
+ gem "honeybadger", :path=>"../"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: /Users/josh/code/honeybadger-ruby
3
+ specs:
4
+ honeybadger (1.5.0)
5
+ json
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (0.5.1)
11
+ bundler
12
+ rake
13
+ aruba (0.5.1)
14
+ childprocess (~> 0.3.6)
15
+ cucumber (>= 1.1.1)
16
+ rspec-expectations (>= 2.7.0)
17
+ bourne (1.3.0)
18
+ mocha (= 0.13.0)
19
+ builder (3.1.4)
20
+ capistrano (2.14.1)
21
+ highline
22
+ net-scp (>= 1.0.0)
23
+ net-sftp (>= 2.0.0)
24
+ net-ssh (>= 2.0.14)
25
+ net-ssh-gateway (>= 1.1.0)
26
+ childprocess (0.3.6)
27
+ ffi (~> 1.0, >= 1.0.6)
28
+ cucumber (1.2.1)
29
+ builder (>= 2.1.2)
30
+ diff-lcs (>= 1.1.3)
31
+ gherkin (~> 2.11.0)
32
+ json (>= 1.4.6)
33
+ diff-lcs (1.1.3)
34
+ fakeweb (1.3.0)
35
+ ffi (1.3.1)
36
+ ffi (1.3.1-java)
37
+ gherkin (2.11.5)
38
+ json (>= 1.4.6)
39
+ gherkin (2.11.5-java)
40
+ json (>= 1.4.6)
41
+ highline (1.6.15)
42
+ json (1.7.6)
43
+ json (1.7.6-java)
44
+ metaclass (0.0.1)
45
+ mocha (0.13.0)
46
+ metaclass (~> 0.0.1)
47
+ net-scp (1.0.4)
48
+ net-ssh (>= 1.99.1)
49
+ net-sftp (2.0.5)
50
+ net-ssh (>= 2.0.9)
51
+ net-ssh (2.6.3)
52
+ net-ssh-gateway (1.1.0)
53
+ net-ssh (>= 1.99.1)
54
+ rack (1.4.5)
55
+ rack-protection (1.3.2)
56
+ rack
57
+ rake (10.0.3)
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.2)
63
+ rspec-expectations (2.12.1)
64
+ diff-lcs (~> 1.1.3)
65
+ rspec-mocks (2.12.2)
66
+ sham_rack (1.3.4)
67
+ rack
68
+ shoulda (2.11.3)
69
+ sinatra (1.3.3)
70
+ rack (~> 1.3, >= 1.3.6)
71
+ rack-protection (~> 1.2)
72
+ tilt (~> 1.3, >= 1.3.3)
73
+ tilt (1.3.3)
74
+
75
+ PLATFORMS
76
+ java
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ appraisal
81
+ aruba
82
+ bourne (>= 1.0)
83
+ capistrano
84
+ cucumber (~> 1.2.1)
85
+ fakeweb (~> 1.3.0)
86
+ honeybadger!
87
+ rake
88
+ rspec (~> 2.12.0)
89
+ sham_rack (~> 1.3.0)
90
+ shoulda (~> 2.11.3)
91
+ sinatra
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sinatra"
6
+ gem "honeybadger", :path=>"../"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: /Users/josh/code/honeybadger-ruby
3
+ specs:
4
+ honeybadger (1.5.0)
5
+ json
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (0.5.1)
11
+ bundler
12
+ rake
13
+ aruba (0.5.1)
14
+ childprocess (~> 0.3.6)
15
+ cucumber (>= 1.1.1)
16
+ rspec-expectations (>= 2.7.0)
17
+ bourne (1.3.0)
18
+ mocha (= 0.13.0)
19
+ builder (3.1.4)
20
+ capistrano (2.14.1)
21
+ highline
22
+ net-scp (>= 1.0.0)
23
+ net-sftp (>= 2.0.0)
24
+ net-ssh (>= 2.0.14)
25
+ net-ssh-gateway (>= 1.1.0)
26
+ childprocess (0.3.6)
27
+ ffi (~> 1.0, >= 1.0.6)
28
+ cucumber (1.2.1)
29
+ builder (>= 2.1.2)
30
+ diff-lcs (>= 1.1.3)
31
+ gherkin (~> 2.11.0)
32
+ json (>= 1.4.6)
33
+ diff-lcs (1.1.3)
34
+ fakeweb (1.3.0)
35
+ ffi (1.3.1)
36
+ ffi (1.3.1-java)
37
+ gherkin (2.11.5)
38
+ json (>= 1.4.6)
39
+ gherkin (2.11.5-java)
40
+ json (>= 1.4.6)
41
+ highline (1.6.15)
42
+ json (1.7.6)
43
+ json (1.7.6-java)
44
+ metaclass (0.0.1)
45
+ mocha (0.13.0)
46
+ metaclass (~> 0.0.1)
47
+ net-scp (1.0.4)
48
+ net-ssh (>= 1.99.1)
49
+ net-sftp (2.0.5)
50
+ net-ssh (>= 2.0.9)
51
+ net-ssh (2.6.3)
52
+ net-ssh-gateway (1.1.0)
53
+ net-ssh (>= 1.99.1)
54
+ rack (1.4.5)
55
+ rack-protection (1.3.2)
56
+ rack
57
+ rake (10.0.3)
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.2)
63
+ rspec-expectations (2.12.1)
64
+ diff-lcs (~> 1.1.3)
65
+ rspec-mocks (2.12.2)
66
+ sham_rack (1.3.4)
67
+ rack
68
+ shoulda (2.11.3)
69
+ sinatra (1.3.3)
70
+ rack (~> 1.3, >= 1.3.6)
71
+ rack-protection (~> 1.2)
72
+ tilt (~> 1.3, >= 1.3.3)
73
+ tilt (1.3.3)
74
+
75
+ PLATFORMS
76
+ java
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ appraisal
81
+ aruba
82
+ bourne (>= 1.0)
83
+ capistrano
84
+ cucumber (~> 1.2.1)
85
+ fakeweb (~> 1.3.0)
86
+ honeybadger!
87
+ rake
88
+ rspec (~> 2.12.0)
89
+ sham_rack (~> 1.3.0)
90
+ shoulda (~> 2.11.3)
91
+ sinatra
@@ -49,15 +49,15 @@ class HoneybadgerGenerator < Rails::Generator::Base
49
49
  def determine_api_key
50
50
  puts "Attempting to determine your API Key from Heroku..."
51
51
  ENV['HONEYBADGER_API_KEY'] = heroku_api_key
52
- if ENV['HONEYBADGER_API_KEY'].blank?
52
+ if ENV['HONEYBADGER_API_KEY'] =~ /\S/
53
+ puts "... Done."
54
+ puts "Heroku's Honeybadger API Key is '#{ENV['HONEYBADGER_API_KEY']}'"
55
+ else
53
56
  puts "... Failed."
54
57
  puts "WARNING: We were unable to detect the Honeybadger API Key from your Heroku environment."
55
58
  puts "Your Heroku application environment may not be configured correctly."
56
59
  puts "Have you configured multiple Heroku apps? Try using the '--app [app name]' flag." unless options[:app]
57
60
  exit 1
58
- else
59
- puts "... Done."
60
- puts "Heroku's Honeybadger API Key is '#{ENV['HONEYBADGER_API_KEY']}'"
61
61
  end
62
62
  end
63
63
 
@@ -67,7 +67,7 @@ class HoneybadgerGenerator < Rails::Generator::Base
67
67
  end
68
68
 
69
69
  def heroku_api_key
70
- heroku_var("HONEYBADGER_API_KEY",options[:app]).split.find {|x| x unless x.blank?}
70
+ heroku_var("HONEYBADGER_API_KEY",options[:app]).split.find {|x| x =~ /\S/ }
71
71
  end
72
72
 
73
73
  def heroku?
data/honeybadger.gemspec CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'honeybadger'
7
- s.version = '1.5.0'
8
- s.date = '2013-01-16'
7
+ s.version = '1.6.0'
8
+ s.date = '2013-03-12'
9
9
 
10
10
  s.summary = 'Error reports you can be happy about.'
11
11
  s.description = 'Make managing application errors a more pleasant experience.'
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.extra_rdoc_files = %w[README.md MIT-LICENSE]
21
21
 
22
22
  s.add_dependency('json')
23
- s.add_dependency('activesupport')
24
23
 
25
24
  s.add_development_dependency('cucumber', '~> 1.2.1')
26
25
  s.add_development_dependency('rspec', '~> 2.12.0')
@@ -40,6 +39,7 @@ Gem::Specification.new do |s|
40
39
  # = MANIFEST =
41
40
  s.files = %w[
42
41
  Appraisals
42
+ CHANGELOG.md
43
43
  Gemfile
44
44
  Gemfile.lock
45
45
  Guardfile
@@ -56,9 +56,12 @@ Gem::Specification.new do |s|
56
56
  features/step_definitions/rails_steps.rb
57
57
  features/step_definitions/rake_steps.rb
58
58
  features/support/env.rb
59
+ features/support/honeybadger_failure_shim.rb.template
59
60
  features/support/honeybadger_shim.rb.template
60
61
  features/support/rails.rb
61
62
  features/support/rake/Rakefile
63
+ gemfiles/rack.gemfile
64
+ gemfiles/rack.gemfile.lock
62
65
  gemfiles/rails2.3.gemfile
63
66
  gemfiles/rails2.3.gemfile.lock
64
67
  gemfiles/rails3.0.gemfile
@@ -67,6 +70,12 @@ Gem::Specification.new do |s|
67
70
  gemfiles/rails3.1.gemfile.lock
68
71
  gemfiles/rails3.2.gemfile
69
72
  gemfiles/rails3.2.gemfile.lock
73
+ gemfiles/rails4.gemfile
74
+ gemfiles/rails4.gemfile.lock
75
+ gemfiles/rake.gemfile
76
+ gemfiles/rake.gemfile.lock
77
+ gemfiles/sinatra.gemfile
78
+ gemfiles/sinatra.gemfile.lock
70
79
  generators/honeybadger/honeybadger_generator.rb
71
80
  generators/honeybadger/lib/insert_commands.rb
72
81
  generators/honeybadger/lib/rake_commands.rb
data/lib/honeybadger.rb CHANGED
@@ -1,14 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'net/https'
3
3
  require 'json'
4
-
5
- begin
6
- require 'active_support'
7
- require 'active_support/core_ext'
8
- rescue LoadError
9
- require 'activesupport'
10
- require 'activesupport/core_ext'
11
- end
4
+ require 'logger'
12
5
 
13
6
  require 'honeybadger/configuration'
14
7
  require 'honeybadger/backtrace'
@@ -19,7 +12,7 @@ require 'honeybadger/sender'
19
12
  require 'honeybadger/railtie' if defined?(Rails::Railtie)
20
13
 
21
14
  module Honeybadger
22
- VERSION = '1.5.0'
15
+ VERSION = '1.6.0'
23
16
  LOG_PREFIX = "** [Honeybadger] "
24
17
 
25
18
  HEADERS = {
@@ -38,7 +31,7 @@ module Honeybadger
38
31
 
39
32
  # Tell the log that the Notifier is good to go
40
33
  def report_ready
41
- write_verbose_log("Notifier #{VERSION} ready to catch errors")
34
+ write_verbose_log("Notifier #{VERSION} ready to catch errors", :info)
42
35
  end
43
36
 
44
37
  # Prints out the environment info to the log for debugging help
@@ -59,8 +52,8 @@ module Honeybadger
59
52
  end
60
53
 
61
54
  # Writes out the given message to the #logger
62
- def write_verbose_log(message)
63
- logger.info LOG_PREFIX + message if logger
55
+ def write_verbose_log(message, level = Honeybadger.configuration.debug ? :info : :debug)
56
+ logger.send(level, LOG_PREFIX + message) if logger
64
57
  end
65
58
 
66
59
  # Look for the Rails logger currently defined
@@ -128,8 +121,8 @@ module Honeybadger
128
121
  result[:environment_name] = 'production'
129
122
 
130
123
  unless notice.backtrace.lines.empty?
131
- result[:file] = notice.backtrace.lines.first.file
132
- result[:line_number] = notice.backtrace.lines.first.number
124
+ result[:file] = notice.backtrace.lines[0].file
125
+ result[:line_number] = notice.backtrace.lines[0].number
133
126
  end
134
127
 
135
128
  result
@@ -5,7 +5,8 @@ module Honeybadger
5
5
  :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
6
6
  :params_filters, :project_root, :port, :protocol, :proxy_host, :proxy_pass,
7
7
  :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain, :framework,
8
- :user_information, :rescue_rake_exceptions, :source_extract_radius].freeze
8
+ :user_information, :rescue_rake_exceptions, :source_extract_radius,
9
+ :send_request_session, :debug].freeze
9
10
 
10
11
  # The API key for your project, found on the project edit form.
11
12
  attr_accessor :api_key
@@ -91,6 +92,12 @@ module Honeybadger
91
92
  # The radius around trace line to include in source excerpt
92
93
  attr_accessor :source_extract_radius
93
94
 
95
+ # +true+ to send session data, +false+ to exclude
96
+ attr_accessor :send_request_session
97
+
98
+ # +true+ to log extra debug info, +false+ to suppress
99
+ attr_accessor :debug
100
+
94
101
  # A Proc object used to send notices asynchronously
95
102
  attr_writer :async
96
103
 
@@ -145,6 +152,8 @@ module Honeybadger
145
152
  @user_information = 'Honeybadger Error {{error_id}}'
146
153
  @rescue_rake_exceptions = nil
147
154
  @source_extract_radius = 2
155
+ @send_request_session = true
156
+ @debug = false
148
157
  end
149
158
 
150
159
  # Public: Takes a block and adds it to the list of backtrace filters. When
@@ -26,6 +26,9 @@ module Honeybadger
26
26
  # The message from the exception, or a general description of the error
27
27
  attr_reader :error_message
28
28
 
29
+ # See Configuration#send_request_session
30
+ attr_reader :send_request_session
31
+
29
32
  # See Configuration#backtrace_filters
30
33
  attr_reader :backtrace_filters
31
34
 
@@ -107,6 +110,8 @@ module Honeybadger
107
110
  self.source_extract_radius = args[:source_extract_radius] || 2
108
111
  self.source_extract = extract_source_from_backtrace
109
112
 
113
+ self.send_request_session = args[:send_request_session].nil? ? true : args[:send_request_session]
114
+
110
115
  also_use_rack_params_filters
111
116
  find_session_data
112
117
  clean_params
@@ -129,7 +134,8 @@ module Honeybadger
129
134
  :notifier => {
130
135
  :name => notifier_name,
131
136
  :url => notifier_url,
132
- :version => notifier_version
137
+ :version => notifier_version,
138
+ :language => 'ruby'
133
139
  },
134
140
  :error => {
135
141
  :class => error_class,
@@ -161,9 +167,28 @@ module Honeybadger
161
167
  as_json.to_json(*a)
162
168
  end
163
169
 
164
- # Determines if this notice should be ignored
170
+ # Public: Determines if error class should be ignored
171
+ #
172
+ # ignored_class_name - The name of the ignored class. May be a
173
+ # string or regexp (optional)
174
+ #
175
+ # Returns true/false with an argument, otherwise a Proc object
176
+ def ignore_by_class?(ignored_class = nil)
177
+ @ignore_by_class ||= Proc.new do |ignored_class|
178
+ case error_class
179
+ when (ignored_class.respond_to?(:name) ? ignored_class.name : ignored_class)
180
+ true
181
+ else
182
+ exception && ignored_class.is_a?(Class) && exception.class < ignored_class
183
+ end
184
+ end
185
+
186
+ ignored_class ? @ignore_by_class.call(ignored_class) : @ignore_by_class
187
+ end
188
+
189
+ # Public: Determines if this notice should be ignored
165
190
  def ignore?
166
- ignored_class_names.include?(error_class) ||
191
+ ignore.any?(&ignore_by_class?) ||
167
192
  ignore_by_filters.any? {|filter| filter.call(self) }
168
193
  end
169
194
 
@@ -192,7 +217,7 @@ module Honeybadger
192
217
  :session_data, :project_root, :url, :ignore, :ignore_by_filters,
193
218
  :notifier_name, :notifier_url, :notifier_version, :component, :action,
194
219
  :cgi_data, :environment_name, :hostname, :context, :source_extract,
195
- :source_extract_radius
220
+ :source_extract_radius, :send_request_session
196
221
 
197
222
  # Private: Arguments given in the initializer
198
223
  attr_accessor :args
@@ -308,8 +333,10 @@ module Honeybadger
308
333
  end
309
334
 
310
335
  def find_session_data
311
- self.session_data = args[:session_data] || args[:session] || rack_session || {}
312
- self.session_data = session_data[:data] if session_data[:data]
336
+ if send_request_session
337
+ self.session_data = args[:session_data] || args[:session] || rack_session || {}
338
+ self.session_data = session_data[:data] if session_data[:data]
339
+ end
313
340
  end
314
341
 
315
342
  def set_context
@@ -318,18 +345,6 @@ module Honeybadger
318
345
  self.context = nil if context.empty?
319
346
  end
320
347
 
321
- # Private: Converts the mixed class instances and class names into just names
322
- # TODO: move this into Configuration or another class
323
- def ignored_class_names
324
- ignore.collect do |string_or_class|
325
- if string_or_class.respond_to?(:name)
326
- string_or_class.name
327
- else
328
- string_or_class
329
- end
330
- end
331
- end
332
-
333
348
  def rack_env(method)
334
349
  rack_request.send(method) if rack_request
335
350
  end
@@ -348,10 +363,13 @@ module Honeybadger
348
363
  args[:rack_env]['rack.session'] if args[:rack_env]
349
364
  end
350
365
 
366
+ # Private: (Rails 3+) Adds params filters to filter list
367
+ #
368
+ # Returns nothing
351
369
  def also_use_rack_params_filters
352
- if args[:rack_env]
370
+ if cgi_data
353
371
  @params_filters ||= []
354
- @params_filters += rack_request.env["action_dispatch.parameter_filter"] || []
372
+ @params_filters += cgi_data['action_dispatch.parameter_filter'] || []
355
373
  end
356
374
  end
357
375