giant robots smashing into other giant robots

Written by thoughtbot

sikachu

Paperclip is Going Three-Point-Oh Nelly

The new version of your favorite file upload library, Paperclip 3.0.0, has been released earlier today. We changed a lot of internals to make Paperclip better. These changes lay the groundwork for the shiny, new features that will come in the future.

Goodbye, Rails 2.3.x and Ruby 1.8.7

Ruby 1.8.7 and Ruby on Rails 2.3.x are both reaching end of life now, so this is a good time to drop support for them. This let us remove some code and introduce a new validator syntax (below.)

If you’re still using Ruby on Rails 2.3.x or Ruby 1.8.7, you should lock Paperclip to version 2.x by doing this:

gem "paperclip", "~> 2.7"

In some rare case that there’s a critical bug in Paperclip 2.7.x, we’ll release a patch version under that minor version. However, you’re advised to upgrade to a newer version of Ruby and Rails as soon as you can.

Modularized Internals

We’re working to extract functionality into modules. We’re not done with this yet, and it is an ongoing process. If you’ve freedom patched Paperclip, you’ll need to look out for this as some of the methods might have new names or locations.

If you are developing a plugin for Paperclip—e.g. custom storage, a processor, or a validator—we would love to hear from you. We want to expose hooks to help you develop your plugin and reduce the risk of breaking things in the future.

Default attachment path has been changed

When you’re installing the new version of Paperclip, you’ll be greeted with this upgrading message:

##################################################
#  NOTE FOR UPGRADING FROM PRE-3.0 VERSION       #
##################################################

Paperclip 3.0 introduces a non-backward compatible change in your attachment
path. This will help to prevent attachment name clashes when you have
multiple attachments with the same name. If you didn't alter your
attachment's path and are using Paperclip's default, you'll have to add
`:path` and `:url` to your `has_attached_file` definition. For example:

    has_attached_file :avatar,
      :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
      :url => "/system/:attachment/:id/:style/:filename"

Going forward, the default URL for your attachment will be /system/:class/:attachment/:id_partition/:style/:filename. This will prevent filename collisions and will reduce the number of files in a single directory.

Rails 3 Validators

All of the validators have been rewritten to take the full advantage of Rails 3. They’re now in their own Validator class, and can be passed into validates or validates_with like any other Active Model validator:

validates :avatar, :attachment_presence => true
validates_with AttachmentPresenceValidator, :attributes => :avatar

We are also introducing a validates_attachment method. This method is almost the same as the validates method except you can skip the :attachment_ prefix. We’ve found this helpful when defining multiple validators on a single attachment:

validates_attachment :avatar, :presence => true,
  :content_type => { :content_type => "image/jpg" },
  :size => { :in => 0..10.kilobytes }

Going forward

I would like to thank our contributors and all of the other users who are helping to make Paperclip better and better. Please give this new version a try. If you find a bug, please file an issue, or better, you can also help us fixing it.

We’re thrilled to introduce the new Paperclip, and we hope that you’ll like them.

lolconomy

This week in open source

bourbon

So this bourbon gem…people seem to like it: there was a RailsCast about it and the principle author (Phil LaPier) will be speaking at Frontend United about it.

This week people cleaned up the obsolete CSS attributes: Thibaut (Thibaut) removed -moz-inline-block (d73ea46), Chad Mazzola removed both -ms-border-radius and -o-border-radius (10a5908), and Phil LaPier (plapier) removed -moz-box-orient (6331e26). Gabe Berke-Williams (gabebw) fixed support for Rails 2 (eacd5ee and e9347e7) and, lesson learned, removed Gemfile.lock (671ad33).

factory_girl

Version 2.6.3 of factory_girl is out, all y’all. In this action-packed version we got a cucumber step named e.g. Given the following post exists (note the lack of : at the end), via cj (cj) (d4b8cac and 48afe24). Barun Singh (barunio) fixed a bug where the factory’s traits weren’t compiled in the very first time the factory was used (68ca50f), plus a factory can use all the traits on any ancestor (f14a8cf). Joshua Clayton (joshuaclayton) is now listed as an author (07d2834), so congrats to him and his hard work. As part of that hard work he discovered that the vintage syntax broke in MRI 1.9.2-p318, and then fixed it (a7acc3e).

This just in! Version 3.0.0.rc1 is now public! It breaks everything, again! Please try it and open issues with what breaks:

gem 'factory_girl', '3.0.0.rc1'

bourne

Oh hey version 1.1.1 of bourne is out (650afb0)! Bourne is an extension to mocha that adds test spies so your tests can read like normal tests. Tristan Dunn (tristandunn) added support for mocha 0.10.5 (286d8f9) and fixed a long-standing error message that occurs when you forget to stub a method before spying on it (17dc7d2).

Gabe Berke-Williams (gabebw), who pushed the release, also did some maintainance: adding Travis CI notifications to the README (7d6eb37), removing Gemfile.lock (950a445), and some general code cleanups (4bbe610 and b0f1f99).

