Category Archives: ruby

HTTParty::Response doesn’t like tap

A small surprise by hacking rivendell-api, if you try to use Object#tap on HTTParty::Response like this : do |response|
  response.error! unless response.success?

The response instance won’t find these HTTParty::Response #error! or #success? methods (?).

In fact, the response variable isn’t a HTTParty::Response because of HTTParty::Response#method_missing which delegates the #tap method the parsed_response :-/

Without a tap, these 3 lines work fine :

response =
response.error! unless response.success?

Check if selected date is correct with cucumber

The default web steps provided by cucumber provide a way to check the content of a text field : the "..." field should contain "...", but how to check if the date selected by default in a form is correct ?

To describe some of the features of the coming PigeBox web interface, we needed something like : the "..." datetime should contain "17:00:00".

Even if webrat doesn’t provide the builtin method to “read” a Rails datetime select, this piece of code adds the method selected_datetime to webrate scope.

With this small webrat extension, the following step becomes possible :

Continue reading

First “public” release for alsa-backup

For a long time, we’re using continuous recording tools to record our radio broadcasts. Many of these tools were homemade and alsa-backup is the latest project of this “serie” (after jack-backup and just-record).

alsa-backup can :

  • record several channels,
  • change record file according your naming policy (… without a blank),
  • run as daemon,
  • log into syslog,
  • stop record and retry after errors

And many other features are coming :) This piece of Ruby code is more flexible than just-record. It uses the awesome ruby-ffi library which allows to use C libraries with few lines of ruby code.

alsa-backup is available as debian/ubuntu packages on Tryphon’s debian repository. Source files are available in GitHub alsa-backup repository.

Debian packages for Phusion Passenger 2.2.4

The Debian packages for Phusion Passenger 2.2.4 are available on the debian tryphon repository. This time, I have been a little faster than John and his ubuntu packages.

But : these packages don’t include nginx support and the documentation is, for the moment, skipped.

librack-ruby1.8 under lenny seems very old (Mauro confirms the problem in his comment). I’m trying to backport a fresher release.

Setup your Rails environment with rails_setup

Rails provides great tools to manage the application environment. Using gems instead of freezed librairies is usefull in many cases (when you’re using GitHub for example ;-) ). But it can become quickly painful too.

A specific situation makes the “all-in-gems” policy very painful : making a continuous integration server with a several rails projects. Adding a project, changing a config.gem, each time you need to make the required gem installs in a ssh session :-(

rails_setup provides a simple solution.

You’re a new developer on a rails project ? Retrieve the project sources and make ./script/rails_setup. It will install :

  • the rails gem (and “active” dependencies) (in the version required by the project)
  • the gems configured in the application,
  • the gems required by the database adapter (to be improved)

If you’re using a continuous integration tool (like CruiseControl.rb), build yours projects with ./scripts/rake_with_rails_setup (which runs rails_setup before rake). With the provided sudo support, your CruiseControl.rb daemon user will install required gems for you.

rails_setup is a very simple rails plugin which provides a small set of scripts and rake tasks :

./script/plugin install git://

More details in the rails_setup README file.

Install CruiseControl.rb on debian or ubuntu

CruiseControl.rb is a continuous integration tool. It runs a build process when modifications are detected in a project. Java developers know CruiseControl (often discussed in this blog). CruiseControl.rb is very practical for projects built with rake, especially rails projects.

For example, CruiseControl.rb can:

  • follow several branches of your project,
  • run tests or specs in a clean environment,
  • notify our team when something goes wrong (by email, twitter, jabber, irc, campfire, …),
  • deploy with capistrano our development stage when specs are verified,

This CruiseControl.rb debian package is based on CruiseControl.rb github branch of ThoughtWorks.

Continue reading

Let’s Puppet

Puppet is a great tool to automatize your system administration tasks.

Many tutorials are available to make your first steps like the official Getting Started with a Simple Puppet Recipe or the (french) Puppet, Administration système centralisée.

But when your puppet configuration becomes a real project, it’s great to see how the other users organize and manage it.

Many users publish their modules like the David Schmitt’s puppet complete configuration or Lab42.

We’ll try to publish our “complete” puppet project because scripts, rake tasks and tests are an important part of a good puppet project.

This project doesn’t contain private information (passwords, certificates, …), these are managed by an unpublished module.

For the moment, the interesting part is the integration of external tools : rake tasks, cucumber tests, generate scripts or the capistrano deployment (to be published).

I’ll try to describe, in future posts, these current (and future) tools.