Overview

ActiveRDF is a library for accessing RDF data from Ruby programs. It can be used as data layer in Ruby-on-Rails, similar to ActiveRecord (which provides an O/R mapping to relational databases). ActiveRDF in RoR allows you to create semantic web applications very rapidly. ActiveRDF gives you a Domain Specific Language (DSL) for your RDF model: you can address RDF resources, classes, properties, etc. programmatically, without queries.

The development of ActiveRDF was inspired and influenced by the work on model-driven web development of prof. Daniel Schwabe and his group on SHDM and HyperDE.

Examples

Create and edit people

# we load activerdf
require 'active_rdf'

# we add an existing SPARQL database as datasource
ConnectionPool.add_data_source(:type => :sparql, :results => :sparql_xml,
 :url => "http://m3pe.org:8080/repositories/test-people") 

# we register a short-hand notation for the namespace used in this test data 
Namespace.register :test, 'http://activerdf.org/test/'

# now we can access all RDF properties of a person as Ruby attributes:
eyal = RDFS::Resource.new 'http://activerdf.org/test/eyal'
puts eyal.test::age
puts eyal.test::eye
puts eyal.rdf::type

# now we construct Ruby classes for the currently existing RDFS classes
ObjectManager.construct_classes

# and we can use these classes
armin = TEST::Person.new 'http://armin-haller.com/#me'

# we cannot change anything, since SPARQL endpoints have just read-only access

Find resources

require 'active_rdf'

# we add an existing SPARQL database as datasource
ConnectionPool.add_data_source(:type => :sparql, :results => :sparql_xml,
 :url => "http://m3pe.org:8080/repositories/test-people") 

# we register a short-hand notation for the namespace used in this test data 
Namespace.register :test, 'http://activerdf.org/test/'
ObjectManager.construct_classes

all_people = TEST::Person.find_all
all_resources = RDFS::Resource.find_all

# print all the people, and their friends
all_people.each do |person|
  puts "#{person} has #{person.test::eye} eyes"
end

# find all people aged 27
almost_thirties = TEST::Person.find_by_test::age(27)
puts "the following people are almost thirty: #{almost_thirties}"

Documentation

The wiki should be your starting point for documentation. You can read the RDoc API documentation online.

For a more general discussion on object-oriented access to RDF data, a comparison to other approaches and the advantages of a dynamic language such as Ruby, please see our WWW paper or the older SFSW workshop paper.

Download

You can install ActiveRDF and the adapters as a gem: "gem install activerdf" and then for example "gem install activerdf_rdflite". Do "gem search -r activerdf" to see all available adapters.

We use bazaar for source control. You can see all registered ActiveRDF branches on launchpad.net. You can check out the main branch with "bzr branch http://bazaar.launchpad.net/~activerdf/activerdf/trunk". To contribute to this branch, register with launchpad and add yourself to the ActiveRDF team. But bazaar is also decentralised, so you can just make any code changes you want locally, publish your branch somewhere online and send us an email.

Contact

Please report bugs or feature requests in our launchpad bug repository, and use the mailinglist for questions, feature requests, or any other discussion. ActiveRDF is developed by Eyal Oren, Renaud Delbru, Sebastian Gerke, and Benjamin Heitmann from DERI, supported by Science Foundation Ireland under Grant No. SFI/02/CE1/I131.

SFI logo DERI logo