Module: TechnoGate::Contao::UI
- Defined in:
- lib/contao/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
-
.action_with_scopes(action, scopes) ⇒ Object
Show a scoped action message.
-
.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.
-
.warning(message, options = { }) ⇒ Object
Show a yellow warning message that is prefixed with WARNING.
Class Method Details
.action_with_scopes(action, scopes) ⇒ Object
Show a scoped action message.
92 93 94 95 96 97 98 |
# File 'lib/contao/ui.rb', line 92 def action_with_scopes(action, scopes) ||= scopes[:contao] ||= scopes[:group] ||= 'all' info "#{action} #{}" end |
.clear ⇒ Object
Clear the output.
83 84 85 |
# File 'lib/contao/ui.rb', line 83 def clear system('clear;') end |
.debug(message, options = { }) ⇒ Object
Show a debug message that is prefixed with DEBUG and a timestamp.
68 69 70 71 72 73 |
# File 'lib/contao/ui.rb', line 68 def debug(, = { }) unless ENV['RAILS_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.
56 57 58 59 60 61 |
# File 'lib/contao/ui.rb', line 56 def deprecation(, = { }) unless ENV['RAILS_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.
44 45 46 47 48 49 |
# File 'lib/contao/ui.rb', line 44 def error(, = { }) unless ENV['RAILS_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/contao/ui.rb', line 20 def info(, = { }) unless ENV['RAILS_ENV'] == 'test' reset_line if [:reset] STDERR.puts color() if != '' end end |
.reset_line ⇒ Object
Reset a line.
77 78 79 |
# File 'lib/contao/ui.rb', line 77 def reset_line STDERR.print(color_enabled? ? "\r\e[0m" : "\r\n") end |
.warning(message, options = { }) ⇒ Object
Show a yellow warning message that is prefixed with WARNING.
32 33 34 35 36 37 |
# File 'lib/contao/ui.rb', line 32 def warning(, = { }) unless ENV['RAILS_ENV'] == 'test' reset_line if [:reset] STDERR.puts color('WARNING: ', :yellow) + end end |