Sha256: 63376a0373cb10fd451af5c9c24e88e2f99350070db532027df96853a56a3679
Contents?: true
Size: 499 Bytes
Versions: 4
Compression:
Stored size: 499 Bytes
Contents
require 'yaml' module HSS ## # Load values from an external YAML hash class 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 end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hss-1.0.1 | lib/hss/helpers/external.rb |
hss-1.0.0 | lib/hss/helpers/external.rb |
hss-0.2.11 | lib/hss/helpers/external.rb |
hss-0.2.10 | lib/helpers/external.rb |