class Barbeque::SlackClient

Public Class Methods

new(channel) click to toggle source
# File lib/barbeque/slack_client.rb, line 7
def initialize(channel)
  @channel = channel
end

Public Instance Methods

notify_failure(message) click to toggle source
# File lib/barbeque/slack_client.rb, line 21
def notify_failure(message)
  post_slack(
    attachments: [{
      text: message,
      color: 'danger',
      mrkdwn_in: ['text'],
    }],
  )
end
notify_success(message) click to toggle source
# File lib/barbeque/slack_client.rb, line 11
def notify_success(message)
  post_slack(
    attachments: [{
      text: message,
      color: 'good',
      mrkdwn_in: ['text'],
    }],
  )
end

Private Instance Methods

default_payload() click to toggle source
# File lib/barbeque/slack_client.rb, line 40
def default_payload
  { link_names: 1, channel: @channel }
end
endpoint_uri() click to toggle source
# File lib/barbeque/slack_client.rb, line 44
def endpoint_uri
  @endpoint_uri ||= URI.parse(ENV['SLACK_WEBHOOK_URL'])
end
post_slack(payload) click to toggle source
# File lib/barbeque/slack_client.rb, line 33
def post_slack(payload)
  Net::HTTP.post_form(
    endpoint_uri,
    payload: default_payload.merge(payload).to_json,
  )
end