dn83gg
Last Updated: February 25, 2016
·
625
· EnriqueVidal
8b3482cd83cd8170d9bbbb711062dcc3

Switch a ruby project to the 1.9 hash sytax

To change a whole project to the new hash syntax just do the following inside your project's folder:

OSX and BSD

find . -iname *.rb -exec perl -pi -e 's/:([\w\d_]+)(\s*)=>/\1:/g' {} \;

GNU/Linux

find . -iname "*.rb" -exec perl -pi -e 's/:([\w\d_]+)(\s*)=>/\1:/g' {} \;

This should do the trick.

Say Thanks
Respond

2 Responses
Add your response

5487
Arnaudm 2008

Or in Ruby:

find . -name '*.rb' -exec ruby -pi -e 'gsub(/:([\w\d_]+)\s*=>/,'"'"'\1:'"'"')' {} \;
over 1 year ago ·
18815
Cc1482b6867895fb0cc52063dc2b60e9

Why not just use Rubocop to do it for you?
It will help you fix other issues with your code as well... ;-)

over 1 year ago ·