Class: Backups::Listeners::Notify::Slack
- Inherits:
-
Backups::Listener
- Object
- Backups::Listener
- Backups::Listeners::Notify::Slack
- Defined in:
- lib/backups/listeners/notify/slack.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Slack
constructor
A new instance of Slack.
Methods inherited from Backups::Listener
Constructor Details
#initialize(config) ⇒ Slack
Returns a new instance of Slack.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/backups/listeners/notify/slack.rb', line 8 def initialize config @config = config webhook = config.fetch("webhook") channel = config.fetch("channel", "backups") username = config.fetch("username", "backups-cli") events = config.fetch("events", "all") active = config.fetch("active", true) unless active $LOGGER.debug "Slack listener not active" return end @slack = ::Slack::Notifier.new webhook, channel: channel, username: username $LOGGER.debug "Slack listener initialized" if events == "all" or events.include? "start" $LOGGER.debug "Slack listening to start events" Events::on :start do |params| _start params end end if events == "all" or events.include? "complete" $LOGGER.debug "Slack listening to complete events" Events::on :done do |params| _done params end end if events == "all" or events.include? "error" $LOGGER.debug "Slack listening to error events" Events::on :error do |params| _error params end end end |