lib/dsc.rb in dsc-0.0.1 vs lib/dsc.rb in dsc-0.1.0
- old
+ new
@@ -1,14 +1,18 @@
-require "dsc/version"
require "hashie/mash"
+require "erb"
require "yaml"
+
+require "dsc/version"
require "dsc/mash"
module Dsc
UndefinedAttribute = Class.new(NoMethodError)
- def self.load_file(file_path, env: "development")
- config_hash = YAML::load_file(file_path)[env]
+ def self.load_file(file_path, env: "development", optional: [])
+ optional_hash = optional.map { |key| [key, nil] }.to_h
+ config_yaml = ERB.new(File.read(file_path)).result
+ config_hash = optional_hash.merge(YAML::load(config_yaml)[env])
Dsc::Mash.new(config_hash)
end
end