honeybadger 1.3.1 → 1.4.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.
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
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source :rubygems
4
+
5
+ gem "rails", "3.1.8"
6
+ gem "honeybadger", :path=>"../"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,161 @@
1
+ PATH
2
+ remote: /Users/josh/code/honeybadger-ruby
3
+ specs:
4
+ honeybadger (1.3.1)
5
+ activesupport
6
+ json
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.1.8)
12
+ actionpack (= 3.1.8)
13
+ mail (~> 2.3.3)
14
+ actionpack (3.1.8)
15
+ activemodel (= 3.1.8)
16
+ activesupport (= 3.1.8)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ i18n (~> 0.6)
20
+ rack (~> 1.3.6)
21
+ rack-cache (~> 1.2)
22
+ rack-mount (~> 0.8.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.0.4)
25
+ activemodel (3.1.8)
26
+ activesupport (= 3.1.8)
27
+ builder (~> 3.0.0)
28
+ i18n (~> 0.6)
29
+ activerecord (3.1.8)
30
+ activemodel (= 3.1.8)
31
+ activesupport (= 3.1.8)
32
+ arel (~> 2.2.3)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.1.8)
35
+ activemodel (= 3.1.8)
36
+ activesupport (= 3.1.8)
37
+ activesupport (3.1.8)
38
+ multi_json (>= 1.0, < 1.3)
39
+ appraisal (0.5.1)
40
+ bundler
41
+ rake
42
+ arel (2.2.3)
43
+ aruba (0.5.1)
44
+ childprocess (~> 0.3.6)
45
+ cucumber (>= 1.1.1)
46
+ rspec-expectations (>= 2.7.0)
47
+ bourne (1.1.2)
48
+ mocha (= 0.10.5)
49
+ builder (3.0.4)
50
+ capistrano (2.13.5)
51
+ highline
52
+ net-scp (>= 1.0.0)
53
+ net-sftp (>= 2.0.0)
54
+ net-ssh (>= 2.0.14)
55
+ net-ssh-gateway (>= 1.1.0)
56
+ childprocess (0.3.6)
57
+ ffi (~> 1.0, >= 1.0.6)
58
+ cucumber (1.2.1)
59
+ builder (>= 2.1.2)
60
+ diff-lcs (>= 1.1.3)
61
+ gherkin (~> 2.11.0)
62
+ json (>= 1.4.6)
63
+ diff-lcs (1.1.3)
64
+ erubis (2.7.0)
65
+ fakeweb (1.3.0)
66
+ ffi (1.2.0)
67
+ gherkin (2.11.5)
68
+ json (>= 1.4.6)
69
+ highline (1.6.15)
70
+ hike (1.2.1)
71
+ i18n (0.6.1)
72
+ json (1.7.5)
73
+ mail (2.3.3)
74
+ i18n (>= 0.4.0)
75
+ mime-types (~> 1.16)
76
+ treetop (~> 1.4.8)
77
+ metaclass (0.0.1)
78
+ mime-types (1.19)
79
+ mocha (0.10.5)
80
+ metaclass (~> 0.0.1)
81
+ multi_json (1.2.0)
82
+ net-scp (1.0.4)
83
+ net-ssh (>= 1.99.1)
84
+ net-sftp (2.0.5)
85
+ net-ssh (>= 2.0.9)
86
+ net-ssh (2.6.2)
87
+ net-ssh-gateway (1.1.0)
88
+ net-ssh (>= 1.99.1)
89
+ polyglot (0.3.3)
90
+ rack (1.3.6)
91
+ rack-cache (1.2)
92
+ rack (>= 0.4)
93
+ rack-mount (0.8.3)
94
+ rack (>= 1.0.0)
95
+ rack-protection (1.2.0)
96
+ rack
97
+ rack-ssl (1.3.2)
98
+ rack
99
+ rack-test (0.6.2)
100
+ rack (>= 1.0)
101
+ rails (3.1.8)
102
+ actionmailer (= 3.1.8)
103
+ actionpack (= 3.1.8)
104
+ activerecord (= 3.1.8)
105
+ activeresource (= 3.1.8)
106
+ activesupport (= 3.1.8)
107
+ bundler (~> 1.0)
108
+ railties (= 3.1.8)
109
+ railties (3.1.8)
110
+ actionpack (= 3.1.8)
111
+ activesupport (= 3.1.8)
112
+ rack-ssl (~> 1.3.2)
113
+ rake (>= 0.8.7)
114
+ rdoc (~> 3.4)
115
+ thor (~> 0.14.6)
116
+ rake (10.0.2)
117
+ rdoc (3.12)
118
+ json (~> 1.4)
119
+ rspec (2.12.0)
120
+ rspec-core (~> 2.12.0)
121
+ rspec-expectations (~> 2.12.0)
122
+ rspec-mocks (~> 2.12.0)
123
+ rspec-core (2.12.0)
124
+ rspec-expectations (2.12.0)
125
+ diff-lcs (~> 1.1.3)
126
+ rspec-mocks (2.12.0)
127
+ sham_rack (1.3.4)
128
+ rack
129
+ shoulda (2.11.3)
130
+ sinatra (1.3.2)
131
+ rack (~> 1.3, >= 1.3.6)
132
+ rack-protection (~> 1.2)
133
+ tilt (~> 1.3, >= 1.3.3)
134
+ sprockets (2.0.4)
135
+ hike (~> 1.2)
136
+ rack (~> 1.0)
137
+ tilt (~> 1.1, != 1.3.0)
138
+ thor (0.14.6)
139
+ tilt (1.3.3)
140
+ treetop (1.4.12)
141
+ polyglot
142
+ polyglot (>= 0.3.1)
143
+ tzinfo (0.3.35)
144
+
145
+ PLATFORMS
146
+ ruby
147
+
148
+ DEPENDENCIES
149
+ appraisal
150
+ aruba
151
+ bourne (>= 1.0)
152
+ capistrano
153
+ cucumber (~> 1.2.1)
154
+ fakeweb (~> 1.3.0)
155
+ honeybadger!
156
+ rails (= 3.1.8)
157
+ rake
158
+ rspec (~> 2.12.0)
159
+ sham_rack (~> 1.3.0)
160
+ shoulda (~> 2.11.3)
161
+ sinatra
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source :rubygems
4
+
5
+ gem "rails", "3.2.9"
6
+ gem "honeybadger", :path=>"../"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,160 @@
1
+ PATH
2
+ remote: /Users/josh/code/honeybadger-ruby
3
+ specs:
4
+ honeybadger (1.3.1)
5
+ activesupport
6
+ json
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.9)
12
+ actionpack (= 3.2.9)
13
+ mail (~> 2.4.4)
14
+ actionpack (3.2.9)
15
+ activemodel (= 3.2.9)
16
+ activesupport (= 3.2.9)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.4)
20
+ rack (~> 1.4.0)
21
+ rack-cache (~> 1.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.2.1)
24
+ activemodel (3.2.9)
25
+ activesupport (= 3.2.9)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.9)
28
+ activemodel (= 3.2.9)
29
+ activesupport (= 3.2.9)
30
+ arel (~> 3.0.2)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.9)
33
+ activemodel (= 3.2.9)
34
+ activesupport (= 3.2.9)
35
+ activesupport (3.2.9)
36
+ i18n (~> 0.6)
37
+ multi_json (~> 1.0)
38
+ appraisal (0.5.1)
39
+ bundler
40
+ rake
41
+ arel (3.0.2)
42
+ aruba (0.5.1)
43
+ childprocess (~> 0.3.6)
44
+ cucumber (>= 1.1.1)
45
+ rspec-expectations (>= 2.7.0)
46
+ bourne (1.1.2)
47
+ mocha (= 0.10.5)
48
+ builder (3.0.4)
49
+ capistrano (2.13.5)
50
+ highline
51
+ net-scp (>= 1.0.0)
52
+ net-sftp (>= 2.0.0)
53
+ net-ssh (>= 2.0.14)
54
+ net-ssh-gateway (>= 1.1.0)
55
+ childprocess (0.3.6)
56
+ ffi (~> 1.0, >= 1.0.6)
57
+ cucumber (1.2.1)
58
+ builder (>= 2.1.2)
59
+ diff-lcs (>= 1.1.3)
60
+ gherkin (~> 2.11.0)
61
+ json (>= 1.4.6)
62
+ diff-lcs (1.1.3)
63
+ erubis (2.7.0)
64
+ fakeweb (1.3.0)
65
+ ffi (1.2.0)
66
+ gherkin (2.11.5)
67
+ json (>= 1.4.6)
68
+ highline (1.6.15)
69
+ hike (1.2.1)
70
+ i18n (0.6.1)
71
+ journey (1.0.4)
72
+ json (1.7.5)
73
+ mail (2.4.4)
74
+ i18n (>= 0.4.0)
75
+ mime-types (~> 1.16)
76
+ treetop (~> 1.4.8)
77
+ metaclass (0.0.1)
78
+ mime-types (1.19)
79
+ mocha (0.10.5)
80
+ metaclass (~> 0.0.1)
81
+ multi_json (1.3.7)
82
+ net-scp (1.0.4)
83
+ net-ssh (>= 1.99.1)
84
+ net-sftp (2.0.5)
85
+ net-ssh (>= 2.0.9)
86
+ net-ssh (2.6.2)
87
+ net-ssh-gateway (1.1.0)
88
+ net-ssh (>= 1.99.1)
89
+ polyglot (0.3.3)
90
+ rack (1.4.1)
91
+ rack-cache (1.2)
92
+ rack (>= 0.4)
93
+ rack-protection (1.2.0)
94
+ rack
95
+ rack-ssl (1.3.2)
96
+ rack
97
+ rack-test (0.6.2)
98
+ rack (>= 1.0)
99
+ rails (3.2.9)
100
+ actionmailer (= 3.2.9)
101
+ actionpack (= 3.2.9)
102
+ activerecord (= 3.2.9)
103
+ activeresource (= 3.2.9)
104
+ activesupport (= 3.2.9)
105
+ bundler (~> 1.0)
106
+ railties (= 3.2.9)
107
+ railties (3.2.9)
108
+ actionpack (= 3.2.9)
109
+ activesupport (= 3.2.9)
110
+ rack-ssl (~> 1.3.2)
111
+ rake (>= 0.8.7)
112
+ rdoc (~> 3.4)
113
+ thor (>= 0.14.6, < 2.0)
114
+ rake (10.0.2)
115
+ rdoc (3.12)
116
+ json (~> 1.4)
117
+ rspec (2.12.0)
118
+ rspec-core (~> 2.12.0)
119
+ rspec-expectations (~> 2.12.0)
120
+ rspec-mocks (~> 2.12.0)
121
+ rspec-core (2.12.0)
122
+ rspec-expectations (2.12.0)
123
+ diff-lcs (~> 1.1.3)
124
+ rspec-mocks (2.12.0)
125
+ sham_rack (1.3.4)
126
+ rack
127
+ shoulda (2.11.3)
128
+ sinatra (1.3.3)
129
+ rack (~> 1.3, >= 1.3.6)
130
+ rack-protection (~> 1.2)
131
+ tilt (~> 1.3, >= 1.3.3)
132
+ sprockets (2.2.2)
133
+ hike (~> 1.2)
134
+ multi_json (~> 1.0)
135
+ rack (~> 1.0)
136
+ tilt (~> 1.1, != 1.3.0)
137
+ thor (0.16.0)
138
+ tilt (1.3.3)
139
+ treetop (1.4.12)
140
+ polyglot
141
+ polyglot (>= 0.3.1)
142
+ tzinfo (0.3.35)
143
+
144
+ PLATFORMS
145
+ ruby
146
+
147
+ DEPENDENCIES
148
+ appraisal
149
+ aruba
150
+ bourne (>= 1.0)
151
+ capistrano
152
+ cucumber (~> 1.2.1)
153
+ fakeweb (~> 1.3.0)
154
+ honeybadger!
155
+ rails (= 3.2.9)
156
+ rake
157
+ rspec (~> 2.12.0)
158
+ sham_rack (~> 1.3.0)
159
+ shoulda (~> 2.11.3)
160
+ sinatra
data/honeybadger.gemspec CHANGED
@@ -1,66 +1,72 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.specification_version = 2 if s.respond_to? :specification_version=
3
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
3
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'honeybadger'
7
- s.version = '1.3.1'
8
- s.date = '2012-10-24'
7
+ s.version = '1.4.0'
8
+ s.date = '2012-12-14'
9
9
 
