Top Level Namespace

Defined Under Namespace

Modules: Horatio

Constant Summary collapse

USE =

BEGIN CONFIG ###

<<-EOS
./build_docker_image.rb [<name> <version>]

set DRY_RUN=true if you would like debugging output

The Dockefile you have specified does not contain the required name and version
comments nor have you provided any via the CLI, please add the following after
FROM in you Dockerfile:

#name\=awesome-app
#version=0.0.1
#test_command=/bin/true
EOS
ERROR =
31
SUCCESS =
32
ATTN =
35
Log =
Logger.new(STDOUT)

Instance Method Summary collapse

Instance Method Details

#color(color = SUCCESS) ⇒ Object



27
28
29
30
31
# File 'lib/horatio.rb', line 27

def color (color=SUCCESS)
  printf "\033[#{color}m";
  yield
  printf "\033[0m"
end

#run_sh(cmd) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/horatio.rb', line 47

def run_sh(cmd)
  unless ENV['DRY_RUN']
    color { Log.info "executing command: #{cmd}" }
    o, e, s = sh(cmd)

    if s.exitstatus == 0
      color { Log.info "succesfully executed command `#{cmd}` output:\n #{o}" }
    else
      raise "execution of `#{cmd}` failed output from STDERR was:\n #{e}\n STDOUT was:\n #{o}"
    end
  else
    color { Log.info "dry run: would've executed command `#{cmd}`" }
  end
end

#sh(cmd) ⇒ Object

END CONFIG ###



42
43
44
45
# File 'lib/horatio.rb', line 42

def sh(cmd)
  o, e, s = nil, nil, nil
  o, e, s = Open3.capture3(*cmd)
end