Skip to content

Instantly share code, notes, and snippets.

@rogerleite
Created November 28, 2012 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerleite/4162920 to your computer and use it in GitHub Desktop.
Save rogerleite/4162920 to your computer and use it in GitHub Desktop.
Ruby Query Language *snaky edition*
#!/usr/bin/env ruby
# Ruby Query Language *snaky edition*
# usage: ./rql sample.rql
module RQL
class Context
def self.evaluate(rql_script)
context = self.new
context.instance_eval(rql_script)
context
end
def save(obj, attrs)
puts "=> #{attrs.inspect} on #{obj.inspect}"
end
end
def self.run(rql_file)
rql_content = File.read(rql_file)
Context.evaluate(rql_content)
end
end
puts %{\n# Ruby Query Language *snaky edition*\n}
RQL.run(ARGV[0])
# Ruby Query Language *snaky edition*
save :resource, {:attr1 => "v1", :attr2 => "v2"}
save :resource, {:attr1 => "v11", :attr2 => "v22"}
save :resource, {:attr1 => "v111", :attr2 => "v222"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment