Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…


Cannot retrieve contributors at this time

file 109 lines (75 sloc) 3.07 kb


Automate everything!


This gem is currently under development. Some of what you see below is a fantasy.


sudo gem install auto --source


Auto is a framework for writing automation scripts and plugins for those scripts.

require 'rubygems'
require 'auto'

question :name => "What is your name?"
question :delete => "Delete file when finished? (y/n)"

file "#{@name}.txt" do |f|
  f << 'Append to text file'
  f = 'Overwrite text file'

file("#{@name}.txt").delete if @delete

Save it and run it like you would any other Ruby script.

In this example, question and file are both methods provided by the plugins auto-question and auto-file, respectively. They are included when you install the auto gem, but other plugins can be obtained via Rubygems.


Auto has a tasks system similar to Capistrano or Rake. In the previous example, if you had saved your script to ~/.auto/my/name.rb, you would be able to run it by executing auto my:name in Terminal.

Tasks may also be included via plugin. See the Authoring Plugins section for more information.


Installing the auto gem also installs auto-session, which allows you to record the input to your Auto scripts and replay them later.

To save a session, run your script or task with the SESSION environment variable:

SESSION=name ruby my_name.rb
SESSION=name auto my:name

This session would be saved in ~/.auto/session/name.rb (run it by executing auto session:name). It might look like this:

answer :name => 'Joe'
answer :delete => false
run 'my:name'

The session script is executed as any other Auto script. This is cool because you can modify your session files to get custom input for certain questions.

question :name => "What is your last name?"
answer :delete => false
run 'my:name'

You also could have deleted the :name answer to ask that question upon running the session.

Authoring Plugins

Plugins have a lib directory just like any other gem. Here is how the lib file for the Foo plugin might look:

# lib/auto/foo.rb
module Auto
  module Foo

    def foo(*args)
      Foo.instance args

    class Foo
      class <<self
        def instance(args)
          # Do something

Auto uses the gem name (auto-foo) to find lib/auto/foo.rb and include Auto::Foo into the environment. Now you can call the foo method in any of your Auto scripts.

Auto plugins must have gem names with auto- as a prefix to be automatically required.

Include Auto tasks with your plugin by adding a .auto directory to your gem, just as you do with your home directory (~/.auto).

Something went wrong with that request. Please try again.