giant robots smashing into other giant robots

Written by thoughtbot

lolconomy

This week in open source

A somewhat short update this week, in large part because I’m writing this from a different timezone than normal. Next week I’ll be five hours slower, don’t you worry!

suspenders

New in suspenders, our Rails app generator: a pre-packaged email validator class (b91ea65), which probably mixes well with things like liaison. Also on the email front, delivery errors are a full error in development, which means we can catch errors faster (637427d). Both of these improvements brough to you by Dan Croak (croaky).

shoulda-matchers

The shoulda-matchers collection of RSpec/shoulda matchers has hit 1.0.0! Gabe Berke-Williams (gabebw) made the switch from 1.0.0.beta3 to 1.0.0 (7c408ef), but first removed a deprecation warning from the rdoc generator (c47557c) and simplified the test suite (22740fd).

shoulda-context

Another 1.0.0 release for shoulda this week, as shoulda-context, which controversially provides nested test structures for Test::Unit saw an explicit dependency on Test::Unit so that MRI 1.9.2 doesn’t confuse it with MiniTest (d1c5881)—that’s thanks to Ryan McGeary (rmm5t)—but then Jason Morrison (jasonm) decided that enough was enough and he released version 1.0.0 of shoulda-context (9557425).

paperclip

Our file uploading gem, paperclip, saw an interesting commit from yours truly, Mike Burns (mike-burns). With a Paperclip attachment you can get the URL (e.g. @user.avatar.url(:medium)). The logic for generating this URL was specified in the Paperclip::Attachment class, which meant that to do anything interesting like delaying the thumbnail generation or storing the style names in the database involved monkey-patching, which is clearly a mistake. So I pulled that functionality out into the UrlGenerator class, but more importantly I parameterized that class name so you can pass whatever you want. For example:

class User < ActiveRecord::Base
  has_attached_file :avatar,
    :url_generator => DataBaseStyledUrlGenerator.new(ActiveRecord::Base.connection)
end
class DataBaseStyledUrlGenerator
  def initialize(db)
    @db = db
  end

  def new(attachment, attachment_options)
    @attachment = attachment
    @attachment_options = attachment_options
  end

  def for(style_name, options)
    dimensions = db.select_row("SELECT width, height FROM styles WHERE style_name = ?", style_name)
    "/assets/images/#{dimensions['width']}/#{dimensions['height']}/#{@attachment.id}.jpg"
  end
end

Refactoring to add functionality? Heck yeah! (bc5c51d)

factory_girl

A bug fix and the usual slew of refactorings for factory_girl this week. As the bug fix, Joshua Clayton (joshuaclayton) fixed implicit traits’ error output by having them know their name (0124d42). Small, but good to have.

Internally, he applied the null object pattern to act as a parent of orphan factories (aee300a). He added a DeclarationList to hold the collection of things declared about a factory, including attributes (3114dcd and f721bc6). He abstracted out the idea of a factory and a trait into the Definition class (41bc3ac). He also removed the unused @ignored_attributes instance variable (68e8e9e) and moved the logic around adding a proxy value into one place (3803be3).

Alexander Gronemann (Highcode) fixed a typo in the docs for us (5a48129). Thanks!

capybara-webkit

All changes to the capybara-webkit headless browser were documentation changes this week: Joe Sak (joemsak) mentioned :js => true for specs and that transactional fixtures still cannot be used (eb6165d). Joe Ferris (jferris) took a stance on the inconsistent authors section of the README by specifying his name and Matt Mongeau’s name, but also pointing to the list of Github contributors (8674ef7). While there he changed some grammar to his liking (7be8f94).

clearance

Another refactoring-based feature for us this week in clearance, our authentication gem. Constantine Mavromoustakos (cmavromoustakos) split the user instance methods into an InstanceMethods module, which helped them be more selective about which methods they want to pull into their MongoDB-based app (cc0d007).

fake_braintree

Mostly refactoring on the Braintree test fakes, fake_braintree, this week, but let’s see what features we can pull out of these refactorings by Gabe Berke-Williams (gabebw). He introduced a FakeBraintree::Subscription class (e4e99f8), which can you use as a fake subscription. He also introduced a FakeBraintree::Customer class, to be a fake paying customer (0259b9d and 9902e08). Maybe you needed those!

