Class: NewRelic::Command::Install
- Inherits:
-
NewRelic::Command
- Object
- NewRelic::Command
- NewRelic::Command::Install
- Defined in:
- lib/new_relic/commands/install.rb
Constant Summary collapse
- NO_LICENSE_KEY =
"<PASTE LICENSE KEY HERE>"
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Use -h to see options.
-
#dest_dir ⇒ Object
readonly
Use -h to see options.
-
#generated_for_user ⇒ Object
readonly
Use -h to see options.
-
#license_key ⇒ Object
readonly
Use -h to see options.
-
#quiet ⇒ Object
readonly
Use -h to see options.
-
#src_file ⇒ Object
readonly
Use -h to see options.
Attributes inherited from NewRelic::Command
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(command_line_args = {}) ⇒ Install
constructor
A new instance of Install.
- #run ⇒ Object
Methods inherited from NewRelic::Command
Constructor Details
#initialize(command_line_args = {}) ⇒ Install
Returns a new instance of Install.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/new_relic/commands/install.rb', line 20 def initialize command_line_args={} super command_line_args if !@dest_dir # Install a newrelic.yml file into the local config directory. if File.directory? "config" @dest_dir = "config" else @dest_dir = "." end end @license_key ||= NO_LICENSE_KEY @app_name ||= @leftover raise CommandFailure.new("Application name required.", @options) unless @app_name && @app_name.size > 0 @generated_for_user ||= @user_string || "" end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Use -h to see options. When command_line_args is a hash, we are invoking directly and it’s treated as an options with optional string values for :user, :description, :appname, :revision, :environment, and :changes.
Will throw CommandFailed exception if there’s any error.
19 20 21 |
# File 'lib/new_relic/commands/install.rb', line 19 def app_name @app_name end |
#dest_dir ⇒ Object (readonly)
Use -h to see options. When command_line_args is a hash, we are invoking directly and it’s treated as an options with optional string values for :user, :description, :appname, :revision, :environment, and :changes.
Will throw CommandFailed exception if there’s any error.
19 20 21 |
# File 'lib/new_relic/commands/install.rb', line 19 def dest_dir @dest_dir end |
#generated_for_user ⇒ Object (readonly)
Use -h to see options. When command_line_args is a hash, we are invoking directly and it’s treated as an options with optional string values for :user, :description, :appname, :revision, :environment, and :changes.
Will throw CommandFailed exception if there’s any error.
19 20 21 |
# File 'lib/new_relic/commands/install.rb', line 19 def generated_for_user @generated_for_user end |
#license_key ⇒ Object (readonly)
Use -h to see options. When command_line_args is a hash, we are invoking directly and it’s treated as an options with optional string values for :user, :description, :appname, :revision, :environment, and :changes.
Will throw CommandFailed exception if there’s any error.
19 20 21 |
# File 'lib/new_relic/commands/install.rb', line 19 def license_key @license_key end |
#quiet ⇒ Object (readonly)
Use -h to see options. When command_line_args is a hash, we are invoking directly and it’s treated as an options with optional string values for :user, :description, :appname, :revision, :environment, and :changes.
Will throw CommandFailed exception if there’s any error.
19 20 21 |
# File 'lib/new_relic/commands/install.rb', line 19 def quiet @quiet end |
#src_file ⇒ Object (readonly)
Use -h to see options. When command_line_args is a hash, we are invoking directly and it’s treated as an options with optional string values for :user, :description, :appname, :revision, :environment, and :changes.
Will throw CommandFailed exception if there’s any error.
19 20 21 |
# File 'lib/new_relic/commands/install.rb', line 19 def src_file @src_file end |
Class Method Details
.command ⇒ Object
9 |
# File 'lib/new_relic/commands/install.rb', line 9 def self.command; "install"; end |
Instance Method Details
#content ⇒ Object
61 62 63 64 65 |
# File 'lib/new_relic/commands/install.rb', line 61 def content @src_file ||= File.(File.join(File.dirname(__FILE__),"..","..","..","newrelic.yml")) template = File.read(@src_file) ERB.new(template).result(binding) end |
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/new_relic/commands/install.rb', line 36 def run dest_file = File.(@dest_dir + "/newrelic.yml") if File.exist?(dest_file) raise NewRelic::Command::CommandFailure, "newrelic.yml file already exists. Move it out of the way." end File.open(dest_file, 'w') { | out | out.puts(content) } puts <<-EOF unless quiet Installed a default configuration file at #{dest_file}. EOF puts <<-EOF unless quiet || @license_key != NO_LICENSE_KEY To monitor your application in production mode, sign up for an account at www.newrelic.com, and replace the newrelic.yml file with the one you receive upon registration. EOF puts <<-EOF unless quiet E-mail [email protected] with any problems or questions. EOF end |