ruby怎么安装yml

Python010

ruby怎么安装yml,第1张

首先用一个在Rails开发中一定会遇到的YAML文件——database.yml——作为示例。在你创建一个Rails工程后,Rails会自动给你创建一个这样的文件,它的路径是config/database.yml:

# MySQL (default setup). Versions 4.1 and 5.0 are recommended.

# 此处省略一些注释。

development:

adapter: mysql

database: demo_development

username: root

password:

host: localhost

# Warning: The database defined as 'test' will be erased and

# re-generated from your development database when you run 'rake'.

# Do not set this db to the same as development or production.

test:

adapter: mysql

database: demo_test

username: root

password:

host: localhost

production:

adapter: mysql

database: demo_production

username: root

password:

host: localhost

title: THE PROBLEMS OF PHILOSOPHY

author: Bertrand Russell

这种双引号前后一闭合,管你多长的字符通通放一行,中间还可能插入各种恶心转义字符例如\\n

可读性真的很差。python/node.js/ruby/java的yaml库都翻了遍,python比较接近*1

。各种库对输入的parse/load都很强大,但是反过来输出yaml时,就开始变成各种反人类亲机器的文件格式,完全抛弃yaml的可读性。

求推荐yaml库,可通过简单的设置或者扩展,自定义长字符串以区块的形式的输出,多于80列则自动换行,如下

title: THE PROBLEMS OF PHILOSOPHY

author: Bertrand Russellpreface:In the following pages I have confined myself in the main to those problems of

或者是扩展性比较高的格式化输出工具。