ruby/psych

Add enough primitives to support comment preservation

SamSaffron opened this issue · 0 comments

Preserving comments in YAML files is a general problem many automation tools have.

The general problem is that you have some YAML file say:

# the answer
- universe: 41

When you decide to programmatically change the file to correct the answer by loading and saving YAML you end up stripping comments

- universe: 42

There are 2 current families of solutions in the wild. The first is regex hacking. The second is leaning on https://pypi.org/project/ruamel.yaml/.

Was wondering if having enough internal primitives in psych to implement this is a good idea? Should comment preservation be built into Psych (optionally) or is this the role of some other gem that consumes it?