Ruby Doable Framework

About

This is a gem largely targeted and making the lives of DevOps / SysAdmin types easier. Whether it is installing complicated sets of software, writing maintenance scripts, or automating administrative tasks, Doable aims to simplify these common tasks, as well as make them more reliable and robust.

The core set of values for this framework are:

  • Extensibility
  • Modularity
  • Simplicity
  • Concurrency
  • Flexibility
  • Reliability
  • Remaining lightweight

These goals are largely achieved through a small set of core features, with nearly all functionality broken out into plugins that can be enabled as required.

Building

The eventual goal is for this gem to simply be available via a normal rubygems search, but until then, you must build and install the gem yourself. This can be done like so:

#!bash
# need Mercurial to clone the repo... or download it from https://bitbucket.org/jgnagy/doable/get/tip.zip
hg clone https://bitbucket.org/jgnagy/doable
cd doable
# highly recommend using RVM here, and Ruby 2.x or above
gem build doable.gemspec
# install what you just built
gem install ./doable-*.gem

Sometimes you might get lucky and there's a semi-recent version of the pre-built gem available on bitbucket here.

Usage

Require the right gem(s):

#!ruby
require 'doable'

To create a simple job, define a plan:

#!ruby
job = Doable::Job.plan do |j|
  j.before  { log "Starting my awesome job" }
  j.step    { # do some stuff here }
  j.attempt { # try to do some other stuff here }
  j.after   { log "Looks like we're all set" }
end

job.run # executes our job

This job is obviously pretty boring, but it shows some of the basics. Now let's continue and include some additional helpers in a new, more complex job:

#!ruby
require 'doable/helpers/password'

class JobWithPasswords < Doable::Job
  include Doable::Helpers::Password
end

job2 = JobWithPasswords.plan do |j|
  j.before  { log "Here's a password for you..." }
  j.step    { puts "Password: " + generate_password(16) }
end

job2.run

After this job runs, you should see output that looks something like:

[2015/01/29 00:10:36] Here's a password for you...
Password: ZwyIVH8LjHGYYzDX
[2015/01/29 00:10:36] All Job steps completed successfully!

Hopefully this demonstrates how to get access to additional helper methods.

License

Doable is distributed under the MIT License.

Contributing

I welcome pull-requests. I may or may not use your code, but I encourage the growth of others too. If this project inspires you to contribute, feel free to fork my code and submit a pull request. In most cases, I'll probably recommend you package additions in an extension gem rather than including new files, etc, directly into the core codebase.