YAML parsing and emitting for the ooc language. Powered by LibYAML.
ooc
Switch branches/tags
Nothing to show
Pull request Compare This branch is 46 commits ahead of joshthecoder:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
samples
source/yaml
.gitignore
.travis.yml
LICENSE
README.md
yaml.use

README.md

Build Status

ooc-yaml

An ooc binding for the libyaml parser and emitter.

Example parsing

First, use the yaml package and import everything you need:

use yaml
import yaml/[Parser, Document, Utils]

Then, create a parser and set it up with your input:

parser := YAMLParser new(File new("bottle.yml"))
doc := parser parseDocument()

Get the root node:

root := doc getRootNode()

And then iterate through it to find your values. Example for a map:

root each(|k, v|
    "Got key #{k}" println()
)

For a list:

root each(|node|
    "Got node #{node _}" println()
)

Note that _ is a shortcut to convert a scalar node to a string.

The yaml/Utils module contains other useful shortcuts - you can index any DocumentNode like this:

// as a map
node["somekey"]

// as a list
node[23]

See the samples/ directory for custom callbacks, multiple documents, etc.

Authors

  • Joshua Roesslein (aka @joshthecoder)
  • Amos Wenger (aka @nddrylliog)

License

ooc-yaml is distributed under the MIT license. See the LICENSE file for more details.

Links