Parent

Included Modules

Redleaf::Parser

An RDF parser object class

Subversion Id

 $Id$

Authors

Copyright © 2008-2009, Michael Granger All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Constants

SVNRev

SVN Revision

SVNId

SVN Id

Attributes

subclasses[R]

(Not documented)

Public Class Methods

features → hash click to toggle source

Return a Hash of supported features from the underlying Redland library.

   Redleaf::Parser.features
   # => {"raptor"       => "",
         "grddl"        => "Gleaning Resource Descriptions from Dialects of Languages",
         "rdfxml"       => "RDF/XML",
         "guess"        => "Pick the parser to use using content type and URI",
         "rdfa"         => "RDF/A via librdfa",
         "trig"         => "TriG - Turtle with Named Graphs",
         "turtle"       => "Turtle Terse RDF Triple Language",
         "ntriples"     => "N-Triples",
         "rss-tag-soup" => "RSS Tag Soup"}
static VALUE
rleaf_redleaf_parser_s_features( VALUE klass ) 
find_by_name( name ) click to toggle source

Find a parser class by name.

    # File lib/redleaf/parser.rb, line 51
51:     def self::find_by_name( name )
52:         begin
53:             require "redleaf/parser/#{name}"
54:         rescue LoadError => err
55:             Redleaf.logger.error "%s while trying to load a parser named %p: %s" %
56:                 [ err.class.name, name, err.message ]
57:         end
58: 
59:         return self.subclasses.find {|klass| klass.parser_type.to_s == name }
60:     end
guess_type( mimetype=nil, buffer=nil, uri=nil ) → string click to toggle source

Guess the type of parser required given one or more of a mimetype, a buffer containing RDF content, and/or an RDF uri.

static VALUE
rleaf_redleaf_parser_s_guess_type( int argc, VALUE *argv, VALUE self ) 
inherited( subclass ) click to toggle source

Inheritance callback — keep track of all subclasses so we can search for them by name later.

    # File lib/redleaf/parser.rb, line 42
42:     def self::inherited( subclass )
43:         if self == Redleaf::Parser
44:             @subclasses << subclass
45:         end
46:         super
47:     end
is_supported?() click to toggle source

Returns true if the Redland parser type required by the receiving store class is supported by the local installation.

    # File lib/redleaf/parser.rb, line 89
89:     def self::is_supported?
90:         return self.features.include?( self.validated_parser_type )
91:     end
new( *args ) click to toggle source

Check to be sure the parser type is supported before instantiating it

    # File lib/redleaf/parser.rb, line 95
95:     def self::new( *args )
96:         raise Redleaf::FeatureError, "unsupported parser type %p" % [ self.parser_type ] unless
97:           self.is_supported?
98:         super
99:     end
new() → parser click to toggle source

Initialize an instance of a subclass of Redleaf::Parser.

static VALUE 
rleaf_redleaf_parser_initialize( VALUE self ) 
parser_type( new_setting=nil ) click to toggle source

Set the class’s Redland parser type to new_setting if given, and return the current (new) setting.

    # File lib/redleaf/parser.rb, line 65
65:     def self::parser_type( new_setting=nil )
66:         if new_setting
67:             Redleaf.logger.debug "Setting backend for %p to %p" % [ self, new_setting ]
68:             @parser_type = new_setting.to_sym
69: 
70:             unless self.is_supported?
71:                 Redleaf.logger.warn "local Redland library doesn't have %p parser; valid values are: %p" %
72:                     [ @parser_type.to_s, self.features ]
73:             end
74:         end
75: 
76:         return @parser_type
77:     end
validated_parser_type() click to toggle source

Get the parser_type for the class after making sure it’s valid and supported by the local installation. Raises a Redleaf::FeatureError if there is a problem.

    # File lib/redleaf/parser.rb, line 82
82:     def self::validated_parser_type
83:         return self.parser_type.to_s.gsub( /_/, '-' )
84:     end

Public Instance Methods

accept_header → string click to toggle source

Return an HTTP Accept header value for the parser.

   Redleaf::Parser.new.accept_header
   # => "application/rdf+xml, text/rdf;q=0.6"
static VALUE
rleaf_redleaf_parser_accept_header( VALUE self ) 
accept_header → string click to toggle source

Return an HTTP Accept header value for the parser.

   Redleaf::Parser.new.accept_header
   # => "application/rdf+xml, text/rdf;q=0.6"
static VALUE
rleaf_redleaf_parser_accept_header( VALUE self ) 
parse( string ) → graph click to toggle source

Parse the content in the specified string and return a Redleaf::Graph containing any resulting statements.

static VALUE
rleaf_redleaf_parser_parse( int argc, VALUE *argv, VALUE self ) 

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.