开发者

YAML in, YAML out -- general questions / guidance

开发者 https://www.devze.com 2023-03-08 00:08 出处:网络
I have a survey application that I build surveys in by hand, and I want to add an option to build surveys by file, yaml seems fit the needs of开发者_StackOverflow社区 this application. I\'d like to up

I have a survey application that I build surveys in by hand, and I want to add an option to build surveys by file, yaml seems fit the needs of开发者_StackOverflow社区 this application. I'd like to upload a yaml file, and then outputting a yaml file from previously built surveys would be nice.

Looking around, I haven't found the tutorial I need for learning how to parse a yaml file into a several db objects (answers, answer areas, answer types, various other things about the survey, etc).

I'm wondering if anyone has any tips, guides, or some wonder tool/plugin that I haven't seen yet, etc.

Just a thought any input appreciated.


Your YAML file will turn into a nested data structure. Each level will be either an Array or a Hash. It's probably easiest to just #pp() it and take a look to get started.

require 'pp'
require 'yaml'

pp YAML.load_file('f.yaml')
0

精彩评论

暂无评论...
验证码 换一张
取 消