lib/rdf/marmotta.rb in rdf-marmotta-0.1.0 vs lib/rdf/marmotta.rb in rdf-marmotta-0.1.1
- old
+ new
@@ -1,7 +1,6 @@
require 'rdf'
-require 'rdf/rdfxml'
require 'sparql/client'
require 'enumerator'
module RDF
class Marmotta < ::SPARQL::Client::Repository
@@ -27,18 +26,21 @@
'RDF::TriX::Format',
'RDF::N3::Format']).empty?
end
def initialize(base_url, options = {})
- @options = options.dup
+ @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)
+ @client = Client.new(endpoints[:sparql].to_s, options)
@update_client = Client.new(endpoints[:sparql_update].to_s, options)
end
def query_client
@client
@@ -66,11 +68,11 @@
class Client < SPARQL::Client
MARMOTTA_GRAPH_ALL = (Marmotta::CTYPES.keys + ['*/*;p=0.1'])
.join(', ').freeze
def initialize(url, options = {}, &block)
- options[:method] ||= :get
+ options[:method] ||= :get
options[:protocol] ||= '1.1'
super
end
##
@@ -79,9 +81,16 @@
headers['Accept'] ||= MARMOTTA_GRAPH_ALL if
(query.respond_to?(:expects_statements?) ?
query.expects_statements? :
(query =~ /CONSTRUCT|DESCRIBE|DELETE|CLEAR/))
+ super
+ end
+
+ ##
+ # @private
+ def parse_rdf_serialization(response, options = {})
+ options[:content_type] ||= 'text/turtle' if response.content_type.nil?
super
end
# Do HTTP POST if it's an INSERT
def request_method(query)