读写yaml文件

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")

编程技巧