Class: Kasabi::Dataset

Inherits:
BaseClient show all
Defined in:
lib/kasabi/data/dataset.rb

Constant Summary collapse

PROPERTIES =
{
  :title => "http://purl.org/dc/terms/title",
  :description => "http://purl.org/dc/terms/description",
  :homepage => "http://xmlns.com/foaf/0.1/homepage",
  :sparql_endpoint => "http://rdfs.org/ns/void#sparqlEndpoint",
  :lookup_api => "http://rdfs.org/ns/void#uriLookupEndpoint",
  :search_api => "http://labs.kasabi.com/ns/services#searchEndpoint",
  :augmentation_api => "http://labs.kasabi.com/ns/services#augmentationEndpoint",
  :reconciliation_api => "http://labs.kasabi.com/ns/services#reconciliationEndpoint",
  :store_api => "http://labs.kasabi.com/ns/services#storeEndpoint",
  :status_api => "http://labs.kasabi.com/ns/services#statusEndpoint",
  :jobs_api => "http://labs.kasabi.com/ns/services#jobsEndpoint",
  :attribution_api => "http://labs.kasabi.com/ns/services#attributionEndpoint"
}
STANDARD_API_CLIENTS =
{
  :sparql_endpoint => Kasabi::Sparql::Client,
  :lookup_api => Kasabi::Lookup::Client,
  :search_api => Kasabi::Search::Client,
  :augmentation_api => Kasabi::Augment::Client,
  :reconciliation_api => Kasabi::Reconcile::Client,
  :store_api => Kasabi::Storage::Client,
  :status_api => Kasabi::Status,
  :jobs_api => Kasabi::Jobs::Client,
  :attribution_api => Kasabi::Attribution      
}

Instance Attribute Summary collapse

Attributes inherited from BaseClient

#apikey, #client, #endpoint

Instance Method Summary collapse

Methods inherited from BaseClient

#client_options, #get, #post, #validate_response

Constructor Details

#initialize(endpoint, options = {}) ⇒ Dataset

Initialize the client to work with a specific dataset endpoint Dataset endpoints are available from api.kasabi.com/data/…

The options hash can contain the following values:

  • :apikey: required. apikey authorized to use the API

  • :client: HTTPClient object instance



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kasabi/data/dataset.rb', line 14

def initialize(endpoint, options={})
  super(endpoint, options)
  uri = URI.parse(endpoint)
  domain = uri.host.split(".")[0]
  case domain
    when "data"
      @uri = endpoint
      @endpoint = endpoint.gsub("http://data", "http://api")  
    when "api"
      @endpoint = endpoint
      @uri = endpoint.gsub("http://api", "http://data")
    else
      #probably website, e.g. beta.kasabi or www.kasabi
      @endpoint = "http://api.kasabi.com" + uri.path
      @uri = "http://data.kasabi.com" + uri.path
  end      
end

Instance Attribute Details

#short_codeObject (readonly)

Returns the value of attribute short_code.



5
6
7
# File 'lib/kasabi/data/dataset.rb', line 5

def short_code
  @short_code
end

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/kasabi/data/dataset.rb', line 6

def uri
  @uri
end

Instance Method Details

#metadata(allow_cached = true) ⇒ Object

Read the metadata about this dataset from the live service



33
34
35
36
37
38
39
40
41
42
# File 'lib/kasabi/data/dataset.rb', line 33

def (allow_cached=true)
  if @metadata
    return @metadata
  end
  response = get(@uri, nil, 
    {"Accept" => "application/json"})
  validate_response(response)
  @metadata = JSON.parse( response.content )
  return @metadata
end