Class: Lita::GithubPrList::PullRequestOpenMessageHook
- Inherits:
-
Object
- Object
- Lita::GithubPrList::PullRequestOpenMessageHook
- Defined in:
- lib/lita/github_pr_list/pull_request_open_message_hook.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#pull_request_html_url ⇒ Object
Returns the value of attribute pull_request_html_url.
-
#pull_request_owner ⇒ Object
Returns the value of attribute pull_request_owner.
-
#pull_request_status ⇒ Object
Returns the value of attribute pull_request_status.
-
#redis ⇒ Object
Returns the value of attribute redis.
-
#repo_name ⇒ Object
Returns the value of attribute repo_name.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
-
#statuses ⇒ Object
Returns the value of attribute statuses.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ PullRequestOpenMessageHook
constructor
A new instance of PullRequestOpenMessageHook.
- #message ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ PullRequestOpenMessageHook
Returns a new instance of PullRequestOpenMessageHook.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 6 def initialize(params = {}) self.statuses = %w(opened) self.response = params.fetch(:response, nil) self.request = params.fetch(:request, nil) self.redis = params.fetch(:redis, nil) raise "invalid params in #{self.class.name}" if response.nil? || request.nil? || redis.nil? # https://developer.github.com/v3/activity/events/types/#pullrequestevent self.payload = JSON.parse(request.body.read) self.pull_request_status = payload["action"] self.pull_request_owner = redis.get("alias:#{payload["pull_request"]["user"]["login"]}") || payload["pull_request"]["user"]["login"] self.title = payload["pull_request"]["title"] self.repo_name = payload["pull_request"]["head"]["repo"]["full_name"] self.pull_request_html_url = payload["pull_request"]["html_url"] end |
Instance Attribute Details
#payload ⇒ Object
Returns the value of attribute payload.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def payload @payload end |
#pull_request_html_url ⇒ Object
Returns the value of attribute pull_request_html_url.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def pull_request_html_url @pull_request_html_url end |
#pull_request_owner ⇒ Object
Returns the value of attribute pull_request_owner.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def pull_request_owner @pull_request_owner end |
#pull_request_status ⇒ Object
Returns the value of attribute pull_request_status.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def pull_request_status @pull_request_status end |
#redis ⇒ Object
Returns the value of attribute redis.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def redis @redis end |
#repo_name ⇒ Object
Returns the value of attribute repo_name.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def repo_name @repo_name end |
#request ⇒ Object
Returns the value of attribute request.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def response @response end |
#statuses ⇒ Object
Returns the value of attribute statuses.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def statuses @statuses end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 4 def title @title end |
Instance Method Details
#message ⇒ Object
23 24 25 26 27 |
# File 'lib/lita/github_pr_list/pull_request_open_message_hook.rb', line 23 def if statuses.include? pull_request_status "@#{pull_request_owner} #{pull_request_status} pull request: '#{title}' in '#{repo_name}'. #{pull_request_html_url}" end end |