Class: GithubApi
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#format ⇒ Object
Returns the value of attribute format.
-
#login ⇒ Object
Returns the value of attribute login.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #add_collaborator(user) ⇒ Object
- #add_key(params) ⇒ Object
- #create_issue(params) ⇒ Object
- #create_repo(params) ⇒ Object
-
#initialize(login = nil, token = nil, format = "yaml") ⇒ GithubApi
constructor
A new instance of GithubApi.
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(login = nil, token = nil, format = "yaml") @format = format if login @login = login @token = token end end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
8 9 10 |
# File 'lib/githubapi.rb', line 8 def base_uri @base_uri end |
#format ⇒ Object
Returns the value of attribute format.
8 9 10 |
# File 'lib/githubapi.rb', line 8 def format @format end |
#login ⇒ Object
Returns the value of attribute login.
8 9 10 |
# File 'lib/githubapi.rb', line 8 def login @login end |
#repo ⇒ Object
Returns the value of attribute repo.
8 9 10 |
# File 'lib/githubapi.rb', line 8 def repo @repo end |
#token ⇒ Object
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 |