Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Author Archives: Ric Roberts

By Ric Roberts / November 23, 2009

Have you ever yearned for something like Rails’s script/console or Merb’s merb -i in your other Rack based apps? If so, then Marcin Kulik‘s racksh, inspired by Heroku’s console, might be for you.

Racksh is a console for Rack based ruby web applications. It allows you run a console in the context of an application environment for Rails, Merb, Sinatra, Camping, Ramaze (or even your own framework) provided there is a rackup file in the root directory.

When you run the racksh command, it loads the whole application environment just like a Rack web server, but instead of running the app it starts an irb session where you can invoke commands. Read More

By Ric Roberts / November 5, 2009

jekyllJekyll is a simple Ruby-powered static site generator, originally by Tom Preston-Werner (aka mojombo) of Github fame. It’s focused around blogging, but it can be configured to generate any kind of static site. (Note: Jekyll has been around for about a year – Tom originally blogged about it in November last year, so apologies if this is old news to some readers, but I’ve only recently discovered it!)

Because Jekyll outputs a static site structure, it means you can host your blog (or site) from anywhere that you can serve static HTML, simply by using your favourite web server (e.g. Read More

By Ric Roberts / October 31, 2009

JustinRiot is a new Ruby test framework by Justin Knowlden that focuses on faster testing. Justin was frustrated with his slow running test suites, despite employing techniques such as using factories, mocks and avoiding database access. He realized that a slow-running suite makes one reluctant to run it or expand it – not good.

With Riot, each test consists of a block which forms a single assertion on the topic of the test, keeping the tests focused. Tests run in a specific context, and the setup code is only run once per context, further contributing to the speed of your test suite, and unlike some Ruby test frameworks, such as Shoulda, that rely on or are based on Test::Unit, Riot has taken a new approach for speed purposes. Read More

By Ric Roberts / October 7, 2009

mustacheMustache is a new templating library from Chris Wanstrath (a.k.a. defunkt of GitHub fame) that provides a way to render views in your chosen Ruby web framework. Influenced by ctemplate, Mustache helps to keep your MVC layers separate by actively preventing the inclusion of application logic in your views.

With Mustache, the typical view layer is split up into two sub-layers: a Ruby Class-based “view” and an HTML “template”, so you can concentrate on crafting your HTML without polluting it with embedded Ruby logic. This separation also makes it easier to test your view-code.

Amusingly, the name of the project comes from the way that you insert references to the view class into the template. Read More

By Ric Roberts / September 24, 2009

watcherWatchr is a continuous-testing tool by Martin Aumont in the vein of Autotest (part of the ZenTest package).

At its heart, Watchr basically watches any (or all!) of your project’s files, then executes arbitrary Ruby code of your choice when things change.  Watchr configuration takes such a form:

watch(‘pattern’) { |match_data_object| command_to_run }

For example, to produce Autotest-like functionality, you’d just specify Watchr to run the tests whenever a test or some library code changes, like this (taken from Martin’s blog post):

watch(‘test/test_.*\.rb’) { |md| system “ruby #{md[0]}”}
watch(‘lib/(.*)\.rb’) { |md| system “ruby test/test_#{md[1]}.rb”}

…but Watchr can be used for much more than just testing. Read More

By Ric Roberts / September 14, 2009

cucumberEvan Light has recently pushed his Coulda project to Github – it’s a test framework based on Test::Unit, inspired by Cucumber, Shoulda and Thor.

Coulda works like Cucumber in that it’s a Domain Specific Language for capturing the behaviour expected by your code, as part of the Behavior Driven Develoment approach (BDD). Others have noted it’s a little like the RSpec story runner.

Where Coulda differs is that instead of using Gherkin to convert your statements about the behavior to code using regular expressions, it uses standard method calls. This is less of a cognitive leap for the developer… Read More

By Ric Roberts / September 8, 2009

the merb wayI’ve been reading the Merb Way by Foy Savas (Addison Wesley).  I was a little sceptical about this book at first, because of the recent marriage of the Merb and Rails core teams and the announcement that the Merb codebase would be merged with Rails as part of the march towards Rails 3. As Yehuda Katz put it, “Merb 2 is Rails 3″.

So, is this book now redundant?  I don’t think so. As Obie Fernandez explains in the foreword, knowing about Merb is still valuable as it is a fairly widely used framework, and it will probably continue to be seen in the wild for a good while after Rails 3 is released.  Read More

By Ric Roberts / September 2, 2009

couchI have been contemplating the use of document-stores in my Ruby apps for a few months (you might remember my MongoMapper post from back in June), and I’ve been following developments in the No-SQL movement. George Palmer’s presentation at Rails Underground on his couch_foo gem inspired me to explore the possibilities further, and I’ve recently started work on incorporating CouchDB into some projects that I’m working on.

What is a “document store?”

Couch is one of several available document oriented databases (the other main contender being MongoDB, for which there’s a good comparison on the Mongo website). Document stores go some way to bridging the gap between traditional functionality-rich relational databases (like MySQL, Postgres) and fast, highly scalable key/value stores (such as Toyko Cabinet). Read More

By Ric Roberts / August 20, 2009

ready set goGemcutter is a new gem hosting repository that aims to replace RubyForge as the canonical repository for gems. The project has been around for a couple of months, but Thoughtbot recently announced they’re helping out with a forthcoming redesign of the site

As part of the plan to get everyone using it as their main gem repository, Gemcutter has already imported all of the gems that were on RubyForge – meaning there are over 5000 gems on there already.

After installing Gemcutter (with gem install gemcutter), consumers of gems just need one command to set Gemcutter up as their primary source:

gem tumble

As a publisher, you can just use the git-esque ”gem push” command to release a new version of your gem.  Read More

By Ric Roberts / August 14, 2009

monkI recently came across the interesting-looking Monk framework. It allows you to specify a list of dependencies for technologies to use in your project (in the form of git repositories or gems), and it will take care of extracting them into your application’s vendor folder.

With the default skeleton (for which you’ll need a Redis key/value database installed), you’ll get a Sinatra application with Haml, Rack, Contest, Stories, Webrat and Ohm. However, you can create your own skeleton with its own dependencies if you like.

You can install Monk with:

gem install monk

… and then initialize a project with the default skeleton:

monk init myapp

This will give you a familiar structure with helpers, models, routes, views, lib and vendor folders. Read More

By Ric Roberts / August 13, 2009

guess who?Simone Carletti of Altura Labs recently announced on his blog the release of a new pure-Ruby Whois library, inventively named “Whois“.

He needed a whois library for one of his projects, but found that the existing options didn’t satisfy his requirement of being able to query both IP addresses and top level domains.  Simone’s offering replaces the original whois gem by Cyril Mougel, with which it’s backward compatible.

Using the ‘all-in-one’ whois class-method will give you the default behaviour, with a timeout of 5 seconds. If you want more control you can initialize a new instance of the client:

# =whois response for

client =
client.timeout = 3
# =whois response for

For more details, check out Simone’s blog post, the docs, and the Github repository. Read More

By Ric Roberts / August 6, 2009

bowlineBowline is a new MVC GUI framework for developing cross-platform desktop applications using Ruby, HTML, CSS and Javascript. The author, Alex MacCaw, aims to make building a desktop app as simple as creating a Rails site.

Unlike pure Ruby desktop libraries like Shoes, Bowline builds on Appcelerator Titanium, an SDK for building desktop apps that basically gives you a Webkit window and a set of APIs for interacting with various operating systems. This lets you develop for the desktop using familiar web technologies, including CSS3 and HTML5 (think Adobe Air!).

To allow your Ruby code to interact with your HTML, Bowline introduces the concept of “binders” which can update your views as the underlying data changes (a bit like controllers in Rails). Read More

By Ric Roberts / August 5, 2009

chefChef isn’t exactly new, but I’ve been looking into it recently after briefly talking to Lindsay Holmwood at Rails Underground.

Basically, Chef is a Ruby-based configuration management engine. You set up recipes for how you want your system configured, and then Chef will cook it up for you.  So, you can write lovely Ruby code to manage your servers, rather than running commands directly on your server.

With Chef, one of your systems is the server and all others are clients that communicate with the Chef “server” via REST over HTTPS. The server is a Merb application that stores cookbooks for your nodes using CouchDB. Read More

By Ric Roberts / July 30, 2009

rails undergroundI attended the Rails Underground conference in London at the weekend (July 24-25, 2009). As always seems to be the case at these events, I got the most value out of the more theoretical and opinion-based talks rather than ‘how-to’ style presentations. Having said that, Pat Allan and George Palmer gave great talks on their respective thinking_sphinx and couch_foo plugins.

I’m going to concentrate on the keynotes from the two days, which give quite differing perspectives.

Fred George – Rails is a hammer. Not everything is a nail.

fred georgeIn the keynote (video link) for the first day, former Thoughtworker, Fred George warned us against using Rails for the wrong kinds of projects.  Read More

By Ric Roberts / July 23, 2009

backgroundedLike Ryan Sonnek, I’ve dabbled with a few different ways to run background processes in my Ruby apps, even resorting to knocking together my own (far from perfect) solution. As Ryan says on his blog, many popular libraries have complicated interfaces and don’t “feel right”.

I tend to disagree, however, with his statement that every ruby background job solution sucks, and I’m sure he doesn’t really mean it. Although his offering, Backgrounded, is refreshingly simple and concise, it’s effectively just a wrapper for other solutions.

With Backgrounded, if you want a certain method to always run in the background, you can specify it like this:

class User
backgrounded :do_stuff

def do_stuff
# do all your work here

…and then just call that method in the normal way. Read More