api_key_expression()
click to toggle source
def api_key_expression
s = if options[:api_key]
"'#{options[:api_key]}'"
elsif options[:heroku]
"ENV['HOPTOAD_API_KEY']"
end
end
append_capistrano_hook()
click to toggle source
def append_capistrano_hook
if File.exists?('config/deploy.rb') && File.exists?('Capfile')
append_file('config/deploy.rb', "
require './config/boot'
require 'hoptoad_notifier/capistrano'
")
end
end
determine_api_key()
click to toggle source
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?
puts "... Failed."
puts "WARNING: We were unable to detect the Hoptoad API Key from your Heroku environment."
puts "Your Heroku application environment may not be configured correctly."
exit 1
else
puts "... Done."
puts "Heroku's Hoptoad API Key is '#{ENV['HOPTOAD_API_KEY']}'"
end
end
ensure_plugin_is_not_present()
click to toggle source
def ensure_plugin_is_not_present
if plugin_is_present?
puts "You must first remove the hoptoad_notifier plugin. Please run: script/plugin remove hoptoad_notifier"
exit
end
end
generate_initializer()
click to toggle source
def generate_initializer
template 'initializer.rb', 'config/initializers/hoptoad.rb'
end
heroku?()
click to toggle source
def heroku?
options[:heroku] ||
system("grep HOPTOAD_API_KEY config/initializers/hoptoad.rb") ||
system("grep HOPTOAD_API_KEY config/environment.rb")
end
heroku_api_key()
click to toggle source
def heroku_api_key
%xheroku console 'puts ENV[%{HOPTOAD_API_KEY}]'`.split("\n").first
end
plugin_is_present?()
click to toggle source
def plugin_is_present?
File.exists?('vendor/plugins/hoptoad_notifier')
end
test_hoptoad()
click to toggle source
def test_hoptoad
puts run("rake hoptoad:test --trace")
end