10
- s.summary = "Error reports you can be happy about."
11
- s.description = "Make managing application errors a more pleasant experience."
10
+ s.summary = 'Error reports you can be happy about.'
11
+ s.description = 'Make managing application errors a more pleasant experience.'
12
12
 
13
- s.authors = ["Joshua Wood"]
13
+ s.authors = ['Joshua Wood']
14
14
  s.email = 'josh@honeybadger.io'
15
15
  s.homepage = 'http://www.honeybadger.io'
16
16
 
17
17
  s.require_paths = %w[lib]
18
18
 
19
- s.rdoc_options = ["--charset=UTF-8", "--markup tomdoc"]
19
+ s.rdoc_options = ['--charset=UTF-8', '--markup tomdoc']
20
20
  s.extra_rdoc_files = %w[README.md MIT-LICENSE]
21
21
 
22
- s.add_dependency("json")
23
- s.add_dependency("activesupport")
22
+ s.add_dependency('json')
23
+ s.add_dependency('activesupport')
24
24
 
25
- s.add_development_dependency("actionpack", "~> 2.3.8")
26
- s.add_development_dependency("activerecord", "~> 2.3.8")
27
- s.add_development_dependency("activesupport", "~> 2.3.8")
28
- s.add_development_dependency("bourne", ">= 1.0")
29
- s.add_development_dependency("cucumber", "~> 0.10.6")
30
- s.add_development_dependency("rspec", "~> 2.6.0")
31
- s.add_development_dependency("fakeweb", "~> 1.3.0")
32
- s.add_development_dependency("sham_rack", "~> 1.3.0")
33
- s.add_development_dependency("shoulda", "~> 2.11.3")
34
- s.add_development_dependency("capistrano", "~> 2.8.0")
25
+ s.add_development_dependency('cucumber', '~> 1.2.1')
26
+ s.add_development_dependency('rspec', '~> 2.12.0')
27
+ s.add_development_dependency('fakeweb', '~> 1.3.0')
28
+ s.add_development_dependency('sham_rack', '~> 1.3.0')
29
+ s.add_development_dependency('bourne', '>= 1.0')
30
+ s.add_development_dependency('shoulda', '~> 2.11.3')
31
+ s.add_development_dependency('capistrano')
32
+ s.add_development_dependency('rake')
33
+ s.add_development_dependency('sinatra')
34
+ s.add_development_dependency('aruba')
35
+ s.add_development_dependency('appraisal')
35
36
 
