Skip to content

Commit 7950400

Browse files
committed
Removing dependency on ActiveSupport.
ActiveSupport (particularly the core extensions) can play havoc with otherwise well-written applications that were not developed using ActiveSupport. Since Honeybadger claims support for non-Rails frameworks, it makes little sense to include ActiveSupport and potentially cause those applications to fail.
1 parent f503e44 commit 7950400

25 files changed

+400
-314
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ rvm:
44
- 1.9.2
55
- 1.9.3
66
before_script: rake appraisal:install
7-
script: rake appraisal:rails2.3 test
7+
script:
8+
- rake appraisal:rack test
9+
- rake appraisal:rails2.3 test

Appraisals

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
appraise 'rack' do
2+
gem 'rack'
3+
gem 'honeybadger', :path => '../'
4+
end
5+
16
appraise 'rails2.3' do
27
gem 'rails', '2.3.14'
38
gem 'rake', '0.9.5'

Gemfile.lock

-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ PATH
22
remote: .
33
specs:
44
honeybadger (1.5.0)
5-
activesupport
65
json
76

87
GEM
98
remote: http://rubygems.org/
109
specs:
11-
activesupport (3.2.11)
12-
i18n (~> 0.6)
13-
multi_json (~> 1.0)
1410
appraisal (0.5.1)
1511
bundler
1612
rake
@@ -40,12 +36,10 @@ GEM
4036
gherkin (2.11.5)
4137
json (>= 1.4.6)
4238
highline (1.6.13)
43-
i18n (0.6.1)
4439
json (1.7.3)
4540
metaclass (0.0.1)
4641
mocha (0.10.5)
4742
metaclass (~> 0.0.1)
48-
multi_json (1.5.0)
4943
net-scp (1.0.4)
5044
net-ssh (>= 1.99.1)
5145
net-sftp (2.0.5)

features/rack.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Feature: Use the notifier in a plain Rack app
1717
end
1818
"""
1919
When I perform a Rack request to "http://example.com:123/test/index?param=value"
20-
Then I should receive a Honeybadger notification
20+
Then I should receive a Honeybadger notification for rack
2121

2222
Scenario: Ignore user agents
2323
Given the following Rack app:

features/sinatra.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ Feature: Use the notifier in a Sinatra app
2323
app = FontaneApp
2424
"""
2525
When I perform a Rack request to "http://example.com:123/test/index?param=value"
26-
Then I should receive a Honeybadger notification
26+
Then I should receive a Honeybadger notification for rack
2727

features/step_definitions/metal_steps.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
When /^I define a Metal endpoint called "([^\"]*)":$/ do |class_name, definition|
22
FileUtils.mkdir_p(File.join(rails_root, 'app', 'metal'))
3-
file_name = File.join(rails_root, 'app', 'metal', "#{class_name.underscore}.rb")
3+
file_name = File.join(rails_root, 'app', 'metal', "#{class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase}.rb")
44
File.open(file_name, "w") do |file|
55
file.puts "class #{class_name}"
66
file.puts definition
@@ -16,7 +16,7 @@
1616
routes = routes[0..-2] + [rack_route, routes[-1]]
1717
File.open(routesrb, "w") do |f|
1818
f.puts "$:<< '#{LOCAL_RAILS_ROOT}'"
19-
f.puts "require 'app/metal/#{class_name.underscore}'"
19+
f.puts "require 'app/metal/#{class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase}'"
2020
routes.each do |route_line|
2121
f.puts route_line
2222
end

features/step_definitions/rails_steps.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'uri'
2-
require 'active_support/core_ext'
32

43
When /^I generate a new Rails application$/ do
54
rails_create_command = rails2? ? 'rails rails_root' :
@@ -92,7 +91,7 @@
9291
end
9392

