Module: Guard::UI
- Defined in:
- lib/guard/ui.rb
Overview
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`.
Constant Summary collapse
- ANSI_ESCAPE_BRIGHT =
Brighten the color
'1'
- ANSI_ESCAPE_BLACK =
Black foreground color
'30'
- ANSI_ESCAPE_RED =
Red foreground color
'31'
- ANSI_ESCAPE_GREEN =
Green foreground color
'32'
- ANSI_ESCAPE_YELLOW =
Yellow foreground color
'33'
- ANSI_ESCAPE_BLUE =
Blue foreground color
'34'
- ANSI_ESCAPE_MAGENTA =
Magenta foreground color
'35'
- ANSI_ESCAPE_CYAN =
Cyan foreground color
'36'
- ANSI_ESCAPE_WHITE =
White foreground color
'37'
- ANSI_ESCAPE_BGBLACK =
Black background color
'40'
- ANSI_ESCAPE_BGRED =
Red background color
'41'
- ANSI_ESCAPE_BGGREEN =
Green background color
'42'
- ANSI_ESCAPE_BGYELLOW =
Yellow background color
'43'
- ANSI_ESCAPE_BGBLUE =
Blue background color
'44'
- ANSI_ESCAPE_BGMAGENTA =
Magenta background color
'45'
- ANSI_ESCAPE_BGCYAN =
Cyan background color
'46'
- ANSI_ESCAPE_BGWHITE =
White background color
'47'
Class Method Summary collapse
-
.clear ⇒ Object
Clear the output.
-
.debug(message, options = { }) ⇒ Object
Show a debug message that is prefixed with DEBUG and a timestamp.
-
.deprecation(message, options = { }) ⇒ Object
Show a red deprecation message that is prefixed with DEPRECATION.
-
.error(message, options = { }) ⇒ Object
Show a red error message that is prefixed with ERROR.
-
.info(message, options = { }) ⇒ Object
Show an info message.
-
.reset_line ⇒ Object
Reset a line.
Class Method Details
.clear ⇒ Object
Clear the output.
71 72 73 |
# File 'lib/guard/ui.rb', line 71 def clear system('clear;') end |
.debug(message, options = { }) ⇒ Object
Show a debug message that is prefixed with DEBUG and a timestamp.
56 57 58 59 60 61 |
# File 'lib/guard/ui.rb', line 56 def debug(, = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if [:reset] STDERR.puts color("DEBUG (#{Time.now.strftime('%T')}): ", :yellow) + if ::Guard. && ::Guard.[:debug] end end |
.deprecation(message, options = { }) ⇒ Object
Show a red deprecation message that is prefixed with DEPRECATION.
44 45 46 47 48 49 |
# File 'lib/guard/ui.rb', line 44 def deprecation(, = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if [:reset] STDERR.puts color('DEPRECATION: ', :red) + end end |
.error(message, options = { }) ⇒ Object
Show a red error message that is prefixed with ERROR.
32 33 34 35 36 37 |
# File 'lib/guard/ui.rb', line 32 def error(, = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if [:reset] STDERR.puts color('ERROR: ', :red) + end end |
.info(message, options = { }) ⇒ Object
Show an info message.
20 21 22 23 24 25 |
# File 'lib/guard/ui.rb', line 20 def info(, = { }) unless ENV['GUARD_ENV'] == 'test' reset_line if [:reset] STDERR.puts color() if != '' end end |
.reset_line ⇒ Object
Reset a line.
65 66 67 |
# File 'lib/guard/ui.rb', line 65 def reset_line STDERR.print(color_enabled? ? "\r\e[0m" : "\r\n") end |