Thursday, August 26, 2010

The Ruby Toolbox

One of the great things about Ruby is the community. When something is not working out as well as it could, someone figures out a way to improve it.

It used to be difficult to select what gems, Ruby libraries, to use when solving a task that I was not familiar with. This is not the case anymore. Christoph Olszowka decided that he wanted to solve this problem and created The Ruby Toolbox.

The Ruby Toolbox, Know your options!

Ruby developers can choose from a variety of tools to get their job done.

The Ruby Toolbox gives you an overview of these tools, sorted in categories and rated by the amount of watchers and forks in the corresponding source code repository on GitHub so you can find out easily what options you have and which are the most common ones in the Ruby community.

This is surprisingly powerful. In my latest project I used the following libraries (among others).

Rails

Rails need no introduction, it is one of the best frameworks for creating dynamic web applications. With best, I mean most productive and fun to work with!

Haml

Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML that's designed to express the structure of XHTML or XML documents in a non-repetitive, elegant, easy way!

Typhoeus

Typhoeus is a http client library, a thick wrapper around curl, just like curl it works like a charm.

Capistrano

Ahh, Capistrano, deployment scripting done right! The simplicity of the structure is worth showing since it should be copied by other lesser tools.

# Create the basic structure
$ cap deploy:setup
mkdir -p /var/rails/rsvc 
/var/rails/rsvc/releases 
/var/rails/rsvc/shared 
...

# Deploy from the repo into a timestamped release directory and symlink current
$ cap deploy
svn checkout -q  -r5454 https://svn.neo4j.org/qa/matrix-framework/rsvc/trunk/rsvc /var/rails/rsvc/releases/20100826122450 
echo 5454 > /var/rails/rsvc/releases/20100826122450/REVISION
....
rm -f /var/rails/rsvc/current && ln -s /var/rails/rsvc/releases/20100826122450 /var/rails/rsvc/current

It's so simple and powerful, that it makes me cry.

God

God, a wonderfully named, server monitoring tool written in Ruby. God aims to be the simplest, most powerful monitoring application available.

RSpec

RSpec, only code can do it justice.

describe Request do
  
  before do
    @sample = Sample.create(:name => 'my_sample', :method => "post")
  end
    
  context '#old' do
    it "should not return any" do
      Request.old.should be_empty
    end
    ...
  end

  context '#delete_old_non_failing' do
  
    it "should delete old non failing requests" do      
      create_old_request :response_status_code => 0
      create_old_request :response_status_code => 200
      expect {
        Request.delete_old_non_failed
      }.to change { Request.count }.by(-2)
    end
    ...
  end
  
  ...
end

Does your language have a Toolbox? Perhaps it is time to create one, or to switch to another language?

No comments: