Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psych::Nodes::Scalar::LITERAL ignored in encode_with? #673

Open
akunszt opened this issue Jun 26, 2024 · 0 comments
Open

Psych::Nodes::Scalar::LITERAL ignored in encode_with? #673

akunszt opened this issue Jun 26, 2024 · 0 comments

Comments

@akunszt
Copy link

akunszt commented Jun 26, 2024

This could just me, but I really lost and I don't understand why this works this way.

I have a big YAML with various string values. One of them is an encoded file content which is nice for machine consumption but I want to show that as a literal for human beings.

I created a separate class for those values and I added an encode_with method.

                def encode_with( coder )
                        coder.scalar = @str                                                                                                                                 
                        coder.tag = "!file_content"
                        coder.style = Psych::Nodes::Scalar::LITERAL
                end

When the value is short then it works as expected but if it is longer then output is still quoted.

---
hello: world
short: !file_content |
  TEST_DOCKER_IMAGE="foobar/image:1.2.3-r4"
long: !file_content "!\n! %[CONN_NAME]\n!\nneighbor %[REMOTE_ADDRESS] remote-as %[REMOTE_ASN]\nneighbor
  %[REMOTE_ADDRESS] description %[CONN_NAME]\naddress-family ipv6\n\tneighbor %[REMOTE_ADDRESS]
  activate\n\tneighbor %[REMOTE_ADDRESS] soft-reconfiguration inbound\n\tneighbor
  %[REMOTE_ADDRESS] prefix-list ipv6_ranges in\n\tneighbor %[REMOTE_ADDRESS] prefix-list
  ipv6_ranges out\n\tneighbor %[REMOTE_ADDRESS] route-map add_extra_hop in\n\tneighbor
  %[REMOTE_ADDRESS] route-map no_advertise_self out\nexit-address-family\n"

The documentation is quite scarce about this topic. Do I miss something? Or is this a bug in Psych?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant