-
-
Save rogerleite/4162920 to your computer and use it in GitHub Desktop.
Ruby Query Language *snaky edition*
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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