Update Ruby syntax on a Rails project (1.9.3 to 2.0.0)
To change all :foo => bar
to foo: bar
, just run:
$ find . -name \*.rb -exec perl -p -i -e 's/([^:]):(\w+)\s*=>/\1\2:/g' {} \;
UPDATE
@nicolaslazartekaqui warned me that the last command does not apply to the case {:foo? => bar}
and suggested a little change to fix it, here it is:
$ find . -name \*.rb -exec perl -p -i -e 's/([^:]):(\w+?*)\s*=>/\1\2:/g' {} \;
Thanks, @nicolaslazartekaqui.
Written by Rômulo Machado
Related protips
3 Responses
not apply in this case {:foo? => bar}
little change in command to fix this
$ find . -name \*.rb -exec perl -p -i -e 's/([^:]):(\w+?*)\s*=>/\1\2:/g' {} \;
over 1 year ago
·
Thanks for the correction, @nicolaslazartekaqui. I'll update it.
over 1 year ago
·
For Sublime Text users, I like this utility: https://github.com/iltempo/sublime-text-2-hash-syntax
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#