The UI class helps to format messages for the user. Everything that is logged through this class is considered either as an error message or a diagnostic message and is written to standard error (STDERR).
If your Guard does some output that is piped into another process for further processing, please just write it to STDOUT with `puts`.
Black background color
Blue background color
Cyan background color
Green background color
Magenta background color
Red background color
White background color
Yellow background color
Black foreground color
Blue foreground color
Brighten the color
Cyan foreground color
Green foreground color
Magenta foreground color
Red foreground color
White foreground color
Yellow foreground color
Clear the output.
# File lib/guard/ui.rb, line 83 def clear system('clear;') end
Show a debug message that is prefixed with DEBUG and a timestamp.
@param [String] message the message to show @option options [Boolean] reset whether to clean the output before
# File lib/guard/ui.rb, line 68 def debug(message, options = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if options[:reset] STDERR.puts color("DEBUG (#{Time.now.strftime('%T')}): ", :yellow) + message if ::Guard.options && ::Guard.options[:verbose] end end
Show a red deprecation message that is prefixed with DEPRECATION.
@param [String] message the message to show @option options [Boolean] reset whether to clean the output before
# File lib/guard/ui.rb, line 56 def deprecation(message, options = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if options[:reset] STDERR.puts color('DEPRECATION: ', :red) + message end end
Show a red error message that is prefixed with ERROR.
@param [String] message the message to show @option options [Boolean] reset whether to clean the output before
# File lib/guard/ui.rb, line 44 def error(message, options = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if options[:reset] STDERR.puts color('ERROR: ', :red) + message end end
Show an info message.
@param [String] message the message to show @option options [Boolean] reset whether to clean the output before
# File lib/guard/ui.rb, line 20 def info(message, options = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if options[:reset] STDERR.puts color(message) if message != '' end end
Reset a line.
# File lib/guard/ui.rb, line 77 def reset_line STDERR.print(color_enabled? ? "\r\e[0m" : "\r\n") end
Show a yellow warning message that is prefixed with WARNING.
@param [String] message the message to show @option options [Boolean] reset whether to clean the output before
# File lib/guard/ui.rb, line 32 def warning(message, options = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if options[:reset] STDERR.puts color('WARNING: ', :yellow) + message end end
Generated with the Darkfish Rdoc Generator 2.