-
-
Save armarti/d27934ce5e8a9dcf3549f15c17c2b22b to your computer and use it in GitHub Desktop.
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
development: | |
adapter: mysql2 | |
encoding: utf8 | |
database: my_database | |
username: root | |
roles: | |
- admin | |
- developer | |
- guest | |
password: | |
users: | |
- | |
name: pineapple | |
role: admin | |
- | |
name: umbrella | |
role: developer |
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
development_adapter=("mysql2") | |
development_encoding=("utf8") | |
development_database=("my_database") | |
development_username=("root") | |
development_roles+=("admin") | |
development_roles+=("developer") | |
development_roles+=("guest") | |
development_users__name+=("pineapple") | |
development_users__role+=("admin") | |
development_users__name+=("umbrella") | |
development_users__role+=("developer") |
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
## derived from https://gist.github.com/epiloque/8cf512c6d64641bde388 | |
## works for arrays of hashes, as long as the hashes do not have arrays | |
parse_yaml2() { | |
local prefix=$2 | |
local s | |
local w | |
local fs | |
s='[[:space:]]*' | |
w='[a-zA-Z0-9_]*' | |
fs="$(echo @|tr @ '\034')" | |
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ | |
-e "s|^\($s\)\($w\)$s[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" | | |
awk -F"$fs" '{ | |
indent = length($1)/2; | |
if (length($2) == 0) { conj[indent]="+";} else {conj[indent]="";} | |
vname[indent] = $2; | |
for (i in vname) {if (i > indent) {delete vname[i]}} | |
if (length($3) > 0) { | |
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")} | |
printf("%s%s%s%s=(\"%s\")\n", "'"$prefix"'",vn, $2, conj[indent-1],$3); | |
} | |
}' | sed 's/_=/+=/g' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment