View on GitHub

Sparql-client

SPARQL client for Ruby.

Download this project as a .zip file Download this project as a tar.gz file

SPARQL Client for RDF.rb

This is a Ruby implementation of a SPARQL client for RDF.rb.

Gem Version Build Status

Features

Examples

Querying a remote SPARQL endpoint

require 'sparql/client'

sparql = SPARQL::Client.new("http://dbpedia.org/sparql")

Querying a RDF::Repository instance

require 'rdf/trig'
repository = RDF::Repository.load("http://example/dataset.trig")

sparql = SPARQL::Client.new(repository)

Executing a boolean query and outputting the result

# ASK WHERE { ?s ?p ?o }
result = sparql.ask.whether([:s, :p, :o]).true?

puts result.inspect   #=> true or false

Executing a tuple query and iterating over the returned solutions

# SELECT * WHERE { ?s ?p ?o } OFFSET 100 LIMIT 10
query = sparql.select.where([:s, :p, :o]).offset(100).limit(10)

query.each_solution do |solution|
  puts solution.inspect
end

Executing a graph query and iterating over the returned statements

# CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o } LIMIT 10
query = sparql.construct([:s, :p, :o]).where([:s, :p, :o]).limit(10)

query.each_statement do |statement|
  puts statement.inspect
end

Executing an arbitrary textual SPARQL query string

result = sparql.query("ASK WHERE { ?s ?p ?o }")

puts result.inspect   #=> true or false

Documentation

Dependencies

Installation

The recommended installation method is via RubyGems. To install the latest official release of the SPARQL::Client gem, do:

% [sudo] gem install sparql-client

Download

To get a local working copy of the development repository, do:

% git clone git://github.com/ruby-rdf/sparql-client.git

Alternatively, download the latest development version as a tarball as follows:

% wget http://github.com/ruby-rdf/sparql-client/tarball/master

Mailing List

Authors

Contributors

Contributing

This repository uses Git Flow to mange development and release activity. All submissions must be on a feature branch based on the develop branch to ease staging and integration.

Resources

License

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying {file:UNLICENSE} file.