class Capistrano3::Notification::Slack

Public Instance Methods

notify(message) click to toggle source
# File lib/capistrano3/notification/slack.rb, line 6
def notify(message)
  notifier_options = { username: user, channel: channel }.reject { |_x, y| y.nil? }
  ping_options = {}.tap do |h|
    h[icon_type] = icon if icon_type
  end
  ::Slack::Notifier.new(webhook_url, notifier_options).ping message, ping_options
end

Private Instance Methods

channel() click to toggle source
# File lib/capistrano3/notification/slack.rb, line 20
def channel
  fetch(:slack_channel)
end
enabled?() click to toggle source
# File lib/capistrano3/notification/slack.rb, line 37
def enabled?
  user && channel && webhook_url
end
icon() click to toggle source
# File lib/capistrano3/notification/slack.rb, line 24
def icon
  fetch(:slack_icon) || nil
end
icon_type() click to toggle source
# File lib/capistrano3/notification/slack.rb, line 28
def icon_type
  case icon
  when /^:.+:/
    :icon_emoji
  when /^http/
    :icon_url
  end
end
webhook_url() click to toggle source
# File lib/capistrano3/notification/slack.rb, line 16
def webhook_url
  fetch(:slack_webhook_url)
end