Skip to content

Instantly share code, notes, and snippets.

@hanshasselberg
Created January 19, 2012 10:45
Show Gist options
  • Save hanshasselberg/1639370 to your computer and use it in GitHub Desktop.
Save hanshasselberg/1639370 to your computer and use it in GitHub Desktop.
Convert ruby 1.8 hash syntax to 1.9 with shell commands.

Convert to new ruby 1.9 Hashsyntax:

Convert :symbol => value to label: value:

find lib spec -type f -exec sed -i '' -E 's/:([_a-z]+)(\ *)=>/\1:/g' {} \;

Convert "string" => value to label: value:

find lib spec -type f -exec sed -i '' -E 's/"([_a-z]+)"(\ *)=>/\1:/g' {} \;

Convert 'string' => value to label: value:

find lib spec -type f -exec sed -i '' -E "s/'([_a-z]+)'(\ *)=>/\1:/g" {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment