lib/rails/generators/hoptoad/hoptoad_generator.rb in hoptoad_notifier-2.3.11 vs lib/rails/generators/hoptoad/hoptoad_generator.rb in hoptoad_notifier-2.3.12

- old
+ new

@@ -56,19 +56,23 @@ template 'initializer.rb', 'config/initializers/hoptoad.rb' end def determine_api_key puts "Attempting to determine your API Key from Heroku..." - ENV['HOPTOAD_API_KEY'] = `heroku console 'puts ENV[%{HOPTOAD_API_KEY}]'`.split("\n").first + 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 + + def heroku_api_key + `heroku console 'puts ENV[%{HOPTOAD_API_KEY}]'`.split("\n").first end def heroku? options[:heroku] || system("grep HOPTOAD_API_KEY config/initializers/hoptoad.rb") ||