Project

steps

0.02
No commit activity in last 3 years
No release in over 3 years
A way to simplify the output of shell scripting written in ruby. Integrates with Capistrano and Rake tasks.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 10.1.0

Runtime

>= 1.2
>= 1.6
 Project Readme

steps

Build Status

General

A gem that produces simple user feedback in scripting environments.

Integrates with:

  • Capistrano Tasks
  • Rake Tasks
  • Generic Ruby shell scripting

Installation

gem install steps

Usage

require 'steps'

To define a "step" in your scripting process simply surround the grouping of operations like this.

    step "Do Something" do
      # stuff you want to do
    end

Nested steps are supported

Other

Exit if step fails. If nested, fail parent step.

    step "Super Important", :vital => true do
      # vital stuff
    end

Manually bail out of a step

    step "Do Something" do
      # do something
      if you_want_to_bail
        raise "This is the error Message"
      end
    end

Custom Complete Message

    step "Do Something" do
      # do something
      "This is the success Message"
    end

Provide feedback

    step "Do Something" do
      # do something
      report "The user would like to see this info"
      # do more stuff
    end

Getting User Feedback (highline integration)

confirm

Function similar to highline agree function, except it plays nice with our output.

It also accepts a :vital option if you want to exit with a negative response (No).

    step "Confirm Blue" do
      if confirm "Do you like blue?"
        # bail out if they are not sure they like blue
        confirm "Are you sure you like blue?", :vital => true
      end
    end

retrieve

The retrieve function is essentially a shadow of the highline ask function, except it plays nice with our output

    step "Get Favorite Color" do
      feedback = retrieve "What is your favorite color?"
    end

Print stacktraces for errors - Debug Mode

To get more information while debugging you may activate the debug mode. The gem will print the stacktraces for exceptions while in debug mode.

    step "Do something", :debug => true do
      # ...
    end

Debug mode is inherited by all nested steps.

Capistrano Deployment Integration

If you want to quiet down your Capistrano output and use this to provide the output, you can manually quiet the Capistrano logger and use this gem in the following way.

  require 'steps'

  logger.level = Logger::IMPORTANT      # or Capistrano::Logger::IMPORTANT

  # ... omitted ..

  before "deploy:update_code"       do start_to "Deploy" end
  after "deploy:update_code"        do success end

  before "bundle:install"           do start_to "Bundle" end
  after "bundle:install"            do success end

  before "deploy:migrate"           do start_to "Migrate Database" end
  after "deploy:migrate"            do success end

  before "deploy:assets:clean"      do start_to "Clean" end
  after "deploy:assets:clean"       do success end

  before "deploy:assets:precompile" do start to "Compile Assets" end
  after "deploy:assets:precompile"  do success end

  before "deploy:restart"           do start_to "Restart" end
  after "deploy:restart"            do success end

Development

rake
rake install