Last active
March 9, 2017 15:30
-
-
Save J3RN/c2cf6afe612c39dcc6a4d149fc9e13db to your computer and use it in GitHub Desktop.
old2new, the Ruby hash syntax updater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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