RQL for Ruby

This is a port of Kris Zyp's RQL (Resource Query Language) to Ruby.

Installation

$ gem install rql

The current parser uses ExecJS to run the RQL javascript parser. While ExecJS is generally good about using the best available javascript runtime, it's recommended that you use either:

To specify therubyracer runtime:

require 'rql'
require 'v8'

Rql.runtime = ExecJS::RubyRacerRuntime.new

To specify therubyrhino runtime under JRuby

require 'rql'
require 'rhino'

Rql.runtime = ExecJS::RubyRhinoRuntime.new

Usage

require 'rql'
query = Rql['id=5&name=foo']

data = [
     {"id" => 1, "name" => "foo"},
     {"id" => 5, "name" => "foo"}        
]

query.on(data) #=> [{"id" => 5, "name" => "foo"}]

Notes

You should keep the following in mind: