A lil library to allow you to access the source file's line numbers while playing with parsed yaml.
We're using this at Braintree to help docs writers find where issues are in yaml based content (see: reference docs). If a value doesn't line up with what it should, we want to be able to tell the writer "Hey, look at line N, you're missing a colon there". Psych allows this to happen when there is a parsing error, and we want that functionality to carry through all the way to content validation.
The stratetgy is to subclass every class that yaml can be parsed into (there aren't that many if we ignore YAML.dump
for objects) so that in addition to all its methods, we can also call, say, String.metadata["line"] to get the line number where that string was pulled from. Why pack it into metadata and not just do String.line
? Well there's some more metadata that we like to store so that's the implementation I wrote! Maybe I'll change it later. Who knows.