class GHTorrent::BaseAdapter

Constants

ENTITIES

Public Instance Methods

close() click to toggle source

Close the current connection and release any held resources

# File lib/ghtorrent/adapters/base_adapter.rb, line 80
def close
  raise "Unimplemented"
end
count(entity, query = {}) click to toggle source

Count the number of entries returned by query without retrieving them. The query can be any query supported by find.

# File lib/ghtorrent/adapters/base_adapter.rb, line 61
def count(entity, query = {})
  unless ENTITIES.include?(entity)
    raise "Perister: Entity #{entity} not known"
  end
end
del(entity, query = {}) click to toggle source
# File lib/ghtorrent/adapters/base_adapter.rb, line 67
def del(entity, query = {})
  unless ENTITIES.include?(entity)
    raise "Perister: Entity #{entity} not known"
  end
end
find(entity, query = {}) click to toggle source

Retrieves rows from entity matching the provided query. The query is performed on the Github API JSON results. For example, given the following JSON object format:

{
   commit: {
     sha: "23fa34aa442456"
   }
   author: {
     name: {
       real_name: "foo"
       given_name: "bar"
     }
   }
   created_at: "1980-12-30T22:25:25"
}

to query for matching sha, pass to query

{'commit.sha' => 'a_value'}

to query for real_name’s matching an argument, pass to query

{'author.name.real_name' => 'a_value'}

to query for both a specific sha and a specific creation time

{'commit.sha' => 'a_value', 'created_at' => 'other_value'}

The persister adapter must translate the query to the underlying data storage engine query capabilities.

The results are returned as an array of hierarchical maps, one for each matching JSON object.

# File lib/ghtorrent/adapters/base_adapter.rb, line 53
def find(entity, query = {})
  unless ENTITIES.include?(entity)
    raise "Perister: Entity #{entity} not known"
  end
end
get_underlying_connection() click to toggle source

Get a raw connection to the underlying data store. The connection is implementaiton dependent.

# File lib/ghtorrent/adapters/base_adapter.rb, line 75
def get_underlying_connection
  raise "Unimplemented"
end
store(entity, data = {}) click to toggle source

Stores data into entity. Returns a unique key for the stored entry.

# File lib/ghtorrent/adapters/base_adapter.rb, line 12
def store(entity, data = {})
  unless ENTITIES.include?(entity)
    raise "Perister: Entity #{entity} not known"
  end
end