Ruby

Ruby's DataMapper 101

It's been a while and lately I've been playing again with Merb so I figured I'll post about DataMapper. DataMapper is an ORM for Ruby which most Merb users prefer because of its simplicity and neat features.

Before we can start playing with it, you can install it using the following command:

sudo gem install dm-core

Also, for the purpose of this tutorial we're going to install the sqlite database driver:

Dumb server :)

I noticed that Ruby has a neat way in handling sockets, It makes it more natural and easy to read. But as usual, I can't be much satisfied without trying it myself... So I fired up the Ruby docs + a couple of googling. 

FTP? nah, more like remote navigator.

I was checking out the ftp library of ruby and since the commands are minimal, I figured it would be fun to create a simple ftp program in one file. Since I'm feeling lazy, it ended-up as a simple remote directory navigator instead.

Hello FXRuby

To illustrate how simple, clean and fun FXRuby is, Here's a sample Hello World:

A little bit of FXRuby

I've been looking around for a Ruby GUI toolkit that's kickass and I've since been hearing positive feedback regarding FXRuby so I tried it out tonight.

Now I have some experience with other GUI libraries like PyQt (Python + Qt) for example but FXRuby for me is far more supperior when it comes to simplicity.. mainly because of Ruby. So after a little reading here and there, I tried this simple image browser app.

Ruby's spaceship operator

When I first saw this operator I thought this is not something that I'll be using more often, but it turns out that this thing is really handy. To illustrate this, I have a simple string sorting according to its length:

Merb's Partial

As usual I'm still playing with Merb and I would like to share Merb's partial. Basically its the ability to render objects using a template file that could be used inside several other templates. Hmm.. I hope that went well.

To give you a quick example, lets say your building a blog with a controller named posts and got a posts folder inside your views which contains new.html.erb and edit.html.erb. Your new.html.erb might contain something like:

Just a recap

It's been 4 days since my last post and I just want to give a quick recap of where am I now with my Ruby adventure. As I was playing with Ramaze, deep inside I really wanted Merb.

But because Merb got some really quirk going on my system I had to invest some time playing and googling on how things work. Now that I have a stable setup, expect more Merbs to come.

Ruby's Hpricot

As the next step to my Ruby adventure, I figured I'll create some Ruby libraries which I don't care if someone already implemented a similar one. I just want to practice mashing things up on Ruby.

My first candidate is creating a Twitter library and for that I know I need some xml parsing. Like in any high-level programming language, Ruby has a built-in parser. Its fast but not as elegant so I went looking and found Hpricot, It has very elegent style and its so simple.

Hello Ramaze

Somehow I managed to have a somewhat useful time today on my last minute before I go to sleep. I got Ramazed to have a place on my brain, well its not as tedious as it sounds but I did.

I finished the 12 part series of iteration on creating the todolist! It's not much but Its the start towards my Ruby experience. I created a tarball of my sourcefiles incase someone might wanna look at it.

Happy Ruby coding!

Syndicate content