class Cumuli::CLI::RemoteRakeCommand

Constants

COMMAND_ENV
DIR_ENV

Attributes

argv[R]

Public Class Methods

new(argv) click to toggle source
# File lib/cumuli/cli/remote_rake_command.rb, line 9
def initialize(argv)
  puts "argv: #{argv.inspect}"
  @argv = argv
end

Public Instance Methods

command() click to toggle source
# File lib/cumuli/cli/remote_rake_command.rb, line 32
def command
  Commander.new(raw_command).build
end
dir() click to toggle source
# File lib/cumuli/cli/remote_rake_command.rb, line 19
def dir
  extract_env(DIR_ENV)
end
extract_env(env_var) click to toggle source
# File lib/cumuli/cli/remote_rake_command.rb, line 14
def extract_env(env_var)
  found_arg = argv.detect{|arg| arg.include?(env_var)}
  found_arg && found_arg.gsub(env_var, '')
end
get_passed_command() click to toggle source
# File lib/cumuli/cli/remote_rake_command.rb, line 27
def get_passed_command
  matched = argv.first.match(/\[(.*)\]/)
  (matched && matched[1]) || argv.first
end
perform() click to toggle source
# File lib/cumuli/cli/remote_rake_command.rb, line 36
def perform
  Dir.chdir(dir) do
    puts "running #{command}, at #{dir}"
    Terminal.new(command).spawn
  end
end
raw_command() click to toggle source
# File lib/cumuli/cli/remote_rake_command.rb, line 23
def raw_command
  extract_env(COMMAND_ENV) || get_passed_command
end