Class: Marc2LinkedData::SparqlLocalLoc

Inherits:
Sparql
  • Object
show all
Defined in:
lib/marc2linkeddata/sparql_local_loc.rb

Instance Attribute Summary

Attributes inherited from Sparql

#sparql

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ SparqlLocalLoc

Returns a new instance of SparqlLocalLoc.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/marc2linkeddata/sparql_local_loc.rb', line 7

def initialize(uri)
  config = Marc2LinkedData.configuration
  uri = config.local_loc_url
  # local LOC SPARQL client
  auth_code = Base64.encode64("#{config.local_loc_user}:#{config.local_loc_pass}").chomp
  headers = {
      'Accept' => 'application/sparql-results+json',
      'Authorization' => "Basic #{auth_code}",
  }
  @sparql = SPARQL::Client.new(uri, {headers: headers} )
end

Instance Method Details

#auth(auth_uri) ⇒ Object



19
20
21
22
23
# File 'lib/marc2linkeddata/sparql_local_loc.rb', line 19

def auth(auth_uri)
  result = @sparql.query("SELECT * WHERE { <#{auth_uri}> ?p ?o }")
  result.each_solution {|s| puts s.inspect }
  binding.pry
end