Class: Jackal::Slack::Notification
- Inherits:
-
Callback
- Object
- Callback
- Jackal::Slack::Notification
- Defined in:
- lib/jackal-slack/notification.rb
Instance Method Summary collapse
- #execute(message) ⇒ Object
- #setup(*_) ⇒ Object
-
#slack_notifier ⇒ Object
Return slack_notifier object using team & token from data or config depending on what’s loaded in the environment.
-
#valid?(message) ⇒ Truthy, Falsey
Validity of message.
Instance Method Details
#execute(message) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jackal-slack/notification.rb', line 21 def execute() failure_wrap() do |payload| payload[:data][:slack][:messages].each do |slack_msg| notifier = slack_notifier msg = slack_msg[:message].to_s = { fallback: msg, text: msg, color: slack_msg[:color], mrkdwn_in: slack_msg.fetch(:markdown, true) ? [:text, :fallback] : [] } notifier.ping( slack_msg.fetch(:description, 'Result:'), attachments: [] ) end job_completed(:slack_notification, payload, ) end end |
#setup(*_) ⇒ Object
7 8 9 |
# File 'lib/jackal-slack/notification.rb', line 7 def setup(*_) require 'slack-notifier' end |
#slack_notifier ⇒ Object
Return slack_notifier object using team & token from data or config depending on what’s loaded in the environment
43 44 45 |
# File 'lib/jackal-slack/notification.rb', line 43 def slack_notifier ::Slack::Notifier.new(config[:webhook_url]) end |
#valid?(message) ⇒ Truthy, Falsey
Validity of message
15 16 17 18 19 |
# File 'lib/jackal-slack/notification.rb', line 15 def valid?() super do |payload| payload.get(:data, :slack) end end |