Sha256: 7007696da8a87a352f23827580d8fc7c2fe40391ae730e3b05f64c62d628570c
Contents?: true
Size: 919 Bytes
Versions: 5
Compression:
Stored size: 919 Bytes
Contents
# frozen_string_literal: true require "colorize" require "slack/incoming/webhooks" module Miteru class Notifier def initialize(post_to_slack = false) @post_to_slack = post_to_slack end def notify(url:, kits:, message:) attachement = Attachement.new(url) if post_to_slack? && !kits.empty? slack = Slack::Incoming::Webhooks.new(slack_webhook_url, channel: slack_channel) slack.post( message, attachments: attachement.to_a ) end message = message.colorize(:light_red) unless kits.empty? puts "#{url}: #{message}" end def post_to_slack? @post_to_slack && slack_webhook_url? end def slack_webhook_url ENV.fetch "SLACK_WEBHOOK_URL" end def slack_channel ENV.fetch "SLACK_CHANNEL", "#general" end def slack_webhook_url? ENV.key? "SLACK_WEBHOOK_URL" end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
miteru-0.12.8 | lib/miteru/notifier.rb |
miteru-0.12.7 | lib/miteru/notifier.rb |
miteru-0.12.6 | lib/miteru/notifier.rb |
miteru-0.12.5 | lib/miteru/notifier.rb |
miteru-0.12.4 | lib/miteru/notifier.rb |