YAML in, YAML out -- general questions / guidance
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')
精彩评论