Articles on Ruby

Jared Carroll

Jared Carroll

Test-Driving the Design of MVC Based Apps

Using tests to drive out the design of objects is an effective way to write code. By taking the perspective of a client, your objects will develop simple, and intuitive interfaces. In addition, the tests act as both documentation and an automated, regression test suite. In this post, we’ll outline a basic test-driven workflow for

Jared Carroll

Jared Carroll

Extracting Data Access Out of Active Record

The Active Record pattern combines data access and domain logic. Over time, an Active Record class can accumulate a large amount of query methods. Moving these methods into a separate object can result in smaller, more cohesive domain objects.

Test-Driven C
Jared Carroll

Jared Carroll

Test-Driven C with Ceedling

Recently, an Arduino project forced me to brush up on my C. Like many programmers of my generation, C was my first programming language; but it has been a while since I wrote anything in it. After a quick K&R refresher, I immediately began looking for a unit testing framework. I found several, but I

Purple waves
Jared Carroll

Jared Carroll

Enumerator: Ruby’s Versatile Iterator

The classic iterator pattern describes a way of accessing the elements of an aggregate object without exposing its implementation. This pattern comes in two flavors: external and internal. An external iterator is controlled by the client, while an internal iterator is controlled by the aggregate object. In Ruby, internal iteration is the norm. Ruby’s Enumerable

Primary rainbow
Jared Carroll

Jared Carroll

How to Test External APIs

Integrating with an external API is almost a guarantee in any modern web app. To effectively test such integration, you need to stub it out. A good stub should be easy to create and consistently up-to-date with actual, current API responses. In this post, we’ll outline a testing strategy using stubs for an external API.

Jon Cooper

Jon Cooper

Explorations in Go: A dupe checker in Go and Ruby

I’ve recently started exploring the new(ish) programming language “Go”. Go is intended to be a systems programming language and offers speed and low-level API along with some sweet features and the beginnings of a great standard library. At Carbon Five we do most of our work in Ruby, JavaScript, Objective-C, and lately, node.js. I’ve really

August Jaenicke

August Jaenicke

Valium extracts Model attributes without instantiating ActiveRecord objects

I was recently on a project that captures and logs data as ActiveRecord models.  Each datum had 10 or so numeric attributes.  One story required pulling out all the values for a particular attribute in a time range (i.e. all the temperatures for the last week).  This could involve 1000’s of rows from the database.

Alon Salant

Alon Salant

Rails 3 Upgrade Tip: Invalidate Session Cookies

I recently finished working with Kathryn Aaker on upgrading Eggs, her farm CSA management software, to Rails 3. While there is a lot of good information out there on upgrading from Rails 2 to 3, we did run in to a few tricky snags not covered in the guides. One such snag happened only once

Ben Lindsey

Ben Lindsey

Browser session cookies and Dalli

A while back one of our clients requested that Rails sessions be stored in session cookies (i.e. a cookie that will expire when the browser is closed). This was for security reasons so your cookie couldn’t be read off the disk and replayed on another browser/machine. We were using memcached to store our sessions and

Jonah Williams

Jonah Williams

Using RVM on TeamCity build agents

We have been using TeamCity to manage the continuous integration, testing, and deployment of many of our recent projects. We have also been using RVM on all of our recent Rails projects to allow us to install multiple ruby versions and create isolated gemsets for each project. RVM proved to be particularly useful on our