Project

yurl

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
An application to query data from a YAML file trying to mirror curl functionality
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.4
~> 1.15
~> 2.4
~> 10.0
~> 3.0
~> 0.19

Runtime

~> 2.2
 Project Readme

Yurl

Welcome to yurl, a ruby gem inspired by a problem and a conversation. The problem - the abundance of YAML files in Rails, Cloud Foundry, Docker and whatever your favorite tool is. I wanted a way to easily access the information in these files, without having to have multiple tabs open in my text editor. After looking at vault.io (way too much overhead) and creating config servers in both Spring and Node-red (boo java && javascript), a conversation with an intern (Thanks Nick T) led me to a much simpler solution (KISS always works). Yurl (Yaml Url) is a command line tool that attempts to mirror the curl/REST interface to query information from YAML files.

Yurl is both my first ruby gem and open source project of any kind, it was and continues to be a great learning experience. I plan to refactor and implement new features so please excuse the bugs, weird commits and bad code(lol) and feel free to contribute.

Installation

Add this line to your application's Gemfile:

gem 'yurl'

And then execute:

$ bundle

Or install it yourself as:

$ gem install yurl

Usage

Given a directory with YAML file named "info.yaml" with contents:

Production:
    Database:
        username: foo
        password : bar
        Parameter With Spaces:
            value: Some More Foo

Dump

This command is used to dump the contents of a yaml file to STD:OUT

$ yurl dump --path=info.yml
#=> {"Production"=>{"Database"=>{"username"=>"foo", "password"=>"bar", "Parameter With Spaces"=>{"value"=>"Some More Foo"}}}}

To pretty print the contents of the YAML file

$ yurl dump --pp --path=info.yml
#=> {"Production"=>
        {"Database"=>
            {"username"=>"foo",
            "password"=>"bar",
            "Parameter With Spaces"=>{"value"=>"Some More Foo"}}}}

Get

This command is used to access the data at a certain node in the YAML file. To access nested content use a '/' to descend the different nested levels.

$ yurl get --path=info.yml Production
#=> "Database"=>{"username"=>"foo", "password"=>"bar", "Parameter With Spaces"=>{"value"=>"Some More Foo"}}}

$ yurl get --path=info.yaml Production/Database/username
#=> "foo"

If your YAML fields have spaces enclose them in "" i.e

$ yurl get --path=info.yml "Production/Database/Parameter With Spaces"
#=> {"value"=>"Some More Foo"}

AKA

Yurl also has the ability to store paths to yaml files as "also known as" (AKA). In order to shorten the length of commands to access YAML data. To add a element to the AKA List:

$ yurl add info ./info.yaml
#=> Added AKA - info with path ./info.yml

$ yurl add "aka with spaces" info.yml
#=> Added AKA - aka with spaces with path info.yml

To list the current AKA's

$ yurl list
#=> {"AKA List"=>"Add Some AKAs", "aka with spaces"=>"info.yml", "info"=>"info.yml"}

To remove an AKA

$ yurl remove "AKA List"
#=> Deleted AKA - AKA List

$ yurl list
#=> {"aka with spaces"=>"info.yml", "info"=>"info.yml"}

Then YAML information can be queried as such

$ yurl get --aka=info "Production/Database/Username"
#=> "foo"

$ yurl get --aka="aka with spaces" "Production/Database/username"
#=> "foo"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/abll/yurl. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Yurl project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.