After complaining to our developers about using the old, <1.8’s
=> syntax in hashes, I was challenged by my ninja colleague Avi Tzurel to create a script that will convert all the old Ruby hash syntax to the new 1.9, beautiful colon notation.
I came up with this:
1 2 3 4 5 6 7 8
The crazy negative lookbehinds ensures that nothing like
1 2 3 4 5
1 2 3
will get replaced. Turns out that after
return you can only use the old syntax, or have curly brackets. Also, unfortunately, negative lookbehinds can’t contain Regexp inside them. So the multiple negative lookbehinds are like a big ‘or’.
Our really big project, with hundreds of .rb files, Gogobot, converted and is working great. Still afraid to do the final
git push though ;)