class Guard::UI::Config

Constants

DEFAULTS
DEPRECATED_OPTS

Attributes

logger_config[R]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Guard::Options.new
# File lib/guard/ui/config.rb, line 20
def initialize(options = {})
  opts = Guard::Options.new(options, DEFAULTS)

  # migrate old options stored in UI config directly
  deprecated_logger_opts = {}
  DEPRECATED_OPTS.each do |option|
    if opts.key?(option)
      deprecated_logger_opts[option.to_sym] = opts.delete(option)
    end
  end

  @logger_config = Logger::Config.new(deprecated_logger_opts)
  super(opts.to_hash)
end

Public Instance Methods

[](name) click to toggle source
Calls superclass method
# File lib/guard/ui/config.rb, line 48
def [](name)
  name = name.to_s

  # TODO: remove in Guard 3.x
  return logger_config[name] if DEPRECATED_OPTS.include?(name)
  return device if name == "device"

  # let Thor's Hash handle anything else
  super(name.to_s)
end
device() click to toggle source
# File lib/guard/ui/config.rb, line 35
def device
  # Use strings to work around Thor's indifferent Hash's bug
  fetch("device") || $stderr
end
except() click to toggle source
# File lib/guard/ui/config.rb, line 44
def except
  fetch("except")
end
only() click to toggle source
# File lib/guard/ui/config.rb, line 40
def only
  fetch("only")
end
with_progname(name) { || ... } click to toggle source
# File lib/guard/ui/config.rb, line 59
def with_progname(name)
  if Guard::UI.logger.respond_to?(:set_progname)
    Guard::UI.logger.set_progname(name) do
      yield if block_given?
    end
  elsif block_given?
    yield
  end
end