Class: Megam::Dumpout
- Inherits:
-
Object
- Object
- Megam::Dumpout
- Defined in:
- lib/megam/scmmanager/dumpout.rb
Instance Attribute Summary collapse
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #color(string, *colors) ⇒ Object
-
#color? ⇒ Boolean
Should colored output be used ?.
-
#err(message) ⇒ Object
Prints a msg to stderr.
-
#error(message) ⇒ Object
Print an error message.
-
#fatal(message) ⇒ Object
Print a message describing a fatal error.
- #highline ⇒ Object
-
#info(message) ⇒ Object
Prints a message to stdout.
-
#initialize(stdout, stderr, stdin) ⇒ Dumpout
constructor
A new instance of Dumpout.
- #list(*args) ⇒ Object
- #msg(message) ⇒ Object
- #pretty_print(data) ⇒ Object
-
#warn(message) ⇒ Object
Print a warning message.
Constructor Details
#initialize(stdout, stderr, stdin) ⇒ Dumpout
Returns a new instance of Dumpout.
8 9 10 |
# File 'lib/megam/scmmanager/dumpout.rb', line 8 def initialize(stdout, stderr, stdin) @stdout, @stderr, @stdin = stdout, stderr, stdin end |
Instance Attribute Details
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
5 6 7 |
# File 'lib/megam/scmmanager/dumpout.rb', line 5 def stderr @stderr end |
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
6 7 8 |
# File 'lib/megam/scmmanager/dumpout.rb', line 6 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
4 5 6 |
# File 'lib/megam/scmmanager/dumpout.rb', line 4 def stdout @stdout end |
Instance Method Details
#color(string, *colors) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/megam/scmmanager/dumpout.rb', line 51 def color(string, *colors) if color? highline.color(string, *colors) else string end end |
#color? ⇒ Boolean
Should colored output be used ?. When output is not to a terminal, colored output is never used
61 62 63 |
# File 'lib/megam/scmmanager/dumpout.rb', line 61 def color? stdout.tty? end |
#err(message) ⇒ Object
Prints a msg to stderr. Used for warn, error, and fatal.
32 33 34 |
# File 'lib/megam/scmmanager/dumpout.rb', line 32 def err() stderr.puts end |
#error(message) ⇒ Object
Print an error message
42 43 44 |
# File 'lib/megam/scmmanager/dumpout.rb', line 42 def error() err("#{color('ERROR:', :red, :bold)} #{}") end |
#fatal(message) ⇒ Object
Print a message describing a fatal error.
47 48 49 |
# File 'lib/megam/scmmanager/dumpout.rb', line 47 def fatal() err("#{color('FATAL:', :red, :bold)} #{}") end |
#highline ⇒ Object
12 13 14 15 16 17 |
# File 'lib/megam/scmmanager/dumpout.rb', line 12 def highline @highline ||= begin require 'highline' HighLine.new end end |
#info(message) ⇒ Object
Prints a message to stdout. Aliased as info
for compatibility with the logger API.
27 28 29 |
# File 'lib/megam/scmmanager/dumpout.rb', line 27 def info() stdout.puts("#{color('INFO:', :green, :bold)} #{}") end |
#list(*args) ⇒ Object
65 66 67 |
# File 'lib/megam/scmmanager/dumpout.rb', line 65 def list(*args) highline.list(*args) end |
#msg(message) ⇒ Object
20 21 22 |
# File 'lib/megam/scmmanager/dumpout.rb', line 20 def msg() stdout.puts end |
#pretty_print(data) ⇒ Object
69 70 71 |
# File 'lib/megam/scmmanager/dumpout.rb', line 69 def pretty_print(data) stdout.puts data end |
#warn(message) ⇒ Object
Print a warning message
37 38 39 |
# File 'lib/megam/scmmanager/dumpout.rb', line 37 def warn() err("#{color('WARNING:', :yellow, :bold)} #{}") end |