Class: Osakana::Notifier
- Inherits:
-
Object
- Object
- Osakana::Notifier
- Defined in:
- lib/osakana/notifier.rb
Class Method Summary collapse
Instance Method Summary collapse
- #notifiy(title, attachments = []) ⇒ Object
- #slack_channel ⇒ Object
- #slack_webhook_url ⇒ Object
- #slack_webhook_url? ⇒ Boolean
Class Method Details
.notify(title, attachments) ⇒ Object
33 34 35 |
# File 'lib/osakana/notifier.rb', line 33 def self.notify(title, ) new.notifiy(title, ) end |
Instance Method Details
#notifiy(title, attachments = []) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/osakana/notifier.rb', line 7 def notifiy(title, = []) << { title: "N/A" } if .empty? if slack_webhook_url? slack = Slack::Incoming::Webhooks.new(slack_webhook_url, channel: slack_channel) slack.post title, attachments: else puts title .each do || puts .dig(:title) end end end |
#slack_channel ⇒ Object
25 26 27 |
# File 'lib/osakana/notifier.rb', line 25 def slack_channel ENV.fetch "SLACK_CHANNEL", "#general" end |
#slack_webhook_url ⇒ Object
21 22 23 |
# File 'lib/osakana/notifier.rb', line 21 def slack_webhook_url ENV.fetch "SLACK_WEBHOOK_URL" end |
#slack_webhook_url? ⇒ Boolean
29 30 31 |
# File 'lib/osakana/notifier.rb', line 29 def slack_webhook_url? ENV.key? "SLACK_WEBHOOK_URL" end |