Skip to content

Instantly share code, notes, and snippets.

@marksim
Created December 3, 2009 20:24
Show Gist options
  • Save marksim/248478 to your computer and use it in GitHub Desktop.
Save marksim/248478 to your computer and use it in GitHub Desktop.
Dir["#{ENV['HOME']}/.cap/*.rb"].each do |tasks|
load tasks
end
set :stage, nil unless defined? stage
namespace :growl do
task :notify do
growl_send(ENV["GROWL_MESSAGE"] || "wants your attention")
end
task :alert do
growl_send(ENV["GROWL_MESSAGE"] || "needs your attention", 2)
end
end
after "deploy" do
ENV["GROWL_MESSAGE"] = "deployed #{application} #{stage}"
find_and_execute_task "growl:notify"
end
after "deploy:migrations" do
ENV["GROWL_MESSAGE"] = "deployed and migrated #{application} #{stage}"
find_and_execute_task "growl:notify"
end
after "rollback" do
ENV["GROWL_MESSAGE"] = "rolled back #{application} #{stage}"
find_and_execute_task "growl:alert"
end
def growl_send(message, p = 1)
require 'meow'
icon = OSX::NSWorkspace.sharedWorkspace.iconForFile(`which cap`.chomp)
Meow.notify("cap", "Capistrano", message, :priority => p, :icon => icon)
rescue LoadError
`growlnotify -ncap -p#{p} -m #{message.inspect} Capistrano`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment