lib/configliere/config_file.rb in configliere-0.4.5 vs lib/configliere/config_file.rb in configliere-0.4.6

- old
+ new

@@ -28,14 +28,18 @@ # The env option is *not* coerced to_sym, so make sure your key type matches the file's def read filename, options={} if filename.is_a?(Symbol) then raise Configliere::DeprecatedError, "Loading from a default config file is no longer provided" ; end filename = expand_filename(filename) begin - new_data = YAML.load(File.open(filename)) || {} + read_yaml(File.open(filename), options) rescue Errno::ENOENT => e warn "Loading empty configliere settings file #{filename}" - new_data = {} end + self + end + + def read_yaml yaml_str, options={} + new_data = YAML.load(yaml_str) || {} # Extract the :env (production/development/etc) if options[:env] new_data = new_data[options[:env]] || {} end deep_merge! new_data