Class: GithubToSlack::Communicator
- Inherits:
-
Object
- Object
- GithubToSlack::Communicator
- Defined in:
- app/models/github_to_slack/communicator.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
- #build_message ⇒ Object
- #deliver_message ⇒ Object
-
#initialize(payload) ⇒ Communicator
constructor
A new instance of Communicator.
- #label_actions ⇒ Object
Constructor Details
#initialize(payload) ⇒ Communicator
Returns a new instance of Communicator.
6 7 8 |
# File 'app/models/github_to_slack/communicator.rb', line 6 def initialize(payload) @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
4 5 6 |
# File 'app/models/github_to_slack/communicator.rb', line 4 def payload @payload end |
Instance Method Details
#build_message ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/github_to_slack/communicator.rb', line 10 def puts "Parsing json" params = JSON.parse(payload).with_indifferent_access pr_url = params[:pull_request][:html_url] pr_title = params[:pull_request][:title] action = params[:action].to_sym label_name = params[:label][:name] sender_login = params[:sender][:login] = "_#{sender_login}_ #{label_actions[action]} `#{label_name}` label to *#{pr_title}*.\nPR Link: #{pr_url}" end |
#deliver_message ⇒ Object
24 25 26 |
# File 'app/models/github_to_slack/communicator.rb', line 24 def SlackMessage.notify() end |
#label_actions ⇒ Object
28 29 30 31 32 33 |
# File 'app/models/github_to_slack/communicator.rb', line 28 def label_actions { labeled: :added, unlabeled: :removed } end |