dn83gg
Last Updated: February 25, 2016
·
650
· EnriqueVidal

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.

2 Responses
Add your response

5487

Or in Ruby:

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

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 ·