Skip to content

Instantly share code, notes, and snippets.

@minoritea
Last active August 29, 2015 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minoritea/646cc02c4a033a38f943 to your computer and use it in GitHub Desktop.
Save minoritea/646cc02c4a033a38f943 to your computer and use it in GitHub Desktop.

#TOMLの仕様の翻訳をした話

@snowcrush #tqrk09


TOMLとは

TOML aims to be a minimal configuration file format
that's easy to read due to obvious semantics.
TOML is designed to map unambiguously to a hash table.
TOML should be easy to parse into data structures
in a wide variety of languages.

--

TOMLは明瞭なセマンティクスを持ち、可読性の高い、
ミニマルな設定ファイルフォーマットとなることを目的として作られています。
TOMLは曖昧さなしに連想配列に変換できるよう設計されていて、
様々な言語上でそれらのデータ構造に展開することが出来ます。

TOMLとは

  • 設定ファイルのためのドキュメント・フォーマット
  • ぶっちゃけ、.iniファイル風にかけるJSON

フォーマット

# This is a TOML document.

title = "TOML Example"

[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dates

[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8002 ]
connection_max = 5000
enabled = true

#翻訳 最初qiitaに


#本家にマージされました!


どこで知ったのか

Rust言語勉強中です!(最近さぼっている)

  • Cargo(RustのBundlerみたいなやつ)の設定ファイルをかける
  • 後、Go製ツールでTOML採用しているのが結構あります
  • その他
    • Cargo, InfluxDB, Heka, Hugo, bloom.api, MeTA

なんで翻訳しようと思ったのか

  • 仕様がシンプルなのが売り => ドキュメントもシンプル
  • まだ誰も翻訳してなかった

#翻訳するところの苦労

  • とくになし・・・?

#実際は

  • わりとJSONの知識を前提にしている
  • 日付はRFC 3339に丸投げ
  • 浮動小数点型のあたり
    • 仮数部、整数部ともにintegerパートと表記されている
  • キーとバリューの説明が後半まで無い

Ruby実装

https://github.com/emancu/toml-rb

https://github.com/fbernier/tomlrb


まだ、仕様がどんどん変わっている

  • v0.4.0 が最新
  • どんどんプルリク投げよう
  • 日本語版にもプルリク上げていただけると多分通ります
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment