Sha256: 087962783de9ccf81e69a35d02aba3f35dee3c8e6978dfabac427986c966a453

Contents?: true

Size: 694 Bytes

Versions: 2

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

require "colorize"
require "slack-notifier"

module Miteru
  class Notifier
    def notify(url:, kits:, message:)
      attachement = Attachement.new(url)
      kits = kits.select(&:filesize)

      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

    def notifiable?
      Miteru.configuration.slack_webhook_url? && Miteru.configuration.post_to_slack?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miteru-1.0.1 lib/miteru/notifier.rb
miteru-1.0.0 lib/miteru/notifier.rb