On the lighter side he cleared up the test coverage question by removing most untested code (0f6ed3f and ad7a4b9), adding a test to ensure that the next billing date is a month from now (84cfbc4), and removing an 80-line unused method (e1a886c). He responded to my ctags file observation from last week by removing it (8eb5988 and 7a9fb76). He also did a couple of other things under the name “cleanup” (5690d40, 76675cb, 2aaf85c, d7811aa, and cc7463f).

lolconomy

This week in open source

kumade

The big changes to kumade this week: the rake task automatically works, and is properly tested too; the Less::More packager is gone; and the cucumber tests are more extensive and reusable. This is all in the 0.8.0 release of kumade.

All commits this week were from Gabe Berke-Williams (gabebw). He worked on the no-op asset packager, which is the useful for when you have no assets. It is never run (ccfa677 and e2e546e) but is tested (621698e). This came from tests that he refactored (c45df04, 6600abb, 9aa6230, 810a832, 5ef704b, 4a72bc0, a3a080f, c05b398, c34d796, 8e34e56, 4bffaa3, cf370c1, 13469e2, ef026fc, 40eb3a8, caeb62a, 7ca5108, 7e4eab3); a main theme of this refactoring is moving Cucumber step definitions into re-usable Ruby methods. He also noted that Rails is a dependency for the gem, but rake is not (1808c1e). Also included in this paragraph is the cleanup of the README he did (3eb743c).

In terms of awesome, kumade has grown so large that Gabe needed to generate a ctags file, and git-ignore it (41c261b). The More packager, which uses the Less::More gem, was undertested and unused and, thus, removed (594a6d0). The rake task, which has been in odd states in the past, now works, no setup needed (8d93837 and f2ee9f4). A bug where untracked asset files were not caught has been fixed (867594d). And all of this was released as version 0.8.0 of kumade (8de6c4c)!

suspenders

Hot new things in our app-generating gem, suspenders: pass Rails generator arguments through from the command-line to the low-level generator, ActiveRecord attributes default to protected, Clearance is easier to test, the Procfile is copied for easier Heroku usage, and the gem itself is much easier to test.

Like kumade, all commits on suspenders this week were from one person: Harold Giménez (hgimenez). The Procfile is a Heroku-specific file that lets us state that we want to use thin instead of the default Web server. This is copied to the generated app now (4a5c154). Rails and cucumber were both upgraded to 3.1 and 1.1.0, respectively (44190e8, d99d7f3, and 07602fa). The database does not auto-migrate on app generation, giving you time to remove or change Clearance as needed (70887f8 and b4a74c9). The clearance/testing module is automatically required by the spec suite now (6436933). The default rake task runs specs and cucumber features (3131d45). The command-line interface was changed; instead of specifying a subcommand, you instead just say suspenders awesome-blog to create an awesome-blog project (c27af6f). Finally and most controversially, ActiveRecord objects require attribute whitelisting now with attr_accessible (fcbe87c and c3dd8ab).

Internally the lives of developers was made easier (so get your pull requests ready!). The trout gem was removed, along with all the functionality it brought and required (244b944, 2b2c6ec, 470e642, and 1969445). Aruba was added (518f4d8, bcfb05e, and f3dca30), which made is eaier to put Suspenders on bundler (064b1e6, 6f677b9, and e097c00), which also removed the REPO environment variable’s use (d7a74c2), and made the rake tasks easier (d900182). The Rails custom template was re-written to be an AppGenerator (517f0c3). Also, the word “miscellaneous” was spelled properly (ce1b191).

This all brought documentation changes, of course! The README no longer mentions the subcommands (1eec3cc) or trout (385dd5b), nor does it mention the REPO environment variable (01e76e5). It does, however, discuss the OS-level dependencies (713e714).

With all that done, Harold released version 0.3.1 of Suspenders (68f4a1c and a0225bd).

high_voltage

