Class: Ghee

Inherits:
Object
  • Object
show all
Includes:
API::Authorizations, API::Events, API::Gists, API::Orgs, API::Repos, API::Users
Defined in:
lib/ghee.rb,
lib/ghee/errors.rb,
lib/ghee/version.rb,
lib/ghee/api/keys.rb,
lib/ghee/api/orgs.rb,
lib/ghee/api/forks.rb,
lib/ghee/api/gists.rb,
lib/ghee/api/hooks.rb,
lib/ghee/api/pulls.rb,
lib/ghee/api/repos.rb,
lib/ghee/api/users.rb,
lib/ghee/api/emails.rb,
lib/ghee/api/events.rb,
lib/ghee/api/issues.rb,
lib/ghee/api/labels.rb,
lib/ghee/api/search.rb,
lib/ghee/connection.rb,
lib/ghee/uri_escape.rb,
lib/ghee/api/commits.rb,
lib/ghee/api/contents.rb,
lib/ghee/api/git_data.rb,
lib/ghee/api/watchers.rb,
lib/ghee/api/downloads.rb,
lib/ghee/api/followers.rb,
lib/ghee/state_methods.rb,
lib/ghee/api/milestones.rb,
lib/ghee/resource_proxy.rb,
lib/ghee/api/collaborators.rb,
lib/ghee/api/authorizations.rb

Defined Under Namespace

Modules: API, CUD, Middleware Classes: BadGateway, BadRequest, Connection, Error, Forbidden, InternalServerError, NotAcceptable, NotFound, NotImplemented, ResourceProxy, ServiceUnavailable, Unauthorized, UnprocessableEntity

Constant Summary collapse

VERSION =
"0.12.16"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from API::Orgs

#orgs, #team

Methods included from API::Repos

#repos

Methods included from API::Events

#events

Methods included from API::Users

#user, #users

Methods included from API::Gists

#gists

Methods included from API::Authorizations

#authorizations

Constructor Details

#initialize(options = {}, &block) ⇒ Ghee

Instantiates Ghee, accepts an access_token for authenticated access

Access_token - String of the access_token



45
46
47
48
49
# File 'lib/ghee.rb', line 45

def initialize(options = {}, &block)
  @options = options
  @block = block if block
  return @connection = Ghee::Connection.new(options, &block) 
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



31
32
33
# File 'lib/ghee.rb', line 31

def connection
  @connection
end

Class Method Details

.access_token(token, api_url = nil) ⇒ Object



65
66
67
68
69
# File 'lib/ghee.rb', line 65

def self.access_token(token, api_url = nil)
  options = {  :access_token => token }
  options[:api_url] = api_url if api_url
  Ghee.new  options
end

.basic_auth(user_name, password, api_url = nil) ⇒ Object



59
60
61
62
63
# File 'lib/ghee.rb', line 59

def self.basic_auth(user_name, password, api_url = nil)
    options = { :basic_auth  => {:user_name => user_name, :password => password} }
    options[:api_url] = api_url if api_url
    Ghee.new options
end

.create_token(user_name, password, scopes, api_url = nil) ⇒ Object



71
72
73
74
75
# File 'lib/ghee.rb', line 71

def self.create_token(user_name, password, scopes, api_url = nil)
  auth = Ghee.basic_auth(user_name, password, api_url).authorizations.create({
    :scopes => scopes})
  auth["token"]
end

Instance Method Details

#in_parallel(adapter = :typhoeus, &block) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/ghee.rb', line 51

def in_parallel(adapter = :typhoeus, &block)
  ghee = self.class.new @options, &@block
  ghee.connection.adapter adapter
  ghee.connection.in_parallel do
    block.call ghee
  end
end

#searchObject



37
38
39
# File 'lib/ghee/api/search.rb', line 37

def search
  API::Search::Proxy.new(connection,"")
end