9493
Then /^the request\s?(url|component|action|params|session|cgi_data|context)? should( not)? contain "([^\"]*)"$/ do |key, negate, expected|
95-
notice = all_output.match(/Notice: ({.+})/) ? JSON.parse(Regexp.last_match(1)) : {}
94+
notice = all_output.match(/Notice: (\{.+\})/) ? JSON.parse(Regexp.last_match(1)) : {}
9695
hash = key ? notice['request'][key.strip] : notice['request']
9796
hash.to_s.send(negate ? :should_not : :should, match(/#{Regexp.escape(expected)}/))
9897
end
@@ -103,7 +102,7 @@
103102

104103
When /^I define a( metal)? response for "([^\"]*)":$/ do |metal, controller_and_action, definition|
105104
controller_class_name, action = controller_and_action.split('#')
106-
controller_name = controller_class_name.underscore
105+
controller_name = controller_class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase
107106
controller_file_name = File.join(rails_root, 'app', 'controllers', "#{controller_name}.rb")
108107
File.open(controller_file_name, "w") do |file|
109108
file.puts "class #{controller_class_name} < #{ (metal && !rails2?) ? 'ActionController::Metal' : 'ApplicationController'}"

gemfiles/rack.gemfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was generated by Appraisal
2+
3+
source :rubygems
4+
5+
gem "rack"
6+
gem "honeybadger", :path=>"../"
7+
8+
gemspec :path=>"../"

gemfiles/rack.gemfile.lock

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
PATH
2+
remote: /Users/pvande/Projects/honeybadger-ruby
3+
specs:
4+
honeybadger (1.5.0)
5+
json
6+
7+
GEM
8+
remote: http://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+
gherkin (2.11.5)
37+
json (>= 1.4.6)
38+
highline (1.6.15)
39+
json (1.7.6)
40+
metaclass (0.0.1)
41+
mocha (0.13.0)
42+
metaclass (~> 0.0.1)
43+
net-scp (1.0.4)
44+
net-ssh (>= 1.99.1)
45+
net-sftp (2.0.5)
46+
net-ssh (>= 2.0.9)
47+
net-ssh (2.6.3)
48+
net-ssh-gateway (1.1.0)
49+
net-ssh (>= 1.99.1)
50+
rack (1.4.4)
51+
rack-protection (1.3.2)
52+
rack
53+
rake (10.0.3)
54+
rspec (2.12.0)
55+
rspec-core (~> 2.12.0)
56+
rspec-expectations (~> 2.12.0)
57+
rspec-mocks (~> 2.12.0)
58+
rspec-core (2.12.2)
59+
rspec-expectations (2.12.1)
60+
diff-lcs (~> 1.1.3)
61+
rspec-mocks (2.12.1)
62+
sham_rack (1.3.4)
63+
rack
64+
shoulda (2.11.3)
65+
sinatra (1.3.3)
66+
rack (~> 1.3, >= 1.3.6)
67+
rack-protection (~> 1.2)
68+
tilt (~> 1.3, >= 1.3.3)
69+
tilt (1.3.3)
70+
71+
PLATFORMS
72+
ruby
73+
74+
DEPENDENCIES
75+
appraisal
76+
aruba
77+
bourne (>= 1.0)
78+
capistrano
79+
cucumber (~> 1.2.1)
80+
fakeweb (~> 1.3.0)
81+
honeybadger!
82+
rack
83+
rake
84+
rspec (~> 2.12.0)
85+
sham_rack (~> 1.3.0)
86+
shoulda (~> 2.11.3)
87+
sinatra

gemfiles/rails2.3.gemfile.lock

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
PATH
2-
remote: /Users/josh/code/honeybadger-ruby
2+
remote: /Users/pvande/Projects/honeybadger-ruby
33
specs:
44
honeybadger (1.5.0)
5-
activesupport
65
json
76

87
GEM

gemfiles/rails3.0.gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PATH
2-
remote: /Users/josh/code/honeybadger-ruby
2+
remote: /Users/pvande/Projects/honeybadger-ruby
33
specs:
44
honeybadger (1.5.0)
55
activesupport

gemfiles/rails3.1.gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PATH
2-
remote: /Users/josh/code/honeybadger-ruby
2+
remote: /Users/pvande/Projects/honeybadger-ruby
33
specs:
44
honeybadger (1.5.0)
55
activesupport

gemfiles/rails3.2.gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PATH
2-
remote: /Users/josh/code/honeybadger-ruby
2+
remote: /Users/pvande/Projects/honeybadger-ruby
33
specs:
44
honeybadger (1.5.0)
55
activesupport

gemfiles/rails4.gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ GIT
4141
thor (>= 0.15.4, < 2.0)
4242

4343
PATH
44-
remote: /Users/josh/code/honeybadger-ruby
44+
remote: /Users/pvande/Projects/honeybadger-ruby
4545
specs:
4646
honeybadger (1.5.0)
4747
activesupport

generators/honeybadger/honeybadger_generator.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ def api_key_expression
4949
def determine_api_key
5050
puts "Attempting to determine your API Key from Heroku..."
5151
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
5356
puts "... Failed."
5457
puts "WARNING: We were unable to detect the Honeybadger API Key from your Heroku environment."
5558
puts "Your Heroku application environment may not be configured correctly."
5659
puts "Have you configured multiple Heroku apps? Try using the '--app [app name]' flag." unless options[:app]
5760
exit 1
58-
else
59-
puts "... Done."
60-
puts "Heroku's Honeybadger API Key is '#{ENV['HONEYBADGER_API_KEY']}'"
6161
end
6262
end
6363

@@ -67,7 +67,7 @@ def heroku_var(var, app_name = nil)
6767
end
6868

6969
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/ }
7171
end
7272

7373
def heroku?

honeybadger.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
2020
s.extra_rdoc_files = %w[README.md MIT-LICENSE]
2121

2222
s.add_dependency('json')
23-
s.add_dependency('activesupport')
2423

2524
s.add_development_dependency('cucumber', '~> 1.2.1')
2625
s.add_development_dependency('rspec', '~> 2.12.0')

lib/honeybadger.rb

+2-10
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
require 'net/https'
33
require 'json'
44

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
12-
135
require 'honeybadger/configuration'
146
require 'honeybadger/backtrace'
157
require 'honeybadger/notice'
@@ -128,8 +120,8 @@ def build_lookup_hash_for(exception, options = {})
128120
result[:environment_name] = 'production'
129121

130122
unless notice.backtrace.lines.empty?
131-
result[:file] = notice.backtrace.lines.first.file
132-
result[:line_number] = notice.backtrace.lines.first.number
123+
result[:file] = notice.backtrace.lines[0].file
124+
result[:line_number] = notice.backtrace.lines[0].number
133125
end
134126

135127
result

lib/honeybadger/sender.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def send_to_honeybadger(notice)
3939
http = setup_http_connection
4040
headers = HEADERS
4141

42-
headers.merge!({ 'X-API-Key' => api_key}) if api_key.present?
42+
headers.merge!({ 'X-API-Key' => api_key}) unless api_key.nil?
4343

4444
response = begin
4545
http.post(url.path, data, headers)

lib/honeybadger/shared_tasks.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ def heroku_var(var, app_name = nil)
3535
end
3636

3737
heroku_rails_env = heroku_var('RAILS_ENV', ENV['APP'])
38-
heroku_api_key = heroku_var('HONEYBADGER_API_KEY', ENV['APP']).split.find {|x| x unless x.blank?} ||
39-
Honeybadger.configuration.api_key
38+
heroku_api_key = heroku_var('HONEYBADGER_API_KEY', ENV['APP']).split.find(Honeybadger.configuration.api_key) {|x| x =~ /\S/ }
4039

41-
if heroku_api_key.blank? || heroku_rails_env.blank?
40+
unless heroku_api_key =~ /\S/ && heroku_rails_env =~ /\S/
4241
puts "WARNING: We were unable to detect the configuration from your Heroku environment."
4342
puts "Your Heroku application environment may not be configured correctly."
4443
puts "Have you configured multiple Heroku apps? Try using APP=[app name]'" unless ENV['APP']

lib/honeybadger_tasks.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'net/http'
22
require 'uri'
3-
require 'active_support'
43

54
# Capistrano tasks for notifying Honeybadger of deploys
65
module HoneybadgerTasks
@@ -17,12 +16,12 @@ module HoneybadgerTasks
1716
# Returns true or false
1817
def self.deploy(opts = {})
1918
api_key = opts.delete(:api_key) || Honeybadger.configuration.api_key
20-
if api_key.blank?
19+
unless api_key =~ /\S/
2120
puts "I don't seem to be configured with an API key. Please check your configuration."
2221
return false
2322
end
2423

25-
if opts[:environment].blank?
24+
unless opts[:environment] =~ /\S/
2625
puts "I don't know to which environment you are deploying (use the TO=production option)."
2726
return false
2827
end

lib/rails/generators/honeybadger/honeybadger_generator.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ def generate_initializer
5959
def determine_api_key
6060
puts "Attempting to determine your API Key from Heroku..."
6161
ENV['HONEYBADGER_API_KEY'] = heroku_api_key
62-
if ENV['HONEYBADGER_API_KEY'].blank?
62+
if ENV['HONEYBADGER_API_KEY'] =~ /\S/
63+
puts "... Done."
64+
puts "Heroku's Honeybadger API Key is '#{ENV['HONEYBADGER_API_KEY']}'"
65+
else
6366
puts "... Failed."
6467
puts "WARNING: We were unable to detect the Honeybadger API Key from your Heroku environment."
6568
puts "Your Heroku application environment may not be configured correctly."
6669
puts "Have you configured multiple Heroku apps? Try using the '--app [app name]' flag." unless options[:app]
6770
exit 1
68-
else
69-
puts "... Done."
70-
puts "Heroku's Honeybadger API Key is '#{ENV['HONEYBADGER_API_KEY']}'"
7171
end
7272
end
7373

@@ -77,7 +77,7 @@ def heroku_var(var, app_name = nil)
7777
end
7878

7979
def heroku_api_key
80-
heroku_var("HONEYBADGER_API_KEY", options[:app]).split.find {|x| x unless x.blank?}
80+
heroku_var("HONEYBADGER_API_KEY", options[:app]).split.find {|x| x =~ /\S/ }
8181
end
8282

8383
def heroku?

test/test_helper.rb

-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
require 'bourne'
66
require 'rack'
77

8-
require 'action_controller'
9-
require 'action_controller/test_process'
10-
require 'active_record'
11-
require 'active_support'
12-
138
require 'honeybadger'
149

1510
class BacktracedException < Exception

0 commit comments

Comments
 (0)