读写yaml文件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

require 'yaml'

hash = {1 => 'sqlite3', 2 => 'postgresql', 3 => 'mssql', 4 => 'mysql', 5 => 'oracle'}

# write yaml file
File.open("/home/user002/data.yaml", "wb") {|f| YAML.dump(hash, f) }

# read yaml file
data = YAML.load_file("/home/user002/data.yaml", "rb")