All documentation updates this week for high_voltage, our static page gem. Matt Jankowski (mjankowski) mentioned that static pages go under app/views/pages, at least by default (bfb6b4a). Jaime Iniesta (jaimeiniesta) mentioned how custom routes and custom controllers need to work (1450b15).

paperclip

We saw one bug fix, some refactoring, and documentation updates on the paperclip file uploader gem. Prem Sichanugrist (sikachu) fixed the validates_attachment_presence validator to handle an :if and :unless as a symbol instead of a Proc (2583a27).

Prem also moved the storage tests into the test/storage directory (41f685f), which caused Mike Burns (mike-burns) to fix the tests (af689b4). Prem changed some words in the features (9fb5b74) and re-aligned some code (42d4199).

Gabe Berke-Williams (gabebw), who loves changing documentation, documented the geometry formats finally (093a14a) and fixed the Markdown formatting (227d6a4).

factory_girl

Also an internal improvement week for our factory_girl fixture replacment. Gabe Berke-Williams (gabebw) fixed the formatting in the contribution guidelines (cddfa92). GunioRobot (GunioRobot) cleaned up some excess whitespace for us (f41299e). Joshua Clayton (joshuaclayton) tested that the block passed to the factory runner is indeed called (93026a8, 73b9e41, and 4ede9f1).

dotfiles

Hot new stuff if you’re a git, vim, or shell enthusiast! Our dotfiles have new shell aliases for running a bundled rake and deploying to staging and production (9495c56), a new git log format and default push state (fdc8afc), and coffeescript support for vim (318b620 and 1a8d7cf). All of this is thanks to Dan Croak (croaky).

fake_braintree

The Braintree test fake, fake_braintree, can now handle varies types of credit card verification (6bd119e) and missing subscriptions (9b812ed). Note that in the missing subscriptions commit Gabe Berke-Williams (gabebw) committed his generated ctags file.

Along with those features come code re-alignment (43099c4) and more helper methods (0e6f4f5) plus some README updates in the form of formatting (313d8fd), code escaping (1d667c6), and a quick-start tutorial (62feac8).

With those few things done Gabe released version 0.0.4 of fake_braintree (54130ae and e54e98d).

lolconomy

This Week in Open Source

bourbon

Our set of sass mixins, bourbon, saw a quick fix from Travis Haynes (travishaynes), who moved the HTML5 input types into the addons directory (2c7c527). Phil LaPier (plapier) cleaned the input types mixin, removing seven needless lines and then released version 0.1.9 of bourbon (c7027db).

factory_girl

We have this test fixture gem named factory_girl. You might have heard of it. Joshua Clayton (joshuaclayton) sure has; he started with some nice refactoring to change from @options to individually-defined instance variables, removing the need for complex trait assignment (3749056 and c38bac9); he followed the principle of least surprise, allowing users to define parent factories after the children (e28bdb8 and da3af82). Whoa, indeed.

capybara-webkit

The headless JavaScript integration test driver, capybara-webkit, saw more features and improvements. Niklas Baumstark (niklasb) gave us a more diff-friendly list of C++ headers (dc5130c) as a set up for cookie support (fb119f6).

Nicolas Sanguinetti (foca) sent a non-backward-compatible pull request, renaming the capybara-webkit require to capybara/webkit, which some people who write weekly blog posts disagree with (eeeddbd). To top it off, Matthew Mongeau (halogenandtoast) fixed a bug with URLs with anchors (f75bc3d) and worked around a nuance of the Ruby parser (89bee3c).

Also, right now, the capybara lead and capybara-webkit lead are pairing. The magic of RubyConf.

paperclip

paperclip may be the finest file uploading gem for Rails. Jon Yurek (jyurek) did some internal cleanups, extracting the options hash into its own object (3e6d933 and b948f96). Joost Baaij (tilsammans) added determinism to the rake task that refreshes thumbnails, ordering by the database ID, with the idea that a crashed refresh could be restarted more easily. Perhaps this is a bandage instead of a fix (0df5a96). Pavel Forkert (fxposter) continued with previous work on fixing a memory leak, passing strings instead of objects (7243015 and 7a2e2ed).