SIOC/SIOC and Ruby

From W3C Wiki

Using SIOC data with Ruby and Ruby on Rails

This guide shows you how to use SIOC data with Ruby and Ruby on Rails.

SIOC data is expressed using the Resource Description Format (RDF), and in order to access RDF data in Ruby you will have to use ActiveRDF.

ActiveRDF gives you an object oriented abstraction layer for accessing RDF. In stead of manipulating triples, RDF entities get mapped to Ruby objects and their properties can be accessed through methods with the same name. Actually, you really do not have to worry about how to access RDF data if you use ActiveRDF, just like you do not have to worry much about SQL if you use ActiveRecord to access a data base.

ActiveRDF has in fact been designed as a drop-in for ActiveRecord. Your Rails application should not be able to tell the difference between using ActiveRecord as the Model (the M in MVC) or ActiveRDF. You can even use both libraries at the same time.

This Howto gives you pointers for the following:

  • installing ruby and activerdf
  • accessing SIOC data provided by a SIOC exporter in Ruby
  • building a small Ruby on Rails application to access the same SIOC data

Installing Ruby and ActiveRDF

The first step is installing Ruby and ActiveRDF, as well as the Redland RDF library. These steps are described in the ActiveRDF Getting Started Guide.

Please refer to the instructions for your operating system (Linux, Mac OS X and Windows are currently described, for other unix like operating systems take a look at the Mac OS X instructions).

You need to install Ruby, rubygems, redland and the redland language bindings, and Ruby on Rails (if you want to use it later.)


Accessing SIOC data from Ruby

We will now access some basic SIOC data, which is provided by a SIOC exporter (like the wordpress SIOC exporter).