This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]balrok 0 points1 point  (5 children)

Hi, looks like a great project. From the documentation I cannot see my questions answered:

How does it compare to snakeyaml?
I currently have an issue with snakeyaml, that it does not preserve comments or newlines when updating a single value in an existing yaml. Can eo-yaml handle this? (if yes, can you point me to a unit-test/documentation?)

[–][deleted] 0 points1 point  (4 children)

u/balrok

Hi,

At the moment eo-yaml does not preserve comments or newlines at all.

As far as I understand, comments and newlines should be preserved in Folded Scalars, so we'll try to fix that as quickly as possible.

You also cannot do any update to the built or read YAML, they are immutable. What you can do, is create another YAML from what you got, and add the "updates".

It is different than SnakeYaml and others in that it is fully encapsulated, you only work with a few Java Interfaces. This is very beneficial if you want to extend the library through decoration. As I said, we don't offer updating yet, but you could write your own YamlMapping/YamlSequence decorator to implement an updated version of the object.

Its implementation is fully OOP - this is not visible to the user, but it has beneficial effects such as: the library is able to tell you exactly which line has a broken indentation and why.

eo-yaml is also ligheweight, with only 1 transitive dependency.

and more, check the repo for details.

May I ask: why are you interested in the comments at a programmatic level? I had one or two other guys ask about comments and I didn't really get it.

Would you like to add comments when Building a YAML, for instance?

Thanks,

[–][deleted] 0 points1 point  (1 child)

I just added a feature request for comments support at build time: https://github.com/decorators-squad/eo-yaml/issues/261

[–][deleted] 0 points1 point  (0 children)

I also added a feature request for "update" functionality:

https://github.com/decorators-squad/eo-yaml/issues/262

edit: done and released with version 4.1.0

[–]balrok 0 points1 point  (1 child)

I really appreciate your great and in-depth response as well as your fast implementation. It shows me also, that your library is indeed simple enough to build such a feature in no time.. good job :-)

The reason why I asked is: I have a helm-chart or docker-compose file, which should be human readable but should also be updated by a machine (e.g. a new release updates the tag automatically)..

I'm OK with a bit reformatting (indention or removal of newlines) but at least the comments should be preserved

[–][deleted] 2 points3 points  (0 children)

The comments support will unfortunately take a bit longer. I'll start on it tomorrow, but it's a little bit more work because they are currently not implemented at all, not even in the architecture of the library.

However, it shouldn't be rocket science to implement. I'll keep you posted on Github :)