Last active
October 1, 2015 15:50
-
-
Save saliceti/9425874a0703a37914db to your computer and use it in GitHub Desktop.
Extract a value from a YAML file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool!