トップ 新規 一覧 検索 ヘルプ RSS ログイン

Ya2YAMLの変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
This form of viral marketing is both FREE, and easy, http://geocities.com/WhitneyStory/freegirlsgonewild Freegirlsgonewild
 8PPP, http://geocities.com/thomaswarren46/pantiesetc Pantiesetc
 :-OO, http://geocities.com/WhitneyStory/ze5170crash Ze5170 Crash
 =OOO, http://geocities.com/marywood89/frandango Frandango
 8-DD, http://geocities.com/golden.carrie/baltimoreoriloes Baltimore Oriloes
 476, http://geocities.com/mccantsalan/creeklandmiddleschool Creekland Middle School
 2268, http://geocities.com/helenwood88/plvcartonalveolaire Plv Carton Alveolaire
 5370, http://geocities.com/westgatec/leslovemissiles Leslovemissiles
 yuiomh, http://geocities.com/jamescruz67/schwabingerpodium Schwabinger Podium
 vshzg, http://geocities.com/ClaraUgalde/messagetemplateresourcenamerssfeed Messagetemplateresourcename Rss Feed
 %PPP, http://geocities.com/ramos_z/calvenandhobbes Calven And Hobbes
 qkggz, http://geocities.com/cory.cardwell/endometriosos Endometriosos
 itje, 
任意のオブジェクトをYAML形式に変換するライブラリ。pure ruby。

https://rubyforge.org/projects/ya2yaml/

標準添付のYAMLライブラリには、マルチバイト文字列をbinary形式として出力してしまう問題([[ruby-list:42204]])があるが、こちらのライブラリを使えばマルチバイト文字列をそのままYAML内へ出力することができる。日本語の出力もOK。

ただしYAMLを読み込む(パースする)機能は持っていないため、読み込みには別のライブラリを使う必要がある。


!!! 使い方
(READMEより転載)

 $KCODE = 'UTF8'
 require 'ya2yaml'
 
 obj = [
   "abc\nxyz\n",
   "日本語\n文字列\n",
   "\xfd\xfe\xff",
 ]
 puts obj.ya2yaml(:syck_compatible => true)


 --- 
 - |
     abc
     xyz
 - |
     日本語
     文字列
 - !binary |
     /f7/

!!! 既知のバグ
* ==複数のドキュメントを一つのyamlファイルに出力し、rubyに標準添付のyamlライブラリで(YAMLストリームとして)読み込むと、エラーで落ちる。==→最新版では修正されている