Comparing
version 48 and
version 47 backh1. Overview
ActiveRDF is a library for accessing RDF data from Ruby programs. It can be used as data layer in Ruby-on-Rails, in the same way as you can use ActiveRecord for accessing relational databases. Using ActiveRDF with Ruby-on-Rails allows you to create semantic web applications very rapidly. ActiveRDF gives you a domain specific language for your RDF model: you can address RDF resources, classes, properties, etc. programmatically, without queries.
* ActiveRDF can be used with various RDF stores, more adapters are easy to add
* ActiveRDF uses convention over configuration, working nicely in 90% of the cases
* ActiveRDF is in active development
* ActiveRDF is open source, released under LGPL license
h1. Getting started
Check out our [[GettingStartedGuide]] which shows you:
* how to install ActiveRDF and its adapters
* how to read and write to RDF triple stores
* how to create a Ruby on Rails application that gets its data from a triple store
h1. Frequently Asked Questions (FAQ)
For those nagging and important questions about ActiveRDF, please see our [[FrequentlyAskedQuestions]].
If you are confused by RDF, because it is so different from everything you know about databases, then please do not hesitate and read our introduction of RDF concepts and how they relate to ActiveRDF. It can be found here: [[IntroRDF]]
h1. Example
h2. 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
h2. Find resources
require 'active_rdf'
# we add an existing SPARQL database as datasource
ConnectionPool.add_data_source :type => :sparql, :url => "http://m3pe.org:8080/repositories/test-people", :results => :sparql_xml
# 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}"