DataMapper RDF.rb Adapter

This is a DataMapper plugin that provides an adapter supporting RDF.rb-based storage systems.

About DataMapper

About RDF.rb

Examples

require 'dm-rdf'

Using an in-memory RDF repository (1)

DataMapper.setup(:default, :adapter => 'rdf')

Using an in-memory RDF repository (2)

DataMapper.setup(:default, {
  :adapter    => 'rdf',
  :repository => RDF::Repository.new,
})

Using an in-memory RDF repository with initial N-Triples data

require 'rdf/ntriples'

DataMapper.setup(:default, {
  :adapter    => 'rdf',
  :repository => RDF::Repository.load("etc/doap.nt"),
})

Using a Sesame repository (1)

Requires RDF::Sesame.

require 'rdf/sesame'

DataMapper.setup(:default, {
  :adapter    => 'rdf',
  :repository => RDF::Sesame::Repository,
  :url        => 'http://localhost:8080/openrdf-sesame/repositories/mem-rdf',
})

Using a Sesame repository (2)

DataMapper.setup(:default, {
  :adapter    => 'rdf',
  :repository => RDF::Sesame::Repository,
  :options    => {
    :server   => RDF::Sesame::Server.new('http://localhost:8080/openrdf-sesame'),
    :id       => 'mem-rdf',
  },
})

Using an RDFcache repository

Requires RDFcache.

require 'rdfcache'

DataMapper.setup(:default, {
  :adapter    => 'rdf',
  :repository => RDFcache::Repository,
  :url        => 'gdbm://default.db',
})

Defining the RDF type of a model class (1)

class Post
  include DataMapper::Resource
  rdf :type => RDF::SIOC.Post
end

Defining the RDF type of a model class (2)

class Post
  include DataMapper::Resource
  rdf_type RDF::SIOC.Post
end

Defining the RDF type of a model class (3)

class Post
  include DataMapper::RDF::Resource(RDF::SIOC.Post)
end

Defining the RDF vocabulary of a property

class Post
  property :title, String, :vocabulary => RDF::DC
end

Defining the RDF predicate of a property

class Post
  property :title, String, :predicate => RDF::DC.title
end

Defining multiple RDF-compatible properties

class Post
  vocabulary RDF::DC
  property :title,       String
  property :description, String
end

Documentation

Dependencies

Installation

The recommended installation method is via RubyGems. To install the latest official release from Gemcutter, do:

% [sudo] gem install dm-rdf-adapter

Download

To get a local working copy of the development repository, do:

% git clone git://github.com/bendiken/dm-rdf.git

Alternatively, you can download the latest development version as a tarball as follows:

% wget http://github.com/bendiken/dm-rdf/tarball/master

Resources

Authors

License

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.