Constructing a serialised YAML string in Ruby
This post's featured URL for sharing metadata is https://www.jvt.me/img/profile.jpg.
Sometimes you want to convert a YAML document to an encoded format that can then i.e. be base64-encoded, or stored in another form.
I fought against this the other day and it took me a bit of work to work out that we can write the following CLI Ruby incantation to give us what we need:
ruby -ryaml -e 'p YAML.load(ARGF.read).to_yaml' < a.yml
# outputs:
# "---\ninfo:\n version: 1.2.3\n"