A couple of months ago, I started learning to program in Ruby. Largely because I somehow stumbled across Brian Marick's book,
Everyday Scripting with Ruby, which poses the questions: "Do you spend too much of your working life copying and pasting or otherwise manually manipulating data? Wouldn't you like to be able to get a computer to do that for you?" To which I answered, "Yes!"
So, I've been slowly working my way through Marick's book, and playing around with
ruby koans, and reading bits of
why's poignant guide to ruby, which has got to be one of the most extraordinary pieces of technical writing ever committed.
And I've written some little toy scripts, but today I wrote my very first properly useful script. To give a bit of background: For FOGcon, we keep the code for our website backend in a source code repository called Github. We use Github, among other things, to track the bugs and issues that people report in using the database. And one of the things I periodically have to do is get information about issues out of Github and pass it on to people who don't have Github accounts and so don't have the ability to access our issues tracker directly. Up until today, I have been doing this by clicking around in Github and copying and pasting.
But today, I thought, "I should be able to script this." And lo and behold, with a bit of tinkering, I now have a script that logs into Github, downloads all the open issues in a given milestone, and prints out the issue number, title, and description for each one.
Interestingly, the breakdown of how I developed the script went something like this:
~30 minutes: Determining that there is a Github API, that a suitable Ruby wrapper for the API exists, and researching whether this wrapper can access the information I want.
~1 hour 30 minutes: Installing various necessary Ruby 'gems' (a.k.a libraries) and dinking around trying to resolve various dependency issues.
15 minutes: Writing and testing the script.
This was pretty much tinker toy programming, in that the Octokit Ruby library that I used did all the hard work. All I had to know was how to do some basic operations on an array, and how to print out the information. The entire script is 13 lines long.
So, yeah, this decision to learn a bit of Ruby scripting seems to be paying off.