Games · Programming · Source Code

Introducing a ruby adventure in text or how I learn(ed) Ruby

I am currently studying the Ruby programming language. You know; as a software developer you should learn at-least one new language per year! Ruby is a dynamic multi-paradigm programming language that is really fun to use!

This time around I’ve decided to focus on learning a testing framework for Ruby very early. My choice was the very elegant rspec specification framework. RSpec, as most great Ruby libraries, uses an (internal) Domain Specific Language to describe its application domain; which in RSpecs case is describing the expected behaviour of your application.

At the very beginning of my journey I’ve used the Interactive Ruby (irb) REPL (Read-Eval-Print Loop) to explore the language. REPLs are a great way to explore your language of choice! Soon after I’ve started to write tests (or rather specifications) for features of the Ruby language. Personally this didn’t keep me going for very long; it was quite useful.. but.. I needed an actual project to work on!

Of all the goodies Ruby comes with, its Meta Programming features are the most thrilling for me. I wanted to write my own Domain Specific Language (DSL) inside Ruby. And thus was born Teta, a ruby text adventure!

Take a look at this link for an example of the DSL. (You can find all of the source code of Teta on github.)

When I am working on Teta I use three Terminal sessions (in TABs). The 1st TAB has got VIM loaded to edit the source code (Derek Wyatt has got tons of great tutorial videos about VIM):

VIM text editor

.
The 2nd TAB is used to issue various commands; including executing all rspec specifications or pushing changes to the git repository. I also use it to access the great ruby documentation (using the ri command):

Teta Rspec Specifications

.
And finally the 3rd TAB has got an interactive ruby session loaded for exploration and experimentation:

Interactive Ruby

.
But back to learning new languages using Test Driven Learning. It was initially a blog post by @pragmatrix that pushed me into the direction of using a testing framework when first learning Ruby. To say the least; it was really worth it!

In case you are like me and don’t feel like writing tests for language features; then there are some great people who already did this for you. The Ruby Koans walk you along the path to enlightenment:

.
If you also want to get started with Ruby then I suggest that you get the following equipment:

1. Ubuntu (Wubi)
2. VIM
3. Ruby Version Manager to install..
4. Ruby
5. RSpec gem as the testing/specification framework
6. Git to get data to and from github
.
Till then, enjoy the journey \o/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s