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.

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.age
puts eyal.eye
puts eyal.class

# 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.eye} eyes"
end

# find all people aged 27
almost_thirties = TEST::Person.find_by_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. To follow the development and read tips-and-tricks on ActiveRDF, please check our new weblog.

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 the paper presented at the SFSW workshop.

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 check out the latest code with "bzr get http://www.eyaloren.org/activerdf". You can also follow our progress with the launchpad web interface. Bazaar is decentralised, so just make any code changes you want, publish your branch somewhere 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, in collaboration with the TecWeb Lab at PUC-Rio.