Sha256: 5010c8c0003fac220edb6b995f2bbd654ee8646e2d8d470d2f17f2e0bb776a16
Contents?: true
Size: 956 Bytes
Versions: 1
Compression:
Stored size: 956 Bytes
Contents
require 'yaml' class Hash include DeepSymbolizable end module Settings extend self @_settings = {} attr_reader :_settings def load!(filename, options = {}) unless File.exist?(filename) puts "Unable to find config file \"#{filename}\"" exit!(1) end newsets = YAML::load_file(filename).deep_symbolize newsets = newsets[options[:env].to_sym] if options[:env] && newsets[options[:env].to_sym] deep_merge!(@_settings, newsets) end def deep_merge!(target, data) merger = proc { |_, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 } target.merge! data, &merger end def defaults @_settings[:defaults] end def base @_settings[:base] end def local @_settings[:local] end def build @_settings[:build] end def install @_settings[:install] end def repos @_settings[:repos] end def packages @_settings[:packages] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
devinstall-0.2.0 | lib/devinstall/settings.rb |