Sha256: 2f4be7f8e6897f82556c9d8a1fb2805ef41c870038e46ab6439f491324d2b3dd

Contents?: true

Size: 1.94 KB

Versions: 3

Compression:

Stored size: 1.94 KB

Contents

= Description

Redlander is Ruby bindings to Redland library (see http://librdf.org). This is an alternative implementation of the bindings, aiming to be more intuitive, lightweight and less buggy.

= Installing

Installing Redlander is simple:

  $ gem install redlander

Note, that you will have to install Redlander (librdf) for Redlander to work.

= Usage

To start doing anything with Redland, you need to initialize a model first:

  $ m = Redlander::Model.new

This creates a model where all RDF statements are stored in the memory. Depending on the selected storage you may need to supply extra parameters like :user or :password. Look-up the options for Storage.initialize_storage method for the list of storage options.

Now that you have created a model, you can access its RDF statements:

  $ m.statements

Most of Redlander functionality is accessable via these statements. The API is almost identical to ActiveRecord:

  $ s = URI.parse('http://example.com/concepts#subject')
  $ p = URI.parse('http://example.com/concepts#label')
  $ o = "subject!"
  $ m.statements.create(:subject => s, :predicate => p, :object => o)

  $ m.statements.empty?  # => false

  $ st = Redlander::Statement.new(:subject => s, :predicate => p, :object => "another label")
  $ m.statements.add(st)

  $ m.statements.size    # => 2

  $ m.statements.each { |st| puts st }

Finding statements:

  m.statements.find(:first, :object => "subject!")
  m.statements.all(:object => "another label")
  m.statements.find(:all, :object => "subject!").each { |statement|
    puts statement.subject
  }

Note that "m.statements.each" is "lazy", while "m.statements.all" (and other finders) are not.

For more details refer to the documentation of Model, Statement, Storage and other classes of Redlander.

= Exceptions

If anything unexpected happens, Redlander raises RedlandError.

= Authors

Slava Kravchenko <slava.kravchenko@gmail.com>

= Thanks

Thanks goes to Dave Beckett, the creator of Redland!

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redlander-0.3.3 README.rdoc
redlander-0.3.2 README.rdoc
redlander-0.3.1 README.rdoc