Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby Virtuoso repository adapter for RDF.rb
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
etc Use some test data
lib/rdf updated to RDF.rb 1.1
spec updated to RDF.rb 1.1
.gitignore updated specs
Gemfile Initial commit updated specs
Rakefile Initial commit
rdf-virtuoso.gemspec updated to RDF.rb 1.1

rdf-virtuoso: Ruby Virtuoso adapter for RDF.rb

The intent of this class is to act as an abstraction for clients wishing to connect and manipulate linked data stored in a Virtuoso Quad store.


RDF::Virtuoso::Repository subclasses RDF::Repository built on RDF.rb and is the main connection class built on top of APISmith to establish the read and write methods to a Virtuoso store SPARQL endpoint. RDF::Virtuoso::Query subclasses RDF::Query and adds SPARQL 1.1. update methods (insert, delete, aggregates, etc.).

For examples on use, please read: ./spec/repository_spec.rb and ./spec/query_spec.rb

A simple example

This example assumes you have a local installation of Virtoso running at standard port 8890

Setup Repository connection connection with auth

uri        = "http://localhost:8890/sparql"
update_uri = "http://localhost:8890/sparql-auth"
repo       =, 
                :update_uri => update_uri, 
                :username => 'admin', 
                :password => 'secret', 
                :auth_method => 'digest')

:auth_method can be 'digest' or 'basic'. a repository connection without auth requires only uri

INSERT WHERE query example

QUERY = RDF::Virtuoso::Query
graph ="")
subject ="http://subject")

query = QUERY.insert([subject, :p, "object"]).graph(graph).where([subject, :p, :o])
result = repo.insert(query)

A count query example

New prefixes can either extend the RDF::Vocabulary class (best if you want to model yourself:

module RDF
  class FOO < RDF::Vocabulary("");end
  class BAR < RDF::Vocabulary("");end

it can then be easily accessed by RDF superclass, eg.

=> #<RDF::URI:0x4d273ec(> 
=> #<RDF::URI:0x4d294ee(> 

or you can dynamically add RDF::Vocabulary objects

foo ="")

QUERY  = RDF::Virtuoso::Query
graph  ="")

query  =[:s,, :o]).count(:s).graph(graph)
result =

Results will be an array of RDF::Query::Solution that can be accessed by bindings or iterated

count = result.first[:count].to_i
Something went wrong with that request. Please try again.