class Miteru::Notifier

Public Instance Methods

notifiable?() click to toggle source
# File lib/miteru/notifier.rb, line 21
def notifiable?
  Miteru.configuration.slack_webhook_url? && Miteru.configuration.post_to_slack?
end
notify(url:, kits:, message:) click to toggle source
# File lib/miteru/notifier.rb, line 8
def notify(url:, kits:, message:)
  attachement = Attachement.new(url)
  kits = kits.select(&:downloaded?)

  if notifiable? && kits.any?
    notifier = Slack::Notifier.new(Miteru.configuration.slack_webhook_url, channel: Miteru.configuration.slack_channel)
    notifier.post(text: message.capitalize, attachments: attachement.to_a)
  end

  message = message.colorize(:light_red) if kits.any?
  puts "#{url}: #{message}"
end