Sha256: 212d701b7f318f62923311a509e3f54283b3bc2b98487e61177b4b630e7a20aa
Contents?: true
Size: 456 Bytes
Versions: 3
Compression:
Stored size: 456 Bytes
Contents
require 'yaml' ## # Load values from an external YAML hash class HSS::Parser private def external(source, key) begin config = open(File.expand_path(source)) { |f| YAML.load f.read } rescue Psych::SyntaxError, Errno::ENOENT raise "Failed to open YAML file: #{source}" end begin key.split('.').reduce(config) { |a, e| a[e] } || fail rescue raise NameError, "Key not found in YAML: #{key}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hss-0.2.8 | lib/helpers/external.rb |
hss-0.2.6 | lib/helpers/external.rb |
hss-0.2.5 | lib/helpers/external.rb |