Scott Watermasysk

Still Learning to Code

Isolated Gem Hacking

I noticed a recurring pattern this week. At least once a day, I complete the following tasks:

  1. Create a new directory
  2. Copy a recent .rvmrc file to that directory
  3. Edit the name of the gemset in the .rvmrc file
  4. Start textmate

I have also been adding both a Rakefile and Gemfile within this directory.

To automate this, I created the following function1 you can drop in your favorite shell’s startup file (.zhsrc, .bashrc, etc.).


function mkgemset() {
  mkdir $1
  echo 'source :gemcutter' > $1/Gemfile
  touch $1/Rakefile
  echo 'rvm_gemset_create_on_use_flag=1\nrvm gemset use' $1 > $1/.rvmrc
  cd $1
  git init
  mate .
}

If you have suggestions to make this better, please fork the gist

1 Hat tip to Peepcode. This function started with the gmate function in the Peepcode command line episode.