Class: RubyJard::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_jard/config.rb

Overview

Another reinvent-the-wheel configuration

Constant Summary collapse

CONFIG_FILE_NAME =
'.jardrc'
DEFAULTS =
[
  DEFAULT_COLOR_SCHEME = '256',
  DEFAULT_ALIAS_TO_DEBUGGER = false,
  DEFAULT_LAYOUT = nil, # Pick layout automatically
  DEFAULT_FILTER = RubyJard::PathFilter::FILTER_APPLICATION,
  DEFAULT_FILTER_INCLUDED = [].freeze,
  DEFAULT_FILTER_EXCLUDED = [].freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



54
55
56
57
58
59
60
61
62
# File 'lib/ruby_jard/config.rb', line 54

def initialize
  @color_scheme = DEFAULT_COLOR_SCHEME
  @alias_to_debugger = DEFAULT_ALIAS_TO_DEBUGGER
  @layout = DEFAULT_LAYOUT
  @enabled_screens = RubyJard::Screens.names
  @filter = DEFAULT_FILTER
  @filter_included = DEFAULT_FILTER_INCLUDED.dup
  @filter_excluded = DEFAULT_FILTER_EXCLUDED.dup
end

Instance Attribute Details

#alias_to_debuggerObject

Returns the value of attribute alias_to_debugger.



41
42
43
# File 'lib/ruby_jard/config.rb', line 41

def alias_to_debugger
  @alias_to_debugger
end

#color_schemeObject

Returns the value of attribute color_scheme.



41
42
43
# File 'lib/ruby_jard/config.rb', line 41

def color_scheme
  @color_scheme
end

#enabled_screensObject

Returns the value of attribute enabled_screens.



41
42
43
# File 'lib/ruby_jard/config.rb', line 41

def enabled_screens
  @enabled_screens
end

#filterObject

Returns the value of attribute filter.



41
42
43
# File 'lib/ruby_jard/config.rb', line 41

def filter
  @filter
end

#filter_excludedObject

Returns the value of attribute filter_excluded.



41
42
43
# File 'lib/ruby_jard/config.rb', line 41

def filter_excluded
  @filter_excluded
end

#filter_includedObject

Returns the value of attribute filter_included.



41
42
43
# File 'lib/ruby_jard/config.rb', line 41

def filter_included
  @filter_included
end

#layoutObject

Returns the value of attribute layout.



41
42
43
# File 'lib/ruby_jard/config.rb', line 41

def layout
  @layout
end

Class Method Details

.smart_loadObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_jard/config.rb', line 8

def smart_load
  config = RubyJard::Config.new

  unless ENV['JARD_CONFIG_FILE'].nil?
    unless File.exist?(ENV['JARD_CONFIG_FILE'])
      raise "Config file '#{ENV['JARD_CONFIG_FILE']}' does not exist"
    end

    return load_config(config, ENV['JARD_CONFIG_FILE'])
  end

  path = File.expand_path(File.join(Dir.pwd, CONFIG_FILE_NAME))
  load_config(config, path) if File.exist?(path)

  path = File.expand_path(File.join('~/', CONFIG_FILE_NAME))
  load_config(config, path) if File.exist?(path)

  config
end

Instance Method Details

#configObject



64
65
66
# File 'lib/ruby_jard/config.rb', line 64

def config
  self
end