class Mmtrix::Cli::Install

Constants

NO_LICENSE_KEY

Attributes

app_name[R]

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.

dest_dir[R]

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.

generated_for_user[R]

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.

license_key[R]

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.

quiet[R]

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.

src_file[R]

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.

Public Class Methods

command() click to toggle source
# File lib/mmtrix/cli/commands/install.rb, line 13
def self.command; "install"; end
new(command_line_args={}) click to toggle source
Calls superclass method Mmtrix::Cli::Command::new
# File lib/mmtrix/cli/commands/install.rb, line 24
def initialize command_line_args={}
  super command_line_args
  if !@dest_dir
    # Install a mmtrix.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.join(" ")
  @agent_version = Mmtrix::VERSION::STRING
  raise CommandFailure.new("Application name required.", @options) unless @app_name && @app_name.size > 0
end

Public Instance Methods

content() click to toggle source
# File lib/mmtrix/cli/commands/install.rb, line 65
def content
  @src_file ||= File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","..","mmtrix.yml"))
  template = File.read(@src_file)
  ERB.new(template).result(binding)
end
run() click to toggle source
# File lib/mmtrix/cli/commands/install.rb, line 40
  def run
    dest_file = File.expand_path(@dest_dir + "/mmtrix.yml")
    if File.exist?(dest_file)
      raise Mmtrix::Cli::Command::CommandFailure, "mmtrix.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.mmtrix.com, and replace the mmtrix.yml file with the one
you receive upon registration.
    EOF
    puts <<-EOF unless quiet

Visit support.mmtrix.com if you are experiencing installation issues.
    EOF

  end

Private Instance Methods

options() { |o| ... } click to toggle source
# File lib/mmtrix/cli/commands/install.rb, line 73
def options
  OptionParser.new "Usage: #{$0} #{self.class.command} [ OPTIONS] 'application name'", 40 do |o|
    o.on("-l", "--license_key=NAME", String,
           "Use the given license key") { | e | @license_key = e }
    o.on("-d", "--destdir=name", String,
             "Write the mmtrix.yml to the given directory, default is '.'") { | e | @dest_dir = e }
    yield o if block_given?
  end
end