Project

ytools

0.0
No commit activity in last 3 years
No release in over 3 years
Installs the ypath tool for reading YAML files using an XPath-like syntax. Installs the ytemplates tool for turning YAML-based configuration files into other files using erb temlates.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0.4.4
 Project Readme

YTools

These are a couple of YAML-based tools for working with configuration files.

YPath

The first tool, ypath, be used to pull values from a YAML configuration and print them to STDOUT. It's quite useful if you need to use the YAML as a configuration and only pull out individual values for your other scripts to use.

Say you have a YAML configuration file like:

project:
    name: C.proj
    dependencies:
        - A.proj
        - B.proj

You could then pull out the project name 'C.proj' by running

ytools -p /project/name YAML_FILE

You could even list all of the dependencies by running

ytools -p /project/dependencies YAML_FILE

which would print

A.proj
B.proj

YTemplates

The second tool, ytemplates, be used to generate configuration files that use YAML files as the backing object binding. A simple use case might be that you need a configuration file generated for an environment, and you can break out the environment-specific values into different YAML files. In this case, you could create a file for each environment, one for production

environment: production
database:
    host: production.host.com
    username: produser
    password: imsecret

and another for testing

environment: testing
database:
    host: internal-testing.host.com
    username: testuser
    password: imsecret

With those files, you could then create an ERB template to pull in the relevant values like:

<settings environment="<%= environment =>">
    <database>
        <host><%= database.host %></host>
        <username><%= database.username %></username>
        <password><%= database.password %></username>
    </database>
</settings>

Using ytemplates, you could then generate a different environment file from each yaml file, but only have to manage one actual configuration file. Obviously, this becomes much more useful when the number of environments grows and the number of changes in the configuration files goes down relative to file's size.

Downloading

You can download the gem using

gem install ytools