Namespace

Included Modules

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 plugin does some output that is piped into another process for further processing, please just write it to STDOUT with `puts`.

Public Class Methods

action_with_scopes(action, scope) click to toggle source

Show a scoped action message.

@param [String] action the action to show @param [Hash] scopes hash with a guard or a group scope

# File lib/guard/ui.rb, line 124
def action_with_scopes(action, scope)
  first_non_blank_scope = _first_non_blank_scope(scope)
  scope_message = first_non_blank_scope.map(&:title).join(', ') unless first_non_blank_scope.nil?

  info "#{ action } #{ scope_message || 'all' }"
end
clear(options = {}) click to toggle source

Clear the output if clearable.

# File lib/guard/ui.rb, line 106
def clear(options = {})
  if ::Guard.options.clear && (@clearable || options[:force])
    @clearable = false
    system('clear;')
  end
end
clearable() click to toggle source

Allow the screen to be cleared again.

# File lib/guard/ui.rb, line 115
def clearable
  @clearable = true
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 @option options [String] plugin manually define the calling plugin

# File lib/guard/ui.rb, line 94
def debug(message, options = {})
  _filtered_logger_message(message, :debug, :yellow, options)
end
deprecation(message, options = {}) click to toggle source

Show a red deprecation message that is prefixed with DEPRECATION. It has a log level of `warn`.

@param [String] message the message to show @option options [Boolean] reset whether to clean the output before @option options [String] plugin manually define the calling plugin

# File lib/guard/ui.rb, line 84
def deprecation(message, options = {})
  warning(message, options) if ::Guard.options.show_deprecations
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 @option options [String] plugin manually define the calling plugin

# File lib/guard/ui.rb, line 73
def error(message, options = {})
  _filtered_logger_message(message, :error, :red, options)
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 @option options [String] plugin manually define the calling plugin

# File lib/guard/ui.rb, line 53
def info(message, options = {})
  _filtered_logger_message(message, :info, nil, options)
end
logger() click to toggle source

Get the Guard::UI logger instance

# File lib/guard/ui.rb, line 21
def logger
  @logger ||= begin
    opts = options.marshal_dump
    Lumberjack::Logger.new(opts.delete(:device) { $stderr }, opts)
  end
end
options() click to toggle source

Get the logger options

@return [Hash] the logger options

# File lib/guard/ui.rb, line 32
def options
  @options ||= ::Guard::Options.new(level: :info, template: ':time - :severity - :message', time_format: '%H:%M:%S')
end
options=(options) click to toggle source

Set the logger options

@param [Hash] options the logger options @option options [Symbol] level the log level @option options [String] template the logger template @option options [String] time_format the time format

# File lib/guard/ui.rb, line 43
def options=(options)
  @options = ::Guard::Options.new(options)
end
reset_line() click to toggle source

Reset a line.

# File lib/guard/ui.rb, line 100
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 @option options [String] plugin manually define the calling plugin

# File lib/guard/ui.rb, line 63
def warning(message, options = {})
  _filtered_logger_message(message, :warn, :yellow, options)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.