Class: PdkSync::GithubClient
- Inherits:
-
Object
- Object
- PdkSync::GithubClient
- Defined in:
- lib/pdksync/githubclient.rb
Instance Method Summary collapse
-
#create_pull_request(repo_name, create_pr_against, head, title, message) ⇒ Object
An Octokit pull request object for the newly created pull request.
-
#delete_branch(repo_name, branch_name) ⇒ Boolean
True on success, false on failure.
-
#initialize(access_token, api_endpoint = nil) ⇒ GithubClient
constructor
A new instance of GithubClient.
-
#labels(repo_name) ⇒ Array
List of available labels in the repository.
-
#repository?(repository) ⇒ Boolean
True if the repository exists, false otherwise.
-
#update_issue(repo_name, issue_number, options) ⇒ Object
An Octokit issue object of the updated issue.
Constructor Details
#initialize(access_token, api_endpoint = nil) ⇒ GithubClient
Returns a new instance of GithubClient.
13 14 15 16 17 18 |
# File 'lib/pdksync/githubclient.rb', line 13 def initialize(access_token, api_endpoint = nil) # USE ENV['OCTOKIT_API_ENDPOINT'] or pass in the api_endpoint Octokit.configure { |c| c.api_endpoint = api_endpoint } unless api_endpoint.nil? @client = Octokit::Client.new(access_token: access_token.to_s) @client.user.login end |
Instance Method Details
#create_pull_request(repo_name, create_pr_against, head, title, message) ⇒ Object
Returns An Octokit pull request object for the newly created pull request.
41 42 43 |
# File 'lib/pdksync/githubclient.rb', line 41 def create_pull_request(repo_name, create_pr_against, head, title, ) @client.create_pull_request(repo_name, create_pr_against, head, title, ) end |
#delete_branch(repo_name, branch_name) ⇒ Boolean
Returns true on success, false on failure.
74 75 76 |
# File 'lib/pdksync/githubclient.rb', line 74 def delete_branch(repo_name, branch_name) @client.delete_branch(repo_name, branch_name) end |
#labels(repo_name) ⇒ Array
Returns List of available labels in the repository.
50 51 52 |
# File 'lib/pdksync/githubclient.rb', line 50 def labels(repo_name) @client.labels(repo_name) end |
#repository?(repository) ⇒ Boolean
Returns true if the repository exists, false otherwise.
24 25 26 |
# File 'lib/pdksync/githubclient.rb', line 24 def repository?(repository) @client.repository?(repository) end |
#update_issue(repo_name, issue_number, options) ⇒ Object
Returns An Octokit issue object of the updated issue.
63 64 65 |
# File 'lib/pdksync/githubclient.rb', line 63 def update_issue(repo_name, issue_number, ) @client.update_issue(repo_name, issue_number, ) end |