Sha256: d8e78504a468ba8ba4c12a072ad3f3eafca21679bbd1756ee069f5eab8fbeb66
Contents?: true
Size: 478 Bytes
Versions: 1
Compression:
Stored size: 478 Bytes
Contents
require 'yaml' module HSS ## # Load values from an external YAML hash class Parser private def external(source, key) config = File.open(File.expand_path(source)) { |f| YAML.safe_load f.read } key.split('.').reduce(config) { |acc, elem| acc[elem] } || raise rescue Psych::SyntaxError, Errno::ENOENT raise "Failed to open YAML file: #{source}" rescue StandardError raise NameError, "Key not found in YAML: #{key}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hss-1.1.0 | lib/hss/helpers/external.rb |