Skip to content

Instantly share code, notes, and snippets.

@J3RN
Last active March 9, 2017 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save J3RN/c2cf6afe612c39dcc6a4d149fc9e13db to your computer and use it in GitHub Desktop.
Save J3RN/c2cf6afe612c39dcc6a4d149fc9e13db to your computer and use it in GitHub Desktop.
old2new, the Ruby hash syntax updater
# This script has been tested with zsh 5.2 on macOS 10.12.3 with BSD sed and find.
# It may work under other conditions, but likely does not.
# old2new, the Ruby hash syntax updating function
# Takes the given files and replaces all instances of `:key => value` with the equivalent `key: value`
# Usage: old2new <path>
# NOTE: <path> can be a file or directory
function old2new() {
find $argv \( -name "*.haml" -or -name "*.rb" -or -name "*.erb" \) -exec sed -E -i '' 's/:([A-z]+) =>/\1:/g' '{}' \;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment