Class: RDF::Marmotta::Client

Inherits:
SPARQL::Client
  • Object
show all
Defined in:
lib/rdf/marmotta.rb

Constant Summary collapse

MARMOTTA_GRAPH_ALL =
(Marmotta::CTYPES.keys + ['*/*;p=0.1'])
.join(', ').freeze

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}, &block) ⇒ Client

Returns a new instance of Client.



72
73
74
75
76
# File 'lib/rdf/marmotta.rb', line 72

def initialize(url, options = {}, &block)
  options[:method]   ||= :get
  options[:protocol] ||= '1.1'
  super
end

Instance Method Details

#parse_rdf_serialization(response, options = {}) ⇒ Object



91
92
93
94
# File 'lib/rdf/marmotta.rb', line 91

def parse_rdf_serialization(response, options = {})
  options[:content_type] ||= 'text/turtle' if response.content_type.nil?
  super
end

#request(query, headers = {}, &block) ⇒ Object

Limit to accepted content types per comment on RDF::Marmotta::CTYPES



80
81
82
83
84
85
86
87
# File 'lib/rdf/marmotta.rb', line 80

def request(query, headers={}, &block)
  headers['Accept'] ||= MARMOTTA_GRAPH_ALL if
    (query.respond_to?(:expects_statements?) ?
     query.expects_statements? :
     (query =~ /CONSTRUCT|DESCRIBE|DELETE|CLEAR/))

  super
end

#request_method(query) ⇒ Object

Do HTTP POST if it’s an INSERT



97
98
99
100
101
# File 'lib/rdf/marmotta.rb', line 97

def request_method(query)
  method = (self.options[:method] || DEFAULT_METHOD).to_sym
  method = :post if query.to_s =~ /INSERT/
  method
end