Module: Spira

Defined in:
lib/spira.rb,
lib/spira/base.rb,
lib/spira/type.rb,
lib/spira/types.rb,
lib/spira/errors.rb,
lib/spira/version.rb,
lib/spira/resource.rb,
lib/spira/exceptions.rb,
lib/spira/resource/dsl.rb,
lib/spira/resource/validations.rb,
lib/spira/resource/class_methods.rb,
lib/spira/resource/instance_methods.rb

Overview

Spira is a framework for building projections of RDF data into Ruby classes. It is built on top of RDF.rb.

See Also:

Defined Under Namespace

Modules: Resource, Type, Types, VERSION Classes: Base, Errors, NoRepositoryError, NoTypeError, ResourceDeclarationError, ValidationError

Instance Method Summary (collapse)

Instance Method Details

- (Void) add_repository(name, repo) - (Void) add_repository(name, klass, *args) Also known as: add_repository!

Add a repository to Spira's list of repositories.

Examples:

Adding an ntriples file as a repository

Spira.add_repository(:default, RDF::Repository.load('http://datagraph.org/jhacker/foaf.nt'))

Adding an empty repository to be instantiated on use

Spira.add_repository(:default, RDF::Repository)

See Also:

  • RDF::Repository


62
63
64
65
66
67
68
69
70
71
72
# File 'lib/spira.rb', line 62

def add_repository(name, klass, *args)
  repositories[name] = case klass
    when Class
      promise { klass.new(*args) }
    else
      klass
   end
   if (name == :default) && settings[:repositories][name].nil?
      warn "WARNING: Adding nil default repository"
   end
end

- (RDF::Repository) repository(name)

The RDF::Repository for the named repository

See Also:

  • RDF::Repository


82
83
84
# File 'lib/spira.rb', line 82

def repository(name)
  repositories[name]
end

- (Object) settings

A thread-local hash for storing settings. Used by Resource classes.

See Also:



41
42
43
# File 'lib/spira.rb', line 41

def settings
  Thread.current[:spira] ||= {}
end

- (Hash{Symbol => Spira::Type}) types

The list of all property types available for Spira resources

See Also:



30
31
32
# File 'lib/spira.rb', line 30

def types
  settings[:types] ||= {}
end