Skip to content

For reading, interacting with, and saving YAML files in Ruby

Notifications You must be signed in to change notification settings

wyattdanger/YAML-Reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yaml Reader

Written for fun one evening as an exercise in Ruby. My goal was an easy way to load any YAML file and interact with it using dot notation.

Perhaps you have a YAML file:

---
title: Amazing Content

Instantiate a YAML Reader object

yaml = YAMLReader.new 'path/to/yaml_file.yaml'

Fetch data from the file

yaml.title
# "Amazing Content"

Add and update data

yaml.title = "Even More Amazing Content!"
yaml.description = "..."

yaml.title
# "Even More Amazing Content!"

yaml.description
# "..."

Dump the data to string to be written to new YAML file

yaml.dump

# ---
# title: Even More Amazing Content!
# description: ...

Write the updated YAML data to file

yaml.save_as '/path/to/new_yaml_file.yaml'
# true
yaml.save
# true

About

For reading, interacting with, and saving YAML files in Ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages