Sha256: d1cb3a4c1eaa400d03de8e04bfdb62b6134b58d8afcbb250bcec6270edade5e8
Contents?: true
Size: 821 Bytes
Versions: 3
Compression:
Stored size: 821 Bytes
Contents
# frozen_string_literal: true require "slack/incoming/webhooks" module Osakana class Notifier def notifiy(title, attachments = []) attachments << { title: "N/A" } if attachments.empty? if slack_webhook_url? slack = Slack::Incoming::Webhooks.new(slack_webhook_url, channel: slack_channel) slack.post title, attachments: attachments else puts title attachments.each do |attachment| puts attachment.dig(:title) end end 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 def self.notify(title, attachments) new.notifiy(title, attachments) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
osakana-0.4.0 | lib/osakana/notifier.rb |
osakana-0.3.0 | lib/osakana/notifier.rb |
osakana-0.2.1 | lib/osakana/notifier.rb |