Class: OmgPullRequest::GithubWrapper
- Inherits:
-
Object
- Object
- OmgPullRequest::GithubWrapper
- Extended by:
- Configuration::Helpers
- Defined in:
- lib/omg_pull_request/github_wrapper.rb
Constant Summary collapse
- STATUSES =
{ :pending => "pending", :success => "success", :conflict => "error", :failure => "failure" }
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
Instance Method Summary collapse
- #all_logins(pull_request) ⇒ Object
- #author_logins(pull_request) ⇒ Object
- #commit_shas(pull_request) ⇒ Object
- #create_comment(issue_number, body) ⇒ Object
- #create_status(sha, status, params = {}) ⇒ Object
- #find_pull_request(id) ⇒ Object
- #get_statuses(sha, params = {}) ⇒ Object
-
#initialize(attributes = {}) ⇒ GithubWrapper
constructor
A new instance of GithubWrapper.
- #make_gist(data, file_name) ⇒ Object
- #pull_requests ⇒ Object
Methods included from Configuration::Helpers
Constructor Details
#initialize(attributes = {}) ⇒ GithubWrapper
Returns a new instance of GithubWrapper.
11 12 13 14 15 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 11 def initialize(attributes={}) attributes.each do |attr, value| self.send("#{attr}=", value) end end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 3 def configuration @configuration end |
Instance Method Details
#all_logins(pull_request) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 21 def all_logins(pull_request) logins = [pull_request.user.login] logins |= github_client.issues.comments.list(repo_owner, repo, 'issue_id' => pull_request.number).collect do |c| c.user.login end logins.uniq end |
#author_logins(pull_request) ⇒ Object
17 18 19 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 17 def (pull_request) [pull_request.user.login, github_client.users.get(:user => pull_request.user.login).email] end |
#commit_shas(pull_request) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 31 def commit_shas(pull_request) commits = github_client.pull_requests.commits(repo_owner, repo, pull_request.number) commits.collect do |commit| commit.sha[0..10] end end |
#create_comment(issue_number, body) ⇒ Object
39 40 41 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 39 def create_comment(issue_number, body) github_client.issues.comments.create(repo_owner, repo, issue_number, :body => body) end |
#create_status(sha, status, params = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 43 def create_status(sha, status, params={}) if STATUSES.has_value? status params.merge! :state => status github_client.repos.statuses.create(repo_owner, repo, sha, params) end end |
#find_pull_request(id) ⇒ Object
74 75 76 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 74 def find_pull_request(id) github_client.pull_requests.find(repo_owner, repo, id) end |
#get_statuses(sha, params = {}) ⇒ Object
50 51 52 53 54 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 50 def get_statuses(sha, params={}) github_client.repos.statuses.list(repo_owner, repo, sha, params).collect do |h| h.slice("state", "target_url", "description") end end |
#make_gist(data, file_name) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 60 def make_gist(data, file_name) gist = github_client.gists.create( 'description' => 'Omg! Pull Request!', 'public' => false, 'files' => { file_name => { 'content' => data } } ) gist.files[file_name].raw_url end |
#pull_requests ⇒ Object
56 57 58 |
# File 'lib/omg_pull_request/github_wrapper.rb', line 56 def pull_requests github_client.pull_requests.list(repo_owner, repo) end |