Class: Fushin::Notifier
- Inherits:
-
Object
- Object
- Fushin::Notifier
- Defined in:
- lib/fushin/notifier.rb
Class Method Summary collapse
Instance Method Summary collapse
- #notify(title, attachments = []) ⇒ Object
- #slack_channel ⇒ Object
- #slack_webhook_url ⇒ Object
- #slack_webhook_url? ⇒ Boolean
Class Method Details
.notify(title, text) ⇒ Object
31 32 33 |
# File 'lib/fushin/notifier.rb', line 31 def self.notify(title, text) new.notify(title, text) end |
Instance Method Details
#notify(title, attachments = []) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fushin/notifier.rb', line 7 def notify(title, = []) 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)} (#{.dig(:title_link)})" end end end |
#slack_channel ⇒ Object
23 24 25 |
# File 'lib/fushin/notifier.rb', line 23 def slack_channel ENV.fetch "SLACK_CHANNEL", "#general" end |
#slack_webhook_url ⇒ Object
19 20 21 |
# File 'lib/fushin/notifier.rb', line 19 def slack_webhook_url ENV.fetch "SLACK_WEBHOOK_URL" end |
#slack_webhook_url? ⇒ Boolean
27 28 29 |
# File 'lib/fushin/notifier.rb', line 27 def slack_webhook_url? ENV.key? "SLACK_WEBHOOK_URL" end |