class WatchDoge::Notification::SlackWebhook
Public Class Methods
new(opt)
click to toggle source
Calls superclass method
# File lib/watchdoge/notification/slack_webhook.rb, line 4 def initialize opt super @incoming_url = opt[:incoming_url] end
Public Instance Methods
flush()
click to toggle source
# File lib/watchdoge/notification/slack_webhook.rb, line 10 def flush @message_queue.each do |message| body = slack_body(message).to_json Net::HTTP.post URI(@incoming_url), body, "Content-Type" => "application/json" end @message_queue = [] end
Private Instance Methods
slack_body(message)
click to toggle source
# File lib/watchdoge/notification/slack_webhook.rb, line 23 def slack_body message case message when String { text: message } when ChunkyPNG::Image data = ['data:image/png;base64,', message.to_blob].pack('A*m').gsub(/\n/, '') { attachments: [{ image_url: data }] } when WatchDoge::PixelTest data = ['data:image/png;base64,', message.diff.to_blob].pack('A*m').gsub(/\n/, '') { attachments: [{ image_url: data }] } end end