class TerraformLandscape::Output
Encapsulates all communication to an output source.
def self.silent
-
(TerraformLandscape::Output)
-
def self.silent new(File.open(File::NULL, 'w')) end
def bold(*args)
-
args
(Array
) --
def bold(*args) color('1', *args) end
def bold_error(*args)
-
args
(Array
) --
def bold_error(*args) color('1;31', *args) end
def color(code, output, newline = true)
-
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)
-
args
(Array
) --
def error(*args) color(31, *args) end
def info(*args)
-
args
(Array
) --
def info(*args) color(36, *args) end
def initialize(out)
-
out
(IO
) -- the output destination.
def initialize(out) @out = out @color_enabled = tty? end
def newline
def newline puts('') end
def notice(*args)
-
args
(Array
) --
def notice(*args) color(35, *args) end
def print(output)
-
output
(String
) -- the output to send
def print(output) puts(output, false) end
def puts(output, newline = true)
-
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)
-
args
(Array
) --
def success(*args) color(32, *args) end
def tty?
-
(true, false)
-
def tty? @out.respond_to?(:tty?) && @out.tty? end
def warning(*args)
-
args
(Array
) --
def warning(*args) color(33, *args) end
def write_from(other_io)
def write_from(other_io) while (line = other_io.gets) print line end end