According to http://yaml.org/spec/current.html#id2509980 comments in YAML files are a presentational detail and must not be in the serialization/representation graph ( http://yaml.org/spec/current.html#representation/). It looks like Psych is parsing according to spec and loses the comments which means that it is not possible to parse a YAML file and serialize it again exactly the same way when the file contains comments. Which in my opinion is very strange because comments do matter in such file (e.g. configs).
Does anyone know if it possible to parse comments with an existing library or is the only way to go to do it all by myself?