Skip to content

Instantly share code, notes, and snippets.

@jch
Created December 4, 2012 03:17
Show Gist options
  • Save jch/4200223 to your computer and use it in GitHub Desktop.
Save jch/4200223 to your computer and use it in GitHub Desktop.
Namespace ruby files with a module
#!/bin/sh
# Usage:
#
# find app -name *.rb | xargs -L1 ./namespace.sh
#
sed -i.bak -e '
/^class/ {
# prepend namespace
i\
module Help
}
/^class/,$ {
# prefix 2 spaces if there something in line
s/^./ &/
}
$ {
a\
end
}
' $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment