class RDF::Marmotta

Constants

CTYPES

Supported Accept headers for Marmotta. As of 3.3.0, Marmotta will reject a request if the first content type listed is not suppported.

@see issues.apache.org/jira/browse/MARMOTTA-585

DEFAULT_OPTIONS

Attributes

endpoints[RW]
update_client[R]

Public Class Methods

new(base_url, options = {}) click to toggle source
# File lib/rdf/marmotta.rb, line 30
def initialize(base_url, options = {})
  @options   = options.dup

  @tx_class ||= @options.delete(:transaction_class) { DEFAULT_TX_CLASS }

  @endpoints = DEFAULT_OPTIONS
  @endpoints.merge!(options)
  @endpoints.each do |k, v|
    next unless RDF::URI(v.to_s).relative?
    @endpoints[k] = (RDF::URI(base_url.to_s) / v.to_s)
  end
  @client        = Client.new(endpoints[:sparql].to_s, options)
  @update_client = Client.new(endpoints[:sparql_update].to_s, options)
end

Public Instance Methods

clear() click to toggle source
# File lib/rdf/marmotta.rb, line 64
def clear
  update_client.query("DELETE { ?s ?p ?o } WHERE { ?s ?p ?o }")
end
count() click to toggle source
# File lib/rdf/marmotta.rb, line 53
def count
  begin
    binding = client.query("SELECT (COUNT(*) AS ?no) WHERE { ?s ?p ?o }").first.to_hash
    binding[binding.keys.first].value.to_i
  rescue SPARQL::Client::ServerError
    count = 0
    each_statement { count += 1 }
    count
  end
end
delete_statement(statement) click to toggle source
# File lib/rdf/marmotta.rb, line 49
def delete_statement(statement)
  delete(statement)
end
query_client() click to toggle source
# File lib/rdf/marmotta.rb, line 45
def query_client
  @client
end