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.
Written by Enrique Vidal
Related protips
2 Responses
Or in Ruby:
find . -name '*.rb' -exec ruby -pi -e 'gsub(/:([\w\d_]+)\s*=>/,'"'"'\1:'"'"')' {} \;
over 1 year ago
·
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#