Skip to content

Instantly share code, notes, and snippets.

@nagi
Last active August 29, 2015 14:02
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 nagi/f1d536dbc08beec4a6b4 to your computer and use it in GitHub Desktop.
Save nagi/f1d536dbc08beec4a6b4 to your computer and use it in GitHub Desktop.

#Recipe to Clean Up Ugly Ruby

Remove cruft matching regex

ack -l "######" | xargs ruby -i.bak -ne 'print if not /######/'
# check with git diff
find . | grep '\.bak$' | xargs rm
gem install ruby-beautify
rbenv rehash

Script to beautify file inplace

#!/bin/bash

rbeautify $1 > tmp
cat tmp > $1

...now beautify

find . -type f | grep '\.rb$' | xargs -L 1 ./little_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment