Skip to content
Browse files

get rid of activesupport once and for all

  • Loading branch information...
1 parent 327ebe1 commit fb042d7eaa19589adf32d77b76a357ab6656893c @shime shime committed Jun 25, 2013
View
1 airbrake.gemspec
@@ -14,7 +14,6 @@ Gem::Specification.new do |s|
s.test_files = Dir.glob("{test,spec,features}/**/*")
s.add_runtime_dependency("builder")
- s.add_runtime_dependency("activesupport")
s.add_runtime_dependency("json")
s.add_development_dependency("bourne", "~> 1.4.0")
View
10 generators/airbrake/airbrake_generator.rb
@@ -49,14 +49,14 @@ def api_key_expression
def determine_api_key
puts "Attempting to determine your API Key from Heroku..."
ENV['HOPTOAD_API_KEY'] = heroku_api_key
- if ENV['HOPTOAD_API_KEY'].blank?
+ if ENV['HOPTOAD_API_KEY'] =~ /\S/
+ puts "... Done."
+ puts "Heroku's Airbrake API Key is '#{ENV['HOPTOAD_API_KEY']}'"
+ else
puts "... Failed."
puts "WARNING: We were unable to detect the Airbrake API Key from your Heroku environment."
puts "Your Heroku application environment may not be configured correctly."
exit 1
- else
- puts "... Done."
- puts "Heroku's Airbrake API Key is '#{ENV['HOPTOAD_API_KEY']}'"
end
end
@@ -66,7 +66,7 @@ def heroku_var(var,app_name = nil)
end
def heroku_api_key
- heroku_var("(hoptoad|airbrake)_api_key",options[:app]).split.find {|x| x unless x.blank?}
+ heroku_var("(hoptoad|airbrake)_api_key",options[:app]).split.find {|x| x =~ /\S/ }
end
def heroku?
View
8 lib/airbrake.rb
@@ -8,14 +8,6 @@
require 'rubygems'
require 'logger'
-begin
- require 'active_support/core_ext/object/blank'
-rescue
- require 'activesupport'
- require 'activesupport/core_ext'
-end
-
-
require 'airbrake/version'
require 'airbrake/configuration'
require 'airbrake/notice'
View
6 lib/airbrake/configuration.rb
@@ -113,7 +113,7 @@ class Configuration
attr_reader :user_attributes
# Only used for JSON API
- attr_accessor :project_id
+ attr_reader :project_id
# Setting this to true will use the CollectingSender instead of
# the default one which will cause storing the last notice locally
@@ -315,6 +315,10 @@ def local_cert_path
File.expand_path(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__)
end
+ def project_id=(project_id)
+ @project_id = "#{project_id}"
+ end
+
private
# Determines what port should we use for sending notices.
# @return [Fixnum] Returns 443 if you've set secure to true in your
View
39 lib/airbrake/notice.rb
@@ -124,15 +124,15 @@ def initialize(args)
self.action = args[:action] || parameters['action']
self.environment_name = args[:environment_name]
- self.cgi_data = args[:cgi_data] || args[:rack_env]
+ self.cgi_data = args[:cgi_data] || args[:rack_env] || {}
self.backtrace = Backtrace.parse(exception_attribute(:backtrace, caller), :filters => self.backtrace_filters)
self.error_class = exception_attribute(:error_class) {|exception| exception.class.name }
self.error_message = exception_attribute(:error_message, 'Notification') do |exception|
"#{exception.class.name}: #{args[:error_message] || exception.message}"
end
self.hostname = local_hostname
- self.user = args[:user]
+ self.user = args[:user] || {}
also_use_rack_params_filters
find_session_data
@@ -164,27 +164,22 @@ def to_xml
end
end
end
- if url ||
- controller ||
- action ||
- !parameters.blank? ||
- !cgi_data.blank? ||
- !session_data.blank?
+ if request_present?
notice.request do |request|
request.url(url)
request.component(controller)
request.action(action)
- unless parameters.blank?
+ unless parameters.empty?
request.params do |params|
xml_vars_for(params, parameters)
end
end
- unless session_data.blank?
+ unless session_data.empty?
request.session do |session|
xml_vars_for(session, session_data)
end
end
- unless cgi_data.blank?
+ unless cgi_data.empty?
request.tag!("cgi-data") do |cgi_datum|
xml_vars_for(cgi_datum, cgi_data)
end
@@ -196,14 +191,14 @@ def to_xml
env.tag!("environment-name", environment_name)
env.tag!("hostname", hostname)
end
- unless user.blank?
+ unless user.empty?
notice.tag!("current-user") do |u|
user.each do |attr, value|
u.tag!(attr.to_s, value)
end
end
end
- unless framework.blank?
+ if framework =~ /\S/
notice.tag!("framework", framework)
end
end
@@ -229,25 +224,25 @@ def to_json
end
}],
'context' => {}.tap do |hash|
- if url || controller || action || !parameters.blank? || !cgi_data.blank? || !session_data.blank?
+ if request_present?
hash['url'] = url
hash['component'] = controller
hash['action'] = action
hash['rootDirectory'] = File.dirname(project_root)
hash['environment'] = environment_name
end
end.tap do |hash|
- next if user.blank?
+ next if user.empty?
hash['userId'] = user[:id]
hash['userName'] = user[:name]
hash['userEmail'] = user[:email]
end
}.tap do |hash|
- hash['environment'] = cgi_data unless cgi_data.blank?
- hash['params'] = parameters unless parameters.blank?
- hash['session'] = session_data unless session_data.blank?
+ hash['environment'] = cgi_data unless cgi_data.empty?
+ hash['params'] = parameters unless parameters.empty?
+ hash['session'] = session_data unless session_data.empty?
end.to_json
end
@@ -274,6 +269,14 @@ def [](method)
private
+ def request_present?
+ url ||
+ controller ||
+ action ||
+ !parameters.empty? ||
+ !cgi_data.empty? ||
+ !session_data.empty?
+ end
# Gets a property named +attribute+ of an exception, either from an actual
# exception or a hash.
View
2 lib/airbrake/sender.rb
@@ -174,7 +174,7 @@ def setup_http_connection
def json_api_enabled?
!!(host =~ /collect.airbrake.io/) &&
- project_id.present?
+ project_id =~ /\S/
end
end
View
4 lib/airbrake_tasks.rb
@@ -15,12 +15,12 @@ module AirbrakeTasks
# @option opts [String] :local_username Who is deploying
def self.deploy(opts = {})
api_key = opts.delete(:api_key) || Airbrake.configuration.api_key
- if api_key.blank?
+ unless api_key =~ /\S/
puts "I don't seem to be configured with an API key. Please check your configuration."
return false
end
- if opts[:rails_env].blank?
+ unless opts[:rails_env] =~ /\S/
puts "I don't know to which Rails environment you are deploying (use the TO=production option)."
return false
end
View
10 lib/rails/generators/airbrake/airbrake_generator.rb
@@ -72,14 +72,14 @@ def generate_initializer
def determine_api_key
puts "Attempting to determine your API Key from Heroku..."
ENV['AIRBRAKE_API_KEY'] = heroku_api_key
- if ENV['AIRBRAKE_API_KEY'].blank?
+ if ENV['AIRBRAKE_API_KEY'] =~ /\S/
+ puts "... Done."
+ puts "Heroku's Airbrake API Key is '#{ENV['AIRBRAKE_API_KEY']}'"
+ else
puts "... Failed."
puts "WARNING: We were unable to detect the Airbrake API Key from your Heroku environment."
puts "Your Heroku application environment may not be configured correctly."
exit 1
- else
- puts "... Done."
- puts "Heroku's Airbrake API Key is '#{ENV['AIRBRAKE_API_KEY']}'"
end
end
@@ -89,7 +89,7 @@ def heroku_var(var,app_name = nil)
end
def heroku_api_key
- heroku_var("AIRBRAKE_API_KEY",options[:app]).split.find {|x| x unless x.blank?}
+ heroku_var("AIRBRAKE_API_KEY",options[:app]).split.find {|x| x if x =~ /\S/}
end
def secure?
View
2 test/catcher_test.rb
@@ -36,7 +36,7 @@ def ignore(exception_class)
def assert_sent_hash(hash, xpath)
hash.each do |key, value|
next if key.match(/^airbrake\./) || # We added this key.
- hash[key].blank?
+ hash[key] !~ /\S/
element_xpath = "#{xpath}/var[@key = '#{key}']"
if value.respond_to?(:to_hash)

4 comments on commit fb042d7

@benarent

woot woot die 🎯 activesupport.

Time for a version bump yet?

@shime
shime commented on fb042d7 Jun 26, 2013

😸

I was planning on releasing a new version after #218, #219 and #127 are closed. What do you think?

@benarent

Sounds good ~ great bunch of updates.

🍰

@iGEL
iGEL commented on fb042d7 Aug 22, 2013

Thank you! I will update the gem our non rails app tomorrow. 👍

Please sign in to comment.
Something went wrong with that request. Please try again.