In Files

Guard::UI

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`.

Constants

ANSI_ESCAPE_BGBLACK

Black background color

ANSI_ESCAPE_BGBLUE

Blue background color

ANSI_ESCAPE_BGCYAN

Cyan background color

ANSI_ESCAPE_BGGREEN

Green background color

ANSI_ESCAPE_BGMAGENTA

Magenta background color

ANSI_ESCAPE_BGRED

Red background color

ANSI_ESCAPE_BGWHITE

White background color

ANSI_ESCAPE_BGYELLOW

Yellow background color

ANSI_ESCAPE_BLACK

Black foreground color

ANSI_ESCAPE_BLUE

Blue foreground color

ANSI_ESCAPE_BRIGHT

Brighten the color

ANSI_ESCAPE_CYAN

Cyan foreground color

ANSI_ESCAPE_GREEN

Green foreground color

ANSI_ESCAPE_MAGENTA

Magenta foreground color

ANSI_ESCAPE_RED

Red foreground color

ANSI_ESCAPE_WHITE

White foreground color

ANSI_ESCAPE_YELLOW

Yellow foreground color

Public Class Methods

clear() click to toggle source

Clear the output.

# File lib/guard/ui.rb, line 83
def clear
  system('clear;')
end
debug(message, options = { }) click to toggle source

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
deprecation(message, options = { }) click to toggle source

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
error(message, options = { }) click to toggle source

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
info(message, options = { }) click to toggle source

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_line() click to toggle source

Reset a line.

# File lib/guard/ui.rb, line 77
def reset_line
  STDERR.print(color_enabled? ? "\r\e[0m" : "\r\n")
end
warning(message, options = { }) click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.