module Sinatra::SPARQL

The Sinatra::SPARQL module adds {Rack::SPARQL} middleware support for responding to SPARQL requests. It is the responsibility of the application to manage the SPARQL endpoint and perform the query. The query results are then sent as the response body. {Rack::SPARQL} middleware uses content negotiation to format the results appropriately.

To override negotiation on Content-Type, set :format in `sparql_options` to a RDF Format class, or symbol identifying a format.

@see www.sinatrarb.com/extensions.html

Public Class Methods

registered(app) click to toggle source
  • Registers {Rack::SPARQL::ContentNegotiation}

  • adds helpers

  • includes SPARQL, RDF and LinkedData

  • defines `sparql_options`, which are passed to the Rack middleware available as `settings.sparql_options` and as options within the {Rack::SPARQL} middleware.

@param [Sinatra::Base] app @return [void]

# File lib/sinatra/sparql.rb, line 99
def self.registered(app)
  options = {}
  app.set :sparql_options, options
  app.use(Rack::SPARQL::ContentNegotiation, options)
  app.helpers(Sinatra::SPARQL::Helpers)
  app.send(:include, ::SPARQL)
  app.send(:include, ::RDF)
  app.send(:include, ::LinkedData) if defined?(::LinkedData)
end