Skip to content

Instantly share code, notes, and snippets.

@saliceti
Last active October 1, 2015 15:50
Show Gist options
  • Save saliceti/9425874a0703a37914db to your computer and use it in GitHub Desktop.
Save saliceti/9425874a0703a37914db to your computer and use it in GitHub Desktop.
Extract a value from a YAML file
#!/usr/bin/env ruby
require 'yaml'
filename = ARGV[0]
path = ARGV[1]
def get(hash, path_array)
unless path_array.empty?
get(hash[path_array[0]], path_array[1..-1])
else
hash
end
end
secrets_hash = YAML.load_file(filename)
path_array = path.split('/')
puts get(secrets_hash, path_array)
@keymon
Copy link

keymon commented Oct 1, 2015

cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment