Project

yqr

0.0
No commit activity in last 3 years
No release in over 3 years
YAML Query is written in ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
>= 0
~> 10.0
 Project Readme

MIT licensed
Build Status

Yqr

Yaml query executer is written in ruby.

Installation

Add this line to your application's Gemfile:

gem 'yqr'

And then execute:

$ bundle

Or install it yourself as:

$ gem install yqr

Installation (Option)

By using Hashie gem together, even simpler access becomes possible.

Usage

$ cat example1.yaml
---
cat:
- mike
- buchi
dog:
- pochi
- koro

$ yqr --file example1.yaml [dog][0]
pochi

$ cat example2.yaml
---
- name: mike
  kind: cat
- name: pochi
  kind: dog
- name: buchi
  kind: cat
- name: koro
  kind: dog

$ yqr ".find{|a| a[kind] == 'dog'}[name]" < example2.yaml
pochi

$ cat example2.yaml | bundle exec yqr ".select{|a| a[kind] == 'cat'}.last[name]"
buchi

Usage (Output-type)

$ cat example4.yaml
---
cat:
  - name: mike
    sex: male
  - name: tama
    sex: female

# Default output type is yaml
$ yqr --file example4.yaml "[cat].first"
---
:name: mike
:sex: male

# Raw output type (Object.to_s)
$ yqr --file example4.yaml --raw "[cat].first"
{:name=>"mike", :sex=>"male"}

# Json output type
$ yqr --file example4.yaml --json "[cat].first"
{"name":"mike","sex":"male"}

Enable Hashie access

if you install Hashie gem, you can also use query as:

$ yqr --file example4.yaml ".cat.first"
---
:name: mike
:sex: male

$ yqr --file example4.yaml --raw ".cat.first"
#<Hashie::Mash name="mike" sex="male">

Contributing

git-flow.