Moon

Sketches: Aftermath

2009 / 06 / 13 — editor, irb, reload, reloading, repl, ruby, sketch, sketches, slime

Apologies for not updating this blog more often. I have been very busy preparing for ToorCamp and releasing code.

One of my newer projects is Sketches. The idea for Sketches came from hacking sessions with Ronin. Eventually you need to automate some small task, this requires that you write a small method in the Ronin Console. I would find myself either writing methods directly into the console or cluttering my home directory with small Ruby scripts that I would load into the console. Usually after testing my code, I realized some changes needed to be made, and the code redefined/reloaded.

This became tedious and was cramping my work-flow. I just wanted to write code in my editor of choice and have it reloaded into the console like magic.

I remembered that Utility Belt had the ability to spawn an editor from IRB and load the resulting code after you exited it. Although, Utility Belt wont track the edited files and reload them whenever they change. Also, Utility Belt comes with a lot of OSX/S3 specific features that I didn't really need.

So I dug up reval.rb, borrowed the name Sketches from Processing's idea of code "sketches" and one week later I had Sketches working in IRB (and Ronin).

Sketches is easy to install:

$ sudo gem install sketches

Then just drop it into your .irbrc:

require 'sketches'

Sketches.config :editor => 'gvim'

When you want to pop open a new sketch:

sketch

You can also name your sketches:

sketch :foo

See all of your current sketches:

sketches

Don't worry about closing the editor, sketches will persist until you exit IRB and can be re-opened using the sketch method:

sketch :foo

After posting it to reddit I was surprised to see such an immediate positive reaction to the little project. I even saw posts on Twitter were people were using GNU Screen with vim for the editor command. I never thought of using screen, totally clever.

Comments

blog comments powered by Disqus