shoulda-matchers

The big deal in shoulda-matchers over the past week was when Fujimura Daisuke (fujimura) added the ability to specify the key for the flash message in the set_the_flash matcher (0e0339e, ef866e2, and fd4aa53):

it { should set_the_flash[:alert].to("Password doesn't match") }

Gabe Berke-Williams (gabebw) did his usual maintainance of converting the docs to use Markdown (85c37c4), cleaning up the ModelBuilder that’s used in the tests (31595b0), and showing off how often our build is broken in the README using Travis CI (eebb806), which he also did to shoulda proper (7d805d0).

cocaine

Also victim to the Travis CI treatment was cocaine, via Gabe Berke-Williams (gabebw) again (ac47b6f and 490c406).

paperclip

The paperclip project is gearing up for a groundbreaking (maybe app-breaking?) release, but in the meantime Mike Boone (boone) fixed an infinitely-growing PATH environment variable (06d69af) while Mike Burns (mike-burns)—also known as: me—totally broke backward compatibility by changing the default :path and :url configuration setting (26f4d40). These new settings avoid overwriting files on different models and also scales to more than 1024 instances of the same model.

capybara-webkit

In capybara-webkit news, Joe Ferris (jferris) controversially allowed the user to interact with invisible elements (02f2a8a), and caught the fact that Capybara.timeout is deprecated (4d954b7).

lolconomy

This week in open source

cocaine

The only user-visible change in cocaine this week was by Gabe Berke-Williams (gabebw), who modified the public API for CommandLine to change unix? from a class method to an instance method (4183c89). Otherwise it was more of Gabe refactoring things (ae8ae22 and 1b9742a) and Prem Sichanugrist (sikachu) playing with Travis CI (4eb18d2).

diesel

This week diesel, an abstraction and set of helpers for Rails engines, got a bug fix from Gabe Berke-Williams (gabebw); Gabe fixed an issue where setting the BUNDLE_GEMFILE environment variable could sometimes cause it to be duplicated (933d545). Along the way he and Prem Sichanugrist (sikachu) played with Travis CI, Rails 3.2, and other dependencies (1d19331, 7496d91, 39c84e2, 821e1cd, bb4e627).

paperclip

Version 2.6.0 of paperclip is out! It has a bug fix: files have rewind called on them after being called, thanks to Kelley Reynolds (3b2b9bc). Justin Ko (justinko) made sure a non-Rails test suite can use Paperclip (67d5c0b and b0cb54e).

Internally, has_attached_file options are turned into an AttachmentOptions hash-like object (7f948f8, 9eda1bb, and 1f989ae), via Luke Griffiths (Sporky023). The afore mentioned Kelley Reynolds found a way to simplify the Filesystem#flush_writes code using FileUtils.cp (f8c2444). Prem Sichanugrist (sikachu) played with Travis CI (772c8e9) and Mike Burns (mike-burns) released version 2.6.0 (71d3f46).

factory_girl

Hear ye, hear ye, factory_girl 2.5.1 is out (13c58d2). With it Simone Carletti (weppos) gave us all the ability to pass traits to built_list and create_list (13129b0 and 6482a64); Erik Ostrom (eostrom) fixed the Cucumber step to use inherited associations (34c1bf9, 6cddb37, and 852eea8); Joshua Clayton (joshuaclayton) fixed #279 and #285 with some black magic around re-defining and undefining methods (f50550c).

Elsewhere, Gabe Berke-Williams (gabebw) found a way to re-write the entire gemspec (6e7e4ee) and also found six extra characters in a file (b63e389). Joshua Clayton (joshuaclayton) moved some exception classes around (98626c9) and set a minimum on the activesupport package (c103ca1).

capybara-webkit

As promised last week, version 0.9.0 of capybara-webkit is released! Thanks go to Matthew Mongeau (halogenandtoast) for this (bea4cbe and a6fde0e).

fake_braintree

Gabe Berke-Williams (gabebw) found a way to re-write the README for fake_braintree this week (7d10953).

lolconomy

This week in open source

bourbon

As a programmer I love the change that made it into version 1.3.6 (10f978d) of bourbon: Phil LaPier (plapier) added to work done by Frank (frankzilla) to add a monospaced font family, $monospace—with support for Bitstream Vera Sans Mono, my favorite monospace typeface (3467fe3 and c86e5687). Nice.

paperclip

Friday saw a new release of paperclip (1cb40e3), in accordance with the prophecy. It contains Windows support, a bug fix, and two new features.

Prem Sichanugrist (sikachu) has been working on handling characters that are not URL-safe; to this end he added a :restricted_characters option to has_attached_file, with a default value of &$+,\/:;=?@<>\[\]\{\}\|\\\^~%# , which specifies characters to replace with an underscore, _ (8353518 and 604304e). Benjamin Hüttinger (maxigs) added the ability to pass a block, evaluated at runtime, for :fog_host, :bucket_name, and :fog_credential options (e049ec5, 2b562a9, 8742615, and 1c88a72).

