Slack Webhook Gem

A simple ruby gem for getting functionality out of Slack's webhooks.

Installation

Add this line to your application's Gemfile:

gem 'slack'

And then execute:

$ bundle

Or install it yourself as:

$ gem install slack

Usage

Slack.configure do |config|
  config.channel = '#engineering' # or '@jeff'
  config.icon_emoji = ':ghost:'
  config.url = 'https://hooks.slack.com/services/id_1/id_2/token'
  config.username = 'deploybot'
end

Example usage in capistrano to notify deployments

task :notify_start do
  if ['production', 'staging'].include?(fetch(:rails_env))
    Slack.post("Deploying `#{fetch(:branch)}` to `#{fetch(:rails_env)}`")
  end
end