Class: Argonaut::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/argonaut/settings.rb

Class Method Summary collapse

Class Method Details

.configObject



5
6
7
# File 'lib/argonaut/settings.rb', line 5

def self.config
  @config ||= read_config
end

.deep_symbolize(obj) ⇒ Object



21
22
23
24
25
# File 'lib/argonaut/settings.rb', line 21

def deep_symbolize(obj)
  return obj.inject({}){|memo,(k,v)| memo[k.to_sym] =  deep_symbolize(v); memo} if obj.is_a? Hash
  return obj.inject([]){|memo,v| memo << deep_symbolize(v); memo} if obj.is_a? Array
  return obj
end

.read_configObject



11
12
13
14
15
16
17
18
19
# File 'lib/argonaut/settings.rb', line 11

def read_config
  deep_symbolize(YAML.load_file(Argonaut::Constants::SETTINGS_FILE))
rescue Errno::ENOENT
  { options: {
      colorize_rows: true,
      time_format: '%d %b %Y %l:%M %p'
    }
  }
end