-
-
Save ahoward/2636753 to your computer and use it in GitHub Desktop.
# | |
# perl got some things right. here-docs were one of them. YAML takes this | |
# further when we have to define large data structures. | |
# | |
# if you find yourself typing " ' ) ( [ ] too many times in a row, whack | |
# yourself on the wee-wee with a keyboard and whip out the YAML | |
# | |
this_fucking_licks_hairy_balls_to_edit = | |
[{"name"=>"Ara T. Howard", "email"=>"[email protected]"}, | |
{"name"=>"Ryan Cook", "email"=>"[email protected]"}, | |
{"name"=>"Garett Shulman", "email"=>"[email protected]"}] | |
and_this_does_not = | |
YAML.parse ' | |
- | |
name : Ara T. Howard | |
email : [email protected] | |
- | |
name : Ryan Cook | |
email : [email protected] | |
- | |
name : Garett Shulman | |
email : [email protected] | |
' |
@geeksam - touché
replacing the typing of " ' ) ( [ ] for the hellish editing of YAML and all its white spaces glory doesn't seem like a good trade off.
@Telmo - whitespace is hell. but giant structures, as you might put into mongo, require something else.
My favored approach
[ {
"name" => "Ara T. Howard",
"email" => "[email protected]"
}, {
"name" => "Ryan Cook",
"email" => "[email protected]"
}, {
"name" => "Garett Shulman",
"email" => "[email protected]"
} ]
I like this because it is pure ruby, and it closely resembles JSON (which is parseable enough by humans).
moving the code lines separate from the delims is nice for editing....
I tend to separate the delimiters even more, but that's probably just because TextMate's native indentation support isn't as robust as I wish it were.
I also tend to add a trailing comma after all hash or array entries, even the last one (Some of my coworkers took to calling it "the Livingston-Gray comma"). I like to reorder large hashes to group related keys together, and it sucks to wait 10 seconds for Rails to load and then get hit with a syntax error because I moved the last item up and forgot to add the comma. ;>
Given that there are some really weird fetishes out there, I'm almost certain that someone out there actually enjoys licking hairy balls. But I appreciate the sentiment. (=