The gem itself had problems installing on Windows because a bundled test made sure that filenames with question marks were handled fine; turns out this simply breaks on Windows. Even though no actual programmers use Windows, we removed the offending file (ed5cd9f). Jon Yurek (jyurek) fixed a long-standing bug where the RSpec matchers (validate_attachment_content_type, validate_attachment_presence, and validate_attachment_size) didn’t handle the :if argument they were supposed to handle (5d4ba62).

capybara-webkit

A new release of capybara-webkit is in the works, and this is what you’ll see in it: Matthew Mongeau (halogenandtoast) added the ability to trigger mousedown and mouseup events (51c4dfe and 16c1637) while Joe Ferris (jferris) has commands block until the page finishes loading (18607d0).

clearance

Oh sweet, a new version of clearance is out (6c0c070)! In it you’ll find support for Rails 3.2 from Gabe Berke-Williams (gabebw), mostly in following deprecation warnings (6e57d10). Some prodding from Matthew Daubert (MDaubs) prompted us to upgrade cucumber-rails to 1.1.1 (691e867 and 91f4675). Dan Hodge (danhodge) dropped a totally awesome change on us, abstracting out the User class into Clearance.configuration.user_model, which can be changed at runtime (085a9b6, a582eec, and fc6af70). Dude, that’s awesome.

fake_braintree

Holy cow it’s version 0.2.0 of fake_braintree (0be2aea). In this Gabe Berke-Williams (gabebw) gave us the ability to specify a constant amount for a transaction (783719c), and mimics the behavior around customers with failing credit cards (a2ceb58).

factory_girl

No big news in factory_girl this week. Carlos Antonio da Silva (carlosantoniodasilva) updated the docs to mention that .stub is now .build_stubbed (08018f6). Michael Klishin (michaelklishin) fixed the build on Travis CI for Rails 3.2 by updating rubygems first (850116d). Joshua Clayton (joshuaclayton) found a spec that was not appropriately named, and fixed it (0d67a42).

kumade

While kumade did not see a deploy this week, it did see some feature improvements, some of which come with an API change.

The hook for running code just before deployment was originally run_predeploy_task but is now run_pre_deploy_task (764aebe). Chad Boyd (hoverlover) made this change so he could introduce the run_post_deploy_task, which is further exposed as kumade:post_deploy to Rake (da74087, f68a487, and 9679018).

Kumade now works with more stuff: Jammit 0.6.5 (ec63310) thanks to Vesa Vänskä (vesan), and Ruby 1.9.3 (8e73b90) thanks to Gabe Berke-Williams (gabebw).

Gabe also fiddled with some source code (7e0e11e, bb695b9 and 92aa8f4).

copycopter_client

A small documentation update occured in copycopter_client by Joe Ferris (jferris), reminding us that you can leave the name of the controller or model off of the translation key only when using t from a view (6416897).

lolconomy

This week in open source

bourbon

Over the past week bourbon went up to version 1.3.5. A whole bunch of sweet new features are in it now:

Frank (frankzilla) added a modular-scale mixin, of which the golden-ratio mixin is but one implementation (126a83b and 96659a2). He also added a parameterized fallback color to linear-gradient (60e2c63).

Phil LaPier (plapier) worked with Gabe Berke-Williams (gabebw) on a bourbon command-line too for working with Sass outside of a Rails app, such as Jekyll, WordPress, or even a static site (ad1499b, b55a763, 0ebf906, c2077d8, 13e70d3, 2fc2c90, and bf34e70). You can run bourbon install to install it and bourbon update to update an existing installation.

capybara-webkit

A careful sleuth has updated the documentation for capybara-webkit this week. Marc Schwieterman (marcisme) discovered that a fully passing test suite depends on ImageMagick, and documented as much in the contributions guide (df39268).

factory_girl

Version 2.5.0 of factory_girl is out, and there’s a badass new feature in it. But first:

Joshua Clayton (joshuaclayton) fixed a bug where the :parent’s factory wasn’t being passed along (4aecfff). Carlos Antonio da Silva (carlosantoniodasilva) fixed the URLs in the readme to point to correct locations (aa74edd and 42f5a10).

Oh, and you may remember from last week that Josh deprecated the attributes_for method admist much controversy. Well, he undid that (2d6adfd).

Josh then implemented a feature that Joe Ferris (jferris), FactoryGirl’s originator, has wanted for years: you can specify how FactoryGirl should construct the class (5780364). Joe excitedly documented this (ea89aad). This means that FactoryGirl can be used for non-ActiveRecord classes, including immutable classes.

paperclip

In accordance to our new gem schedule, paperclip hit 2.5.1 this week. Mike Burns (mike-burns) cut the release, adding a ChangeLog and updating the NEWS file (b7f9b6f and ec4793e). In short: Fog storage is passed the content type, S3 can be encrypted, and ActiveRecord is optional.