Class: GithubApi

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/githubapi.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(login = nil, token = nil, format = "yaml") ⇒ GithubApi

Returns a new instance of GithubApi.



10
11
12
13
14
15
16
# File 'lib/githubapi.rb', line 10

def initialize( = nil, token = nil, format = "yaml")
  @format = format
  if 
    @login = 
    @token = token
  end
end

Instance Attribute Details

#base_uriObject

Returns the value of attribute base_uri.



8
9
10
# File 'lib/githubapi.rb', line 8

def base_uri
  @base_uri
end

#formatObject

Returns the value of attribute format.



8
9
10
# File 'lib/githubapi.rb', line 8

def format
  @format
end

#loginObject

Returns the value of attribute login.



8
9
10
# File 'lib/githubapi.rb', line 8

def 
  @login
end

#repoObject

Returns the value of attribute repo.



8
9
10
# File 'lib/githubapi.rb', line 8

def repo
  @repo
end

#tokenObject

Returns the value of attribute token.



8
9
10
# File 'lib/githubapi.rb', line 8

def token
  @token
end

Instance Method Details

#add_collaborator(user) ⇒ Object



24
25
26
27
28
# File 'lib/githubapi.rb', line 24

def add_collaborator(user)
  uri = "#{self.class.base_uri}/repos/collaborators/#{@repo}/add/#{user}"
  post_params = {"login"=>@login, "token"=>@token}
  self.class.post(uri, :query=>post_params)
end

#add_key(params) ⇒ Object



30
31
32
33
34
35
# File 'lib/githubapi.rb', line 30

def add_key(params)
  uri = "#{self.class.base_uri}/repos/key/#{@repo}/add"
  post_params = {"login"=>@login, "token"=>@token}
  params = post_params.merge(params)
  self.class.post(uri, :query=>post_params.merge(params))
end

#create_issue(params) ⇒ Object



37
38
39
40
41
42
# File 'lib/githubapi.rb', line 37

def create_issue(params)
  uri = "#{self.class.base_uri}/issues/open/#{@login}/#{@repo}"
  post_params = {"login"=>@login, "token"=>@token}
  params = post_params.merge(params)
  self.class.post(uri, :query=>post_params.merge(params))
end

#create_repo(params) ⇒ Object



18
19
20
21
22
# File 'lib/githubapi.rb', line 18

def create_repo(params)
  uri = uri = "#{self.class.base_uri}/repos/create"
  post_params = {"login"=>@login, "token"=>@token}
  self.class.post(uri, :query=>post_params.merge(params))
end