Spinner

# Create a new spinner instance
spinner = Spinner.new

# Add a task block
spinner.task("Number 1") do
  sleep(5) # simulate taking a while to do something awesome
end

# Add another task
Spinner.task("Number 2") do
  sleep(2)
end

# Run the tasks
spinner.spin!

Spinner can call rake tasks, too

# Example: completely reconstruct a Rails database using migrations

spinner = Spinner.new
spinner.task("Dropping", 'db:drop')
spinner.task("Creating", 'db:create')
spinner.task("Migrating", 'db:migrate')
spinner.task("Loading", 'db:test:load')
spinner.task("Seeding", 'db:seed')
spinner.spin!

Initialize with tasks

# Tasks are just arrays with two items: the name of the task (defaults to "Executing") and the task (either a string representing a rake task, or a block that responds to "call")

tasks = []
tasks << [ "Drop database", "db:drop" ]
tasks << [ "Sleep 2 seconds", lambda { sleep(2) } ]
spinner = Spinner.new(*tasks)
spinner.spin!