class DockerComposeDeploy::Util::Shell

Public Class Methods

new() click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 8
def initialize
  $stderr.sync = true
  $stdout.sync = true
end

Public Instance Methods

confirm?(question) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 58
def confirm?(question)
  warn "#{question} [Yn]"
  STDIN.gets.strip.downcase != 'n'
end
exit(msg) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 41
def exit(msg)
  warn(msg)
  Kernel.exit(1)
end
notify(msg) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 33
def notify(msg)
  puts yellow(msg)
end
puts(msg) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 37
def puts(msg)
  Kernel.puts(msg)
end
run(cmd) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 13
def run(cmd)
  puts blue(cmd)
  IO.popen(cmd) do |io|
    while (line = io.gets) do
      puts line
    end
  end
  $?
end
run!(cmd) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 23
def run!(cmd)
  if run(cmd) != 0
    exit("\nCommand failed:\n#{cmd}")
  end
end
scp!(src, dest, opts="") click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 54
def scp!(src, dest, opts="")
  run!("scp -F ~/.ssh/config -F ssh_config_overrides #{opts} #{src} #{dest} > /dev/tty")
end
ssh(cmd) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 46
def ssh(cmd)
  run(ssh_cmd(cmd))
end
ssh!(cmd, opts="") click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 50
def ssh!(cmd, opts="")
  run!(ssh_cmd(cmd, opts))
end
ssh_cmd(cmd, opts) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 63
def ssh_cmd(cmd, opts)
  "ssh -F ~/.ssh/config -F ssh_config_overrides #{opts} #{connection} '#{cmd}'"
end
warn(msg) click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 29
def warn(msg)
  puts red(msg)
end

Private Instance Methods

connection() click to toggle source
# File lib/docker_compose_deploy/util/shell.rb, line 69
def connection
  DockerComposeDeploy.config.connection
end