Sha256: 490b342d2fea8a1481227858f2bbe583de1c910667d0f2fc4569b7f7709da15f
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
class UniformNotifier class Slack < Base POSSIBLE_OPTIONS = [:username, :channel] @slack = nil class << self def active? @slack end def setup_connection(config={}) webhook_url, options = parse_config(config) fail_connection('webhook_url required for Slack notification') unless webhook_url require 'slack-notifier' @slack = ::Slack::Notifier.new webhook_url, options rescue LoadError fail_connection 'You must install the slack-notifier gem to use Slack notification: '\ '`gem install slack-notifier`' end protected def _out_of_channel_notify(data) message = data.values.compact.join("\n") notify(message) end private def fail_connection(message) @slack = nil raise NotificationError.new(message) end def notify(message) @slack.ping message end def parse_config(config) options = config.select do |name, value| POSSIBLE_OPTIONS.include?(name) && !value.nil? end return config[:webhook_url], options end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
uniform_notifier-1.11.0 | lib/uniform_notifier/slack.rb |
uniform_notifier-1.10.0 | lib/uniform_notifier/slack.rb |
uniform_notifier-1.9.0 | lib/uniform_notifier/slack.rb |