Class: ServerBackups::Notifier
- Inherits:
-
Object
- Object
- ServerBackups::Notifier
- Defined in:
- lib/server_backups/notifier.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config_path) ⇒ Notifier
constructor
A new instance of Notifier.
- #notify_failure(errors) ⇒ Object
- #notify_success ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/server_backups/notifier.rb', line 5 def config @config end |
Instance Method Details
#notify_failure(errors) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/server_backups/notifier.rb', line 20 def notify_failure(errors) return unless config.slack_webhook notifier = Slack::Notifier.new config.slack_webhook = "Backups at `#{config.prefix}` failed. " += config.slack_mention_on_failure.map{|t| "<@#{t}>"}.to_sentence = [] for error in errors do << {text: error. + "\n" + error.backtrace.join("\n")} end notifier.post text: , icon_emoji: ':bomb:', attachments: end |
#notify_success ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/server_backups/notifier.rb', line 11 def notify_success return unless config.slack_webhook && config.notify_on_success notifier = Slack::Notifier.new config.slack_webhook = "Backups at `#{config.prefix}` succeeded. " += config.slack_mention_on_success.map{|t| "<@#{t}>"}.to_sentence notifier.post text: , icon_emoji: ':100:' end |