Class: GHTorrent::BaseAdapter
- Inherits:
-
Object
- Object
- GHTorrent::BaseAdapter
- Defined in:
- lib/ghtorrent/adapters/base_adapter.rb
Direct Known Subclasses
Constant Summary collapse
- ENTITIES =
[:users, :commits, :followers, :repos, :events, :org_members, :commit_comments, :repo_collaborators, :watchers, :pull_requests, :forks, :pull_request_comments, :issue_comments, :issues, :issue_events, :repo_labels ]
Instance Method Summary collapse
-
#close ⇒ Object
Close the current connection and release any held resources.
-
#count(entity, query = {}) ⇒ Object
Count the number of entries returned by
querywithout retrieving them. - #del(entity, query = {}) ⇒ Object
-
#find(entity, query = {}) ⇒ Object
Retrieves rows from
entitymatching the providedquery. -
#get_underlying_connection ⇒ Object
Get a raw connection to the underlying data store.
-
#store(entity, data = {}) ⇒ Object
Stores
dataintoentity.
Instance Method Details
#close ⇒ Object
Close the current connection and release any held resources
80 81 82 |
# File 'lib/ghtorrent/adapters/base_adapter.rb', line 80 def close raise "Unimplemented" end |
#count(entity, query = {}) ⇒ Object
Count the number of entries returned by query without retrieving them. The query can be any query supported by find.
61 62 63 64 65 |
# 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 = {}) ⇒ Object
67 68 69 70 71 |
# 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 = {}) ⇒ Object
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.
53 54 55 56 57 |
# 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 ⇒ Object
Get a raw connection to the underlying data store. The connection is implementaiton dependent.
75 76 77 |
# File 'lib/ghtorrent/adapters/base_adapter.rb', line 75 def raise "Unimplemented" end |
#store(entity, data = {}) ⇒ Object
Stores data into entity. Returns a unique key for the stored entry.
12 13 14 15 16 |
# 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 |