class Tainers::CLI::Command

Attributes

specification[R]

Public Class Methods

commands() click to toggle source
# File lib/tainers/cli.rb, line 88
def self.commands
  cmds = instance_methods.collect {|m| m.to_s}.find_all {|m| m.to_s =~ /_command$/}.collect {|n| n.to_s[0..-9] }
  cmds.collect do |name|
    helper = "#{name}_help".to_sym
    if respond_to? helper
      [name, send(helper)]
    else
      [name, '']
    end
  end
end
create_help() click to toggle source
# File lib/tainers/cli.rb, line 105
def self.create_help
  "Creates specified container, if it doesn't already exist; exits with 0 on creation, 1 if already exists."
end
ensure_help() click to toggle source
# File lib/tainers/cli.rb, line 114
def self.ensure_help
  "Ensures specified container exists, by name."
end
exists_help() click to toggle source
# File lib/tainers/cli.rb, line 123
def self.exists_help
  "Exits with 0 (true) if specified container exists, by name; 1 (false) if not."
end
name_help() click to toggle source
# File lib/tainers/cli.rb, line 132
def self.name_help
  "Prints the specified container's name on stdout."
end
new(spec={}) click to toggle source
# File lib/tainers/cli.rb, line 84
def initialize(spec={})
  @specification = Tainers.specify(spec)
end

Public Instance Methods

create_command() click to toggle source
# File lib/tainers/cli.rb, line 100
def create_command
  return 0 if specification.create
  1
end
ensure_command() click to toggle source
# File lib/tainers/cli.rb, line 109
def ensure_command
  return 0 if specification.ensure
  255
end
exists_command() click to toggle source
# File lib/tainers/cli.rb, line 118
def exists_command
  return 0 if specification.exists?
  1
end
name_command() click to toggle source
# File lib/tainers/cli.rb, line 127
def name_command
  STDOUT.print "#{specification.name}\n"
  0
end