Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

demonstration of how to create your own cap/rake task rubygem

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Rakefile
Octocat-spinner-32 demrec.gemspec

Demonstraion of how to create your own cap/rake tasks gem

In this demo we'll create a rubygem called 'demrec'.

It will contain tasks for rake and capistrano that can easily be shared between multiple projects.

Start a new gem

gem install bundler
bundle gem demrec
# update demrec.gemspec
rake install

Add tasks

You can explore the source of this 'demrec' to see examples of tasks.

mkdir demrec/lib/demrec/recipes
touch deprec/lib/demrec/db.{rake,rb} # Add tasks later

# Update lib/demrec.rb
if defined?(Capistrano)
  Dir.glob("#{File.dirname(__FILE__)}/deprec/recipes/*.rb").each { |t| 
    require t 
elsif defined?(Rake)
  Dir.glob("#{File.dirname(__FILE__)}/deprec/recipes/*.rake").each { |t| 
    import t 

Add to your project

echo "gem 'demrec'" >> Gemfile

echo "require 'demrec'" >> Rakefile
echo "require 'demrec'" >> Capfile

# Those last two can be omitted under certain circumstances.
Something went wrong with that request. Please try again.