Skip to content

Instantly share code, notes, and snippets.

@ymek
Created December 24, 2013 00:15
Show Gist options
  • Save ymek/8106946 to your computer and use it in GitHub Desktop.
Save ymek/8106946 to your computer and use it in GitHub Desktop.
STDOUT.sync
def build_spinner
chars = %w(πŸ™‰ πŸ™‰ πŸ™ˆ πŸ™ˆ πŸ™Š πŸ™Š πŸ™ˆ πŸ™ˆ).cycle
Thread.new do
loop do
print chars.next + ' '
sleep(0.1)
print "\b\b\b"
end
end
end
def start_progress(description)
dots = 40 - description.length
print "--> #{description} #{'.' * dots} "
@spinner = build_spinner
end
def stop_progress
@spinner.kill
print "\b\b\b"
puts "βœ“".green
end
# Specify starts and stops for deploy:update_code and bundle:install
# due to default chaining to finalize_update within update_code
before 'deploy:update_code' do
start_progress('Updating Code Base')
end
before 'bundle:install' do
stop_progress
start_progress('Bundle installing')
end
after 'bundle:install' do
stop_progress
end
tasks = {
'deploy:cleanup' => 'Cleaning up',
'airbrake:deploy' => 'Notifying Airbrake',
'deploy:start' => 'Starting server and workers',
'deploy:stop' => 'Stopping server and workers',
'deploy:restart' => 'Restarting server and workers',
'deploy:assets:precompile' => 'Precompiling assets',
'campfire:pre_announce' => 'Notifying Campfire',
'campfire:post_announce' => 'Notifying Campire',
'newrelic:notice_deployment' => 'Notifying NewRelic'
}
tasks.each do |task_name, description|
before task_name do
start_progress(description)
end
after task_name do
stop_progress
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment