Class: Miteru::Notifier
- Inherits:
-
Object
- Object
- Miteru::Notifier
- Defined in:
- lib/miteru/notifier.rb
Instance Method Summary collapse
- #notify(url:, kits:, message:) ⇒ Object
- #post_to_slack? ⇒ Boolean
- #slack_channel ⇒ Object
- #slack_webhook_url ⇒ Object
- #slack_webhook_url? ⇒ Boolean
Instance Method Details
#notify(url:, kits:, message:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/miteru/notifier.rb', line 8 def notify(url:, kits:, message:) attachement = Attachement.new(url) kits = kits.select(&:filesize) if post_to_slack? && kits.any? notifier = Slack::Notifier.new(slack_webhook_url, channel: slack_channel) notifier.post(text: , attachments: attachement.to_a) end = .colorize(:light_red) if kits.any? puts "#{url}: #{}" end |
#post_to_slack? ⇒ Boolean
21 22 23 |
# File 'lib/miteru/notifier.rb', line 21 def post_to_slack? slack_webhook_url? && Miteru.configuration.post_to_slack? end |
#slack_channel ⇒ Object
29 30 31 |
# File 'lib/miteru/notifier.rb', line 29 def slack_channel ENV.fetch "SLACK_CHANNEL", "#general" end |
#slack_webhook_url ⇒ Object
25 26 27 |
# File 'lib/miteru/notifier.rb', line 25 def slack_webhook_url ENV.fetch "SLACK_WEBHOOK_URL" end |
#slack_webhook_url? ⇒ Boolean
33 34 35 |
# File 'lib/miteru/notifier.rb', line 33 def slack_webhook_url? ENV.key? "SLACK_WEBHOOK_URL" end |