Thursday, October 28, 2010

Using Ruby for Something Not Rails.

Hello!
So, I fell in love with ruby before I knew what ruby on rails was about. I started using ruby because I remembered the thrill of using my computer to actually write the software I needed to get a particular job done. I especially was excited because with ruby, I could run something across many platforms with little modification, in theory. In the old school world of line numbered BASIC, one had to tailor tune the BASIC to his or her platform. I used the Commodore 64, perhaps the creme de la creme, but still, different than AT&T, Tandy, or IBM. Often, the differences were subtle, and I hated going to school, and using the TRS-80's or Apple IIe's because I felt they changed the BASIC only because they wanted me use their software. Incidentally, this became the seeds to my use of Open Software, before I knew about Richard Stallman.
Back to the Ruby.
Chris Pine is my hero. If you've never read Learning to Program you should, even if you are the most amazing 1337 h4xx0r there is. I discovered it while trying to find a language I could love as deeply as I loved my Commodore. Ruby is it.
I worked my way through the book, and began using ruby for various things in my computer, the most coolest of which is updating itself.
That's right, I use ruby to update itself.
Every whenever I want to, I build ruby from source using a little script I hacked together on a whim. In the process of writing it, I learned how ruby does things like change directory in a linux environment, and how adding a puts in there can make things more verbose.
Here's the gist of it: upruby I know it's not much, but it's powerful, and can be improved, and I am interested in hearing how you would improve it. I've been thinking of parameterizing certain elements, and having the file run off of a configuration file. I keep everything invisible to non admin users for obvious reasons, so I don't have to worry about maliciously destroying my /dev/sda. I've also thought about making it a general script to update a lot of different things, and making it so it will run as a cron job, or perhaps only run when I am expressly logged in as the root user, and not merely sudo runnable, just because I don't want to have an issue with something taking a while (like updating all the gems) and have to enter my sudo password multiple times.

I am interested in hearing about how you would handle this situation. How would you adapt this script to run your updates?
That is all!
Next post is going to be all about amateur radio! I hope you are as excited as I am about that!
l8rz,
gb hoyt

No comments: