Skip to content

Commit

Permalink
support multiple default graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Simaris authored and gkellogg committed Dec 3, 2018
1 parent 71f7c9e commit 4d733b9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/sparql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ServerError < StandardError; end
'*/*;q=0.1'
].join(', ').freeze
GRAPH_ALL = (
RDF::Format.content_types.keys +
RDF::Format.content_types.keys +
['*/*;q=0.1']
).join(', ').freeze

Expand Down Expand Up @@ -701,8 +701,8 @@ def request(query, headers = {}, &block)
if response.kind_of? Net::HTTPRedirection
response = @http.request(::URI.parse(response['location']), request)
else
return block_given? ? block.call(response) : response
end
return block_given? ? block.call(response) : response
end
end
raise ServerError, "Infinite redirect at #{url}. Redirected more than 10 times."
end
Expand Down Expand Up @@ -774,13 +774,20 @@ def make_post_request(query, headers = {})
# @see https://www.w3.org/TR/sparql11-protocol/#query-operation
# @see https://www.w3.org/TR/sparql11-protocol/#update-operation
def set_url_default_graph url
if @options[:graph].is_a? Array
graphs = @options[:graph].map {|graph|
CGI::escape(graph)
}
else
graphs = CGI::escape(@options[:graph])
end
case @op
when :query
url.query_values = (url.query_values || {})
.merge(:'default-graph-uri' => CGI::escape(@options[:graph]))
.merge(:'default-graph-uri' => graphs)
when :update
url.query_values = (url.query_values || {})
.merge(:'using-graph-uri' => CGI::escape(@options[:graph]))
.merge(:'using-graph-uri' => graphs)
end
end

Expand Down

0 comments on commit 4d733b9

Please sign in to comment.