Class: Guard::UI::Config
- Inherits:
-
Options
- Object
- Thor::CoreExt::HashWithIndifferentAccess
- Options
- Guard::UI::Config
- Defined in:
- lib/guard/ui/config.rb
Constant Summary collapse
- DEFAULTS =
{ only: nil, except: nil, # nil (will be whatever $stderr is later) or LumberJack device, e.g. # $stderr or 'foo.log' device: nil, }.freeze
- DEPRECATED_OPTS =
%w(template time_format level progname).freeze
Instance Attribute Summary collapse
-
#logger_config ⇒ Object
readonly
Returns the value of attribute logger_config.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #device ⇒ Object
- #except ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #only ⇒ Object
- #with_progname(name) ⇒ Object
Methods inherited from Options
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/guard/ui/config.rb', line 20 def initialize( = {}) opts = Guard::Options.new(, 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 |
Instance Attribute Details
#logger_config ⇒ Object (readonly)
Returns the value of attribute logger_config.
18 19 20 |
# File 'lib/guard/ui/config.rb', line 18 def logger_config @logger_config end |
Instance Method Details
#[](name) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# 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 ⇒ Object
35 36 37 38 |
# 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 ⇒ Object
44 45 46 |
# File 'lib/guard/ui/config.rb', line 44 def except fetch("except") end |
#only ⇒ Object
40 41 42 |
# File 'lib/guard/ui/config.rb', line 40 def only fetch("only") end |