hipchat
hipchat copied to clipboard
HipChat HTTP API Wrapper in Ruby with Capistrano hooks
h1. HipChat Wrapper
A very basic wrapper for the HipChat HTTP API.
h2. Usage
bc.. client = HipChat::Client.new(api_token) client['my room'].send('username', 'I talk')
Send notifications to users (default false)
client['my room'].send('username', 'I quit!', :notify => true)
Color it red. or "yellow", "green", "purple", "random" (default "yellow")
client['my room'].send('username', 'Build failed!', :color => 'red')
h2. Capistrano
bc.. require 'hipchat/capistrano'
set :hipchat_token, "
h3. Who did it?
To determine the user that is currently running the deploy, the capistrano tasks will look for the following:
The $HIPCHAT_USER environment variable
The hipchat_human capistrano var.
The git user.name var.
The $USER environment variable.
h2. Rails 3 Rake Task
Send a message using a rake task:
bc. rake hipchat:send["hello world"]
Options like the room, API token, user name and notification flag can be set in YAML.
RAILS_ROOT/config/hipchat.yml:
bc.. token: "whoami
notify: true # Defaults to false
h2. Engine Yard
Use a "deploy hook":http://bit.ly/qnbIkP to send messages from Engine Yard's Cloud platform.
RAILS_ROOT/deploy/after_restart.rb:
bc.. on_app_master do message = "Deploying revision #{revision[0...6]} to #{node[:environment][:name]}" message += " (with migrations)" if migrate? message += "."
Send a message via rake task assuming a hipchat.yml in your config like above
run "cd #{release_path} && bundle exec rake hipchat:send MESSAGE='#{message}'" end
h2. Copyright
Copyright (c) 2010 Mojo Tech. See LICENSE for details.