0.0
No commit activity in last 3 years
No release in over 3 years
A Psych extension to enable choosing output styles for specific objects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

💄 styled-yaml

A Psych extension to enable choosing output styles for specific objects.

Usage

require 'styled_yaml'
require 'yaml'

recipe = {
  'name' => StyledYAML.double_quoted(+'Fruit Salad'),
  'link' => StyledYAML.single_quoted(+'http://bad.recipes/salad'),
  'ingredients' => StyledYAML.inline(%w[apple pear orange]),
  'steps' => StyledYAML.literal(+<<~STEPS
    1. Dice the fruit into bit size pieces.
    1. Combine the fruit in a bowl.
    1. Enjoy!
  STEPS
  )
}

puts YAML.dump(recipe)
puts StyledYAML.dump(recipe)
---
name: Fruit Salad
link: http://bad.recipes/salad
ingredients:
- apple
- pear
- orange
steps: |
  1. Dice the fruit into bit size pieces.
  1. Combine the fruit in a bowl.
  1. Enjoy!
---
name: "Fruit Salad"
link: 'http://bad.recipes/salad'
ingredients: [apple, pear, orange]
steps: |
  1. Dice the fruit into bit size pieces.
  1. Combine the fruit in a bowl.
  1. Enjoy!

Acknowledgments