Module: RDF::Raptor

Defined in:
lib/rdf/raptor.rb,
lib/rdf/raptor/cli.rb,
lib/rdf/raptor/ffi.rb,
lib/rdf/raptor/rdfa.rb,
lib/rdf/raptor/format.rb,
lib/rdf/raptor/rdfxml.rb,
lib/rdf/raptor/turtle.rb,
lib/rdf/raptor/version.rb,
lib/rdf/raptor/graphviz.rb,
lib/rdf/raptor/ntriples.rb

Overview

RDF::Raptor is a Raptor RDF Parser plugin for RDF.rb.

  • NTriples provides support for the standard machine-readable N-Triples format.

  • Turtle provides support for the popular human-readable Turtle format.

  • RDFXML provides support for the standard machine-readable RDF/XML format.

  • RDFa provides support for extracting RDF statements from XHTML+RDFa documents.

  • Graphviz provides support for serializing RDF statements to the Graphviz DOT format.

Raptor includes an FFI implementation, which loads the libraptor2 library into the Ruby process, as well as a CLI implementation, which drives the rapper command-line tool in a sub-process.

The FFI implementation is used by default unless the libraptor2 library cannot be found, or if the RDF_RAPTOR_ENGINE environment variable is explicitly set to 'cli'.

If the libraptor2 library is in the standard library search path, and the rapper command is in the standard command search path, all should be well and work fine out of the box. However, if either is in a non-standard location, be sure to set the RDF_RAPTOR_LIBPATH and/or RDF_RAPTOR_BINPATH environment variables appropriately before requiring rdf/raptor.

Examples:

Requiring the RDF::Raptor module

require 'rdf/raptor'

Checking whether Raptor is installed

RDF::Raptor.available?         #=> true

Obtaining the Raptor version number

RDF::Raptor.version            #=> "1.4.21"

Obtaining the Raptor engine

RDF::Raptor::ENGINE            #=> :ffi

Obtaining an N-Triples format class

RDF::Format.for(:ntriples)     #=> RDF::Raptor::NTriples::Format
RDF::Format.for("input.nt")
RDF::Format.for(file_name:      "input.nt")
RDF::Format.for(file_extension: "nt")
RDF::Format.for(content_type:   "text/plain")

Obtaining a Turtle format class

RDF::Format.for(:turtle)       #=> RDF::Raptor::Turtle::Format
RDF::Format.for("input.ttl")
RDF::Format.for(file_name:      "input.ttl")
RDF::Format.for(file_extension: "ttl")
RDF::Format.for(content_type:   "text/turtle")

Obtaining an RDF/XML format class

RDF::Format.for(:rdfxml)       #=> RDF::Raptor::RDFXML::Format
RDF::Format.for("input.rdf")
RDF::Format.for(file_name:      "input.rdf")
RDF::Format.for(file_extension: "rdf")
RDF::Format.for(content_type:   "application/rdf+xml")

Obtaining an RDFa format class

RDF::Format.for(:rdfa)       #=> RDF::Raptor::RDFa::Format
RDF::Format.for("input.html")
RDF::Format.for(file_name:      "input.html")
RDF::Format.for(file_extension: "html")
RDF::Format.for(content_type:   "application/xhtml+xml")

See Also:

Author:

Defined Under Namespace

Modules: CLI, FFI, Format, Graphviz, NTriples, RDFXML, RDFa, Turtle, VERSION

Constant Summary collapse

LIBRAPTOR =
ENV['RDF_RAPTOR_LIBPATH'] || ['libraptor2', 'libraptor2.so.0']
RAPPER =
ENV['RDF_RAPTOR_BINPATH'] || 'rapper'

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns true if the rapper binary is available.

Examples:

RDF::Raptor.available?  #=> true

Returns:

  • (Boolean)


106
107
108
# File 'lib/rdf/raptor.rb', line 106

def self.available?
  !!version
end