Convert Ruby 1.8 to 1.9 Hash Syntax

In vim, for an entire file:

:%s/:\([^ ]*\)\(\s*\)=>/\1:/g

In the shell, for an entire project:

perl -pi -e 's/:([\w\d_]+)(\s*)=>/\1:/g' **/*.rb

Now, instead of those old-school hashes like this:

get '/', :agent => MOBILE_BROWSERS do

You’ll have new-school hashes like this:

get '/', agent: MOBILE_BROWSERS do

Pair with one of our expert developers to level up your skills with Coaching by thoughtbot. Save time learning best practices and techniques for reducing technical debt in Ember, Ruby, Haskell, and Go in 1-on-1 sessions tailored to your goals.