lib/appsignal/cli/install.rb in appsignal-2.1.0.alpha.3 vs lib/appsignal/cli/install.rb in appsignal-2.1.0.beta.1
- old
+ new
@@ -1,16 +1,16 @@
-require 'erb'
-require 'ostruct'
-require 'io/console'
-require 'appsignal/demo'
+require "erb"
+require "ostruct"
+require "io/console"
+require "appsignal/demo"
module Appsignal
class CLI
class Install
extend CLI::Helpers
- EXCLUDED_ENVIRONMENTS = ['test'].freeze
+ EXCLUDED_ENVIRONMENTS = ["test"].freeze
class << self
def run(push_api_key)
puts
puts colorize "#######################################", :green
@@ -19,37 +19,37 @@
puts colorize "## Need help? support@appsignal.com ##", :green
puts colorize "## Docs? docs.appsignal.com ##", :green
puts colorize "#######################################", :green
puts
unless push_api_key
- puts colorize 'Problem encountered:', :red
- puts ' No push API key entered.'
- puts ' - Sign up for AppSignal and follow the instructions'
+ puts colorize "Problem encountered:", :red
+ puts " No push API key entered."
+ puts " - Sign up for AppSignal and follow the instructions"
puts " - Already signed up? Click 'New app' on the account overview page"
puts
- puts colorize 'Exiting installer...', :red
+ puts colorize "Exiting installer...", :red
return
end
config = new_config
config[:push_api_key] = push_api_key
- print 'Validating API key'
+ print "Validating API key"
periods
puts
begin
auth_check = Appsignal::AuthCheck.new(config)
- unless auth_check.perform == '200'
+ unless auth_check.perform == "200"
puts "\n API key '#{config[:push_api_key]}' is not valid, please get a new one on https://appsignal.com"
return
end
rescue => e
puts " There was an error validating your API key:"
puts colorize "'#{e}'", :red
puts " Please try again"
return
end
- puts colorize ' API key valid!', :green
+ puts colorize " API key valid!", :green
puts
if installed_frameworks.include?(:rails)
install_for_rails(config)
elsif installed_frameworks.include?(:padrino)
@@ -62,13 +62,13 @@
puts "We could not detect which framework you are using. We'd be very grateful if you email us on support@appsignal.com with information about your setup."
end
end
def install_for_rails(config)
- require File.expand_path(File.join(Dir.pwd, 'config/application.rb'))
+ require File.expand_path(File.join(Dir.pwd, "config/application.rb"))
- puts 'Installing for Ruby on Rails'
+ puts "Installing for Ruby on Rails"
config[:name] = Rails.application.class.parent_name
name_overwritten = yes_or_no(" Your app's name is: '#{config[:name]}' \n Do you want to change how this is displayed in AppSignal? (y/n): ")
puts
@@ -80,14 +80,14 @@
configure(config, rails_environments, name_overwritten)
done_notice
end
def install_for_sinatra(config)
- puts 'Installing for Sinatra'
- config[:name] = required_input(' Enter application name: ')
+ puts "Installing for Sinatra"
+ config[:name] = required_input(" Enter application name: ")
puts
- configure(config, ['development', 'production', 'staging'], true)
+ configure(config, ["development", "production", "staging"], true)
puts "Finish Sinatra configuration"
puts " Sinatra requires some manual configuration."
puts " Add this line beneath require 'sinatra':"
puts
@@ -98,14 +98,14 @@
press_any_key
done_notice
end
def install_for_padrino(config)
- puts 'Installing for Padrino'
- config[:name] = required_input(' Enter application name: ')
+ puts "Installing for Padrino"
+ config[:name] = required_input(" Enter application name: ")
puts
- configure(config, ['development', 'production', 'staging'], true)
+ configure(config, ["development", "production", "staging"], true)
puts "Finish Padrino installation"
puts " Padrino requires some manual configuration."
puts " After installing the gem, add the following line to /config/boot.rb:"
puts
@@ -116,32 +116,32 @@
press_any_key
done_notice
end
def install_for_grape(config)
- puts 'Installing for Grape'
+ puts "Installing for Grape"
- config[:name] = required_input(' Enter application name: ')
+ config[:name] = required_input(" Enter application name: ")
puts
- configure(config, ['development', 'production', 'staging'], true)
+ configure(config, ["development", "production", "staging"], true)
puts "Manual Grape configuration needed"
puts " See the installation instructions at:"
puts " http://docs.appsignal.com/getting-started/supported-frameworks.html#grape"
press_any_key
done_notice
end
def install_for_capistrano
- capfile = File.join(Dir.pwd, 'Capfile')
+ capfile = File.join(Dir.pwd, "Capfile")
return unless File.exist?(capfile)
return if File.read(capfile) =~ %r{require ['|"]appsignal/capistrano}
- puts 'Installing for Capistrano'
- print ' Adding AppSignal integration to Capfile'
- File.open(capfile, 'a') do |f|
+ puts "Installing for Capistrano"
+ print " Adding AppSignal integration to Capfile"
+ File.open(capfile, "a") do |f|
f.write "\nrequire 'appsignal/capistrano'\n"
end
periods
puts
puts
@@ -156,11 +156,11 @@
puts " (1) a config file"
puts " (2) environment variables"
loop do
print " Choose (1/2): "
case ask_for_input
- when '1'
+ when "1"
puts
print "Writing config file"
periods
puts
puts colorize " Config file written to config/appsignal.yml", :green
@@ -169,11 +169,11 @@
:app_name => config[:name],
:environments => environments
)
puts
break
- when '2'
+ when "2"
ENV["APPSIGNAL_ACTIVE"] = "true"
ENV["APPSIGNAL_PUSH_API_KEY"] = config[:push_api_key]
ENV["APPSIGNAL_APP_NAME"] = config[:name]
puts
@@ -197,11 +197,11 @@
puts colorize "## AppSignal installation complete ##", :green
puts colorize "#####################################", :green
sleep 0.3
puts
if Gem.win_platform?
- puts 'The AppSignal agent currently does not work on Windows, please push these changes to your test/staging/production environment'
+ puts "The AppSignal agent currently does not work on Windows, please push these changes to your test/staging/production environment"
else
puts " Sending example data to AppSignal..."
if Appsignal::Demo.transmit
puts " Example data sent!"
puts " It may take about a minute for the data to appear on AppSignal.com/accounts"
@@ -215,48 +215,48 @@
end
def installed_frameworks
[].tap do |out|
begin
- require 'rails'
+ require "rails"
out << :rails
rescue LoadError
end
begin
- require 'sinatra'
+ require "sinatra"
out << :sinatra
rescue LoadError
end
begin
- require 'padrino'
+ require "padrino"
out << :padrino
rescue LoadError
end
begin
- require 'grape'
+ require "grape"
out << :grape
rescue LoadError
end
end
end
def rails_environments
Dir.glob(
- File.join(Dir.pwd, 'config/environments/*.rb')
+ File.join(Dir.pwd, "config/environments/*.rb")
).map { |o| File.basename(o, ".rb") }.sort - EXCLUDED_ENVIRONMENTS
end
def write_config_file(data)
template = ERB.new(
File.read(File.join(File.dirname(__FILE__), "../../../resources/appsignal.yml.erb")),
nil,
- '-'
+ "-"
)
config = template.result(OpenStruct.new(data).instance_eval { binding })
- FileUtils.mkdir_p(File.join(Dir.pwd, 'config'))
- File.write(File.join(Dir.pwd, 'config/appsignal.yml'), config)
+ FileUtils.mkdir_p(File.join(Dir.pwd, "config"))
+ File.write(File.join(Dir.pwd, "config/appsignal.yml"), config)
end
def new_config
Appsignal::Config.new(Dir.pwd, "")
end