Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#673 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
ruby
領域
backend

調査の方向性

まず、カスタムクラスの encode_with メソッドを使い、coder.scalar、coder.tag、および Psych::Nodes::Scalar::LITERAL を設定して、短い YAML 出力と長い YAML 出力を再現します。Psych がスカラーの長さとエスケープされた改行をどのように扱うかを比較し、その後、文書化された動作と生成された出力のどちらが誤っているのかを判断します。完了条件は、原因が説明され、焦点を絞った回帰テストまたはドキュメント変更が特定されていることです。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
Ruby
スター
597
フォーク
223
平均マージ
11時間 23分
マージ済み PR(30日)
3

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/psych のほかの issue

ruby/psych の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。