I have a requirement to programmatically edit YAML files in Ruby, and I need to also retain the enclosing quote characters unfortunately. Being able to retain the comments too would be a bonus.
That is to say if I have a file:
---
foo: 'bar'
or
---
foo: "bar"
My script must not write it back as:
---
foo: bar
And as mentioned, ideally I need to preserve comments too.
Without going down the path of just treating the whole file as a stream of text, is there any convenient way to solve one or both of these problems?