36
37
  ## Leave this section as-is. It will be automatically generated from the
37
38
  ## contents of your Git repository via the gemspec task. DO NOT REMOVE
38
39
  ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
39
40
  # = MANIFEST =
40
41
  s.files = %w[
42
+ Appraisals
41
43
  Gemfile
42
44
  Gemfile.lock
43
45
  Guardfile
44
46
  MIT-LICENSE
45
47
  README.md
46
48
  Rakefile
47
- SUPPORTED_RAILS_VERSIONS
48
- TESTING.md
49
49
  features/metal.feature
50
50
  features/rack.feature
51
51
  features/rails.feature
52
52
  features/rake.feature
53
53
  features/sinatra.feature
54
- features/step_definitions/file_steps.rb
55
54
  features/step_definitions/metal_steps.rb
56
55
  features/step_definitions/rack_steps.rb
57
- features/step_definitions/rails_application_steps.rb
56
+ features/step_definitions/rails_steps.rb
58
57
  features/step_definitions/rake_steps.rb
59
58
  features/support/env.rb
60
59
  features/support/honeybadger_shim.rb.template
61
60
  features/support/rails.rb
62
61
  features/support/rake/Rakefile
63
- features/support/terminal.rb
62
+ gemfiles/rails2.3.gemfile
63
+ gemfiles/rails2.3.gemfile.lock
64
+ gemfiles/rails3.0.gemfile
65
+ gemfiles/rails3.0.gemfile.lock
66
+ gemfiles/rails3.1.gemfile
67
+ gemfiles/rails3.1.gemfile.lock
68
+ gemfiles/rails3.2.gemfile
69
+ gemfiles/rails3.2.gemfile.lock
64
70
  generators/honeybadger/honeybadger_generator.rb
65
71
  generators/honeybadger/lib/insert_commands.rb
66
72
  generators/honeybadger/lib/rake_commands.rb
data/lib/honeybadger.rb CHANGED
@@ -19,7 +19,7 @@ require 'honeybadger/sender'
19
19
  require 'honeybadger/railtie' if defined?(Rails::Railtie)
20
20
 
21
21
  module Honeybadger
22
- VERSION = '1.3.1'
22
+ VERSION = '1.4.0'
23
23
  LOG_PREFIX = "** [Honeybadger] "
24
24
 
25
25
  HEADERS = {
@@ -35,139 +35,143 @@ module Honeybadger
35
35
  # A Honeybadger configuration object. Must act like a hash and return sensible
36
36
  # values for all Honeybadger configuration options. See Honeybadger::Configuration.
37
37
  attr_writer :configuration
38
- end
39
38
 
40
- # Tell the log that the Notifier is good to go
41
- def self.report_ready
42
- write_verbose_log("Notifier #{VERSION} ready to catch errors")
43
- end
39
+ # Tell the log that the Notifier is good to go
40
+ def report_ready
41
+ write_verbose_log("Notifier #{VERSION} ready to catch errors")
42
+ end
44
43
 
45
- # Prints out the environment info to the log for debugging help
46
- def self.report_environment_info
47
- write_verbose_log("Environment Info: #{environment_info}")
48
- end
44
+ # Prints out the environment info to the log for debugging help
45
+ def report_environment_info
46
+ write_verbose_log("Environment Info: #{environment_info}")
47
+ end
49
48
 
50
- # Prints out the response body from Honeybadger for debugging help
51
- def self.report_response_body(response)
52
- write_verbose_log("Response from Honeybadger: \n#{response}")
53
- end
49
+ # Prints out the response body from Honeybadger for debugging help
50
+ def report_response_body(response)
51
+ write_verbose_log("Response from Honeybadger: \n#{response}")
52
+ end
54
53
 
55
- # Returns the Ruby version, Rails version, and current Rails environment
56
- def self.environment_info
57
- info = "[Ruby: #{RUBY_VERSION}]"
58
- info << " [#{configuration.framework}]" if configuration.framework
59
- info << " [Env: #{configuration.environment_name}]" if configuration.environment_name
60
- end
54
+ # Returns the Ruby version, Rails version, and current Rails environment
55
+ def environment_info
56
+ info = "[Ruby: #{RUBY_VERSION}]"
57
+ info << " [#{configuration.framework}]" if configuration.framework
58
+ info << " [Env: #{configuration.environment_name}]" if configuration.environment_name
59
+ end
61
60
 
62
- # Writes out the given message to the #logger
63
- def self.write_verbose_log(message)
64
- logger.info LOG_PREFIX + message if logger
65
- end
61
+ # Writes out the given message to the #logger
62
+ def write_verbose_log(message)
63
+ logger.info LOG_PREFIX + message if logger
64
+ end
66
65
 
67
- # Look for the Rails logger currently defined
68
- def self.logger
69
- self.configuration.logger
70
- end
66
+ # Look for the Rails logger currently defined
67
+ def logger
68
+ self.configuration.logger
69
+ end
71
70
 
72
- # Public: Call this method to modify defaults in your initializers.
73
- #
74
- # Examples:
75
- #
76
- # Honeybadger.configure do |config|
77
- # config.api_key = '1234567890abcdef'
78
- # config.secure = false
79
- # end
80
- #
81
- # Yields Honeybadger configuration
82
- def self.configure(silent = false)
83
- yield(configuration)
84
- self.sender = Sender.new(configuration)
85
- report_ready unless silent
86
- self.sender
87
- end
71
+ # Public: Call this method to modify defaults in your initializers.
72
+ #
73
+ # Examples:
74
+ #
75
+ # Honeybadger.configure do |config|
76
+ # config.api_key = '1234567890abcdef'
77
+ # config.secure = false
78
+ # end
79
+ #
80
+ # Yields Honeybadger configuration
81
+ def configure(silent = false)
82
+ yield(configuration)
83
+ self.sender = Sender.new(configuration)
84
+ report_ready unless silent
85
+ self.sender
86
+ end
88
87
 
89
- # Public: The configuration object.
90
- # See Honeybadger.configure
91
- #
92
- # Returns Honeybadger configuration
93
- def self.configuration
94
- @configuration ||= Configuration.new
95
- end
88
+ # Public: The configuration object.
89
+ # See Honeybadger.configure
90
+ #
91
+ # Returns Honeybadger configuration
92
+ def configuration
93
+ @configuration ||= Configuration.new
94
+ end
96
95
 
97
- # Public: Sends an exception manually using this method, even when you are not in a controller.
98
- #
99
- # exception - The exception you want to notify Honeybadger about.
100
- # options - Data that will be sent to Honeybadger.
101
- # :api_key - The API key for this project. The API key is a unique identifier
102
- # that Honeybadger uses for identification.
103
- # :error_message - The error returned by the exception (or the message you want to log).
104
- # :backtrace - A backtrace, usually obtained with +caller+.
105
- # :rack_env - The Rack environment.
106
- # :session - The contents of the user's session.
107
- # :environment_name - The application environment name.
108
- # :context - Custom hash to send
109
- #
110
- # Returns exception ID from Honeybadger on success, false on failure
111
- def self.notify(exception, options = {})
112
- send_notice(build_notice_for(exception, options))
113
- end
96
+ # Public: Sends an exception manually using this method, even when you are not in a controller.
97
+ #
98
+ # exception - The exception you want to notify Honeybadger about.
99
+ # options - Data that will be sent to Honeybadger.
100
+ # :api_key - The API key for this project. The API key is a unique identifier
101
+ # that Honeybadger uses for identification.
102
+ # :error_message - The error returned by the exception (or the message you want to log).
103
+ # :backtrace - A backtrace, usually obtained with +caller+.
104
+ # :rack_env - The Rack environment.
105
+ # :session - The contents of the user's session.
106
+ # :environment_name - The application environment name.
107
+ # :context - Custom hash to send
108
+ #
109
+ # Returns exception ID from Honeybadger on success, false on failure
110
+ def notify(exception, options = {})
111
+ send_notice(build_notice_for(exception, options))
112
+ end
114
113
 
115
- # Public: Sends the notice unless it is one of the default ignored exceptions
116
- # see Honeybadger.notify
117
- def self.notify_or_ignore(exception, opts = {})
118
- notice = build_notice_for(exception, opts)
119
- send_notice(notice) unless notice.ignore?
120
- end
114
+ # Public: Sends the notice unless it is one of the default ignored exceptions
115
+ # see Honeybadger.notify
116
+ def notify_or_ignore(exception, opts = {})
117
+ notice = build_notice_for(exception, opts)
118
+ send_notice(notice) unless notice.ignore?
119
+ end
121
120
 
122
- def self.build_lookup_hash_for(exception, options = {})
123
- notice = build_notice_for(exception, options)
121
+ def build_lookup_hash_for(exception, options = {})
122
+ notice = build_notice_for(exception, options)
124
123
 
125
- result = {}
126
- result[:action] = notice.action rescue nil
127
- result[:component] = notice.component rescue nil
128
- result[:error_class] = notice.error_class if notice.error_class
129
- result[:environment_name] = 'production'
124
+ result = {}
125
+ result[:action] = notice.action rescue nil
126
+ result[:component] = notice.component rescue nil
127
+ result[:error_class] = notice.error_class if notice.error_class
128
+ result[:environment_name] = 'production'
130
129
 
131
- unless notice.backtrace.lines.empty?
132
- result[:file] = notice.backtrace.lines.first.file
133
- result[:line_number] = notice.backtrace.lines.first.number
134
- end
130
+ unless notice.backtrace.lines.empty?
131
+ result[:file] = notice.backtrace.lines.first.file
132
+ result[:line_number] = notice.backtrace.lines.first.number
133
+ end
135
134
 
136
- result
137
- end
135
+ result
136
+ end
138
137
 
139
- def self.context(hash = {})
140
- Thread.current[:honeybadger_context] ||= {}
141
- Thread.current[:honeybadger_context].merge!(hash)
142
- self
143
- end
138
+ def context(hash = {})
139
+ Thread.current[:honeybadger_context] ||= {}
140
+ Thread.current[:honeybadger_context].merge!(hash)
141
+ self
142
+ end
144
143
 
145
- def self.clear!
146
- Thread.current[:honeybadger_context] = nil
147
- end
144
+ def clear!
145
+ Thread.current[:honeybadger_context] = nil
146
+ end
148
147
 
149
- private
148
+ private
150
149
 
151
- def self.send_notice(notice)
152
- if configuration.public?
153
- sender.send_to_honeybadger(notice.to_json)
150
+ def send_notice(notice)
151
+ if configuration.public?
152
+ if configuration.async?
153
+ configuration.async.call(notice)
154
+ else
155
+ notice.deliver
156
+ end
157
+ end
154
158
  end
155
- end
156
159
 
157
- def self.build_notice_for(exception, opts = {})
158
- exception = unwrap_exception(exception)
159
- opts = opts.merge(:exception => exception) if exception.is_a?(Exception)
160
- opts = opts.merge(exception.to_hash) if exception.respond_to?(:to_hash)
161
- Notice.new(configuration.merge(opts))
162
- end
160
+ def build_notice_for(exception, opts = {})
161
+ exception = unwrap_exception(exception)
162
+ opts = opts.merge(:exception => exception) if exception.is_a?(Exception)
163
+ opts = opts.merge(exception.to_hash) if exception.respond_to?(:to_hash)
164
+ Notice.new(configuration.merge(opts))
165
+ end
163
166
 
164
- def self.unwrap_exception(exception)
165
- if exception.respond_to?(:original_exception)
166
- exception.original_exception
167
- elsif exception.respond_to?(:continued_exception)
168
- exception.continued_exception
169
- else
170
- exception
167
+ def unwrap_exception(exception)
168
+ if exception.respond_to?(:original_exception)
169
+ exception.original_exception
170
+ elsif exception.respond_to?(:continued_exception)
171
+ exception.continued_exception
172
+ else
173
+ exception
174
+ end
171
175
  end
172
176
  end
173
177
  end