class Megam::Dumpout

Attributes

stderr[R]
stdin[R]
stdout[R]

Public Class Methods

new(stdout, stderr, stdin) click to toggle source
# File lib/megam/gogs/dumpout.rb, line 8
def initialize(stdout, stderr, stdin)
  @stdout, @stderr, @stdin = stdout, stderr, stdin
end

Public Instance Methods

color(string, *colors) click to toggle source
# File lib/megam/gogs/dumpout.rb, line 51
def color(string, *colors)
  if color?
    highline.color(string, *colors)
  else
  string
  end
end
color?() click to toggle source

Should colored output be used ?. When output is not to a terminal, colored output is never used

# File lib/megam/gogs/dumpout.rb, line 61
def color?
  stdout.tty?
end
err(message) click to toggle source

Prints a msg to stderr. Used for warn, error, and fatal.

# File lib/megam/gogs/dumpout.rb, line 32
def err(message)
  stderr.puts message
end
error(message) click to toggle source

Print an error message

# File lib/megam/gogs/dumpout.rb, line 42
def error(message)
  err("#{color('ERROR:', :red, :bold)} #{message}")
end
fatal(message) click to toggle source

Print a message describing a fatal error.

# File lib/megam/gogs/dumpout.rb, line 47
def fatal(message)
  err("#{color('FATAL:', :red, :bold)} #{message}")
end
highline() click to toggle source
# File lib/megam/gogs/dumpout.rb, line 12
def highline
  @highline ||= begin
  require 'highline'
  HighLine.new
  end
end
info(message) click to toggle source

Prints a message to stdout. Aliased as info for compatibility with the logger API.

# File lib/megam/gogs/dumpout.rb, line 27
def info(message)
  stdout.puts("#{color('INFO:', :green, :bold)} #{message}")
end
list(*args) click to toggle source
# File lib/megam/gogs/dumpout.rb, line 65
def list(*args)
  highline.list(*args)
end
msg(message) click to toggle source
# File lib/megam/gogs/dumpout.rb, line 20
def msg(message)
  stdout.puts message
end
pretty_print(data) click to toggle source
# File lib/megam/gogs/dumpout.rb, line 69
def pretty_print(data)
  stdout.puts data
end
warn(message) click to toggle source

Print a warning message

# File lib/megam/gogs/dumpout.rb, line 37
def warn(message)
  err("#{color('WARNING:', :yellow, :bold)} #{message}")
end