class Qa::LDF::Client

A client for the LD cache server

Public Class Methods

new() { |self| ... } click to toggle source

@yield [Client] yields self to a block if given

# File lib/qa/ldf/client.rb, line 8
def initialize
  yield self if block_given?
end

Public Instance Methods

get(uri:, dataset: :'') click to toggle source

@param uri [String] a URI-like string @param dataset [Symbol]

@return [RDF::Graph]

@see RDF::Mutable#load @see RDF::LinkedDataFragments::CacheServer

# File lib/qa/ldf/client.rb, line 20
def get(uri:, dataset: :'')
  RDF::Graph.load(cache_uri(uri, dataset))
end

Private Instance Methods

cache_uri(uri, dataset) click to toggle source

@param uri [String] a URI-like string @param dataset [Symbol]

@return [RDF::URI]

# File lib/qa/ldf/client.rb, line 31
def cache_uri(uri, dataset)
  cache_uri = RDF::URI(Qa::LDF::Configuration.instance[:endpoint])
  cache_uri.query = "subject=#{uri}"
  cache_uri = cache_uri / 'dataset' / dataset unless dataset.empty?
  cache_uri.dup
end