Class: Mihari::Notifiers::Slack
- Defined in:
- lib/mihari/notifiers/slack.rb
Constant Summary collapse
- SLACK_WEBHOOK_URL_KEY =
"SLACK_WEBHOOK_URL"- SLACK_CHANNEL_KEY =
"SLACK_CHANNEL"
Instance Method Summary collapse
- #notify(text:, attachments: []) ⇒ Object
- #slack_channel ⇒ Object
- #slack_webhook_url ⇒ Object
- #slack_webhook_url? ⇒ Boolean
- #valid? ⇒ Boolean
Instance Method Details
#notify(text:, attachments: []) ⇒ Object
25 26 27 28 |
# File 'lib/mihari/notifiers/slack.rb', line 25 def notify(text:, attachments: []) notifier = ::Slack::Notifier.new(slack_webhook_url, channel: slack_channel) notifier.post(text: text, attachments: ) end |
#slack_channel ⇒ Object
9 10 11 |
# File 'lib/mihari/notifiers/slack.rb', line 9 def slack_channel ENV.fetch SLACK_CHANNEL_KEY, "#general" end |
#slack_webhook_url ⇒ Object
13 14 15 |
# File 'lib/mihari/notifiers/slack.rb', line 13 def slack_webhook_url ENV.fetch SLACK_WEBHOOK_URL_KEY end |
#slack_webhook_url? ⇒ Boolean
17 18 19 |
# File 'lib/mihari/notifiers/slack.rb', line 17 def slack_webhook_url? ENV.key? SLACK_WEBHOOK_URL_KEY end |
#valid? ⇒ Boolean
21 22 23 |
# File 'lib/mihari/notifiers/slack.rb', line 21 def valid? slack_webhook_url? end |