Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 20 lines (14 sloc) 463 Bytes
#!/usr/bin/env ruby
#
# Beautifies the Ruby code given on STDIN and prints it to STDOUT.
#
# Written in 2010 by Suraj N. Kurapati <https://github.com/sunaku>
print ARGF.read.
# put space after comma
gsub(/(\S,)[ \t]*(\S)/, '\1 \2').
# put space after single colon
gsub(/(\w+:)[ \t]*([^:])/, '\1 \2').
# put spaces around operators
gsub(/(\S)[ \t]*([!<>=*&\|^%\/~+-]*=>?)[ \t]*(\S)/, '\1 \2 \3').
# strip excess whitespace at end of lines
gsub(/[ \t]+$/, '')