Class: Thoom::YamlConfig

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

Instance Method Summary collapse

Methods included from Config

#config_set, #env=, #get, #print, #set

Constructor Details

#initialize(filename, env = :default) ⇒ YamlConfig

Returns a new instance of YamlConfig.

Raises:



64
65
66
67
68
69
70
71
72
73
# File 'lib/config.rb', line 64

def initialize(filename, env = :default)
  file = File.exist?(filename) ? filename : File.expand_path("~/#{filename}")
  raise ConfigFileError, "Configuration file #{filename} not found" unless File.exist? file

  yaml = YAML.load_file file
  raise ConfigFileError, "Configuration file #{file} is empty!" unless yaml

  @env = env
  config_set(yaml)
end