class TerraformLandscape::Output

Encapsulates all communication to an output source.

def self.silent

Returns:
  • (TerraformLandscape::Output) -
def self.silent
  new(File.open(File::NULL, 'w'))
end

def bold(*args)

Parameters:
  • args (Array) --
def bold(*args)
  color('1', *args)
end

def bold_error(*args)

Parameters:
  • args (Array) --
def bold_error(*args)
  color('1;31', *args)
end

def color(code, output, newline = true)

Parameters:
  • newline (Boolean) -- whether to append a newline
  • output (String) -- output to print
  • code (Integer, String) -- ANSI color code
def color(code, output, newline = true)
  puts(color_enabled ? "\033[#{code}m#{output}\033[0m" : output, newline)
end

def error(*args)

Parameters:
  • args (Array) --
def error(*args)
  color(31, *args)
end

def info(*args)

Parameters:
  • args (Array) --
def info(*args)
  color(36, *args)
end

def initialize(out)

Parameters:
  • out (IO) -- the output destination.
def initialize(out)
  @out = out
  @color_enabled = tty?
end

def newline

Print a blank line.
def newline
  puts('')
end

def notice(*args)

Parameters:
  • args (Array) --
def notice(*args)
  color(35, *args)
end

def print(output)

Parameters:
  • output (String) -- the output to send
def print(output)
  puts(output, false)
end

def puts(output, newline = true)

Parameters:
  • newline (true, false) -- whether to append a newline
  • output (String) -- the output to send
def puts(output, newline = true)
  @out.print(output)
  @out.print("\n") if newline
end

def success(*args)

Parameters:
  • args (Array) --
def success(*args)
  color(32, *args)
end

def tty?

Returns:
  • (true, false) -
def tty?
  @out.respond_to?(:tty?) && @out.tty?
end

def warning(*args)

Parameters:
  • args (Array) --
def warning(*args)
  color(33, *args)
end