Making all my Ruby files pretty

K

Kyrre Nygård

Hello!

I'm trying to make a simple Ruby code beautifier to set me at ease. I
know there's already rbeautify:

http://www.arachnoid.com/ruby/rbeautify.rb.html

But I need to do some more:

Like making,

# comments like these

Into,

#
# Comments like these.
#

E.g. making sure the first letter after "^# " (if any) is always
uppercase and that every comment line ends with a dot.

As well as,

# comments like these.
# bla bla.
# bla blaaa.

Into,

#
# Comments like these. Bla bla. Bla blaaa.
#

Every comment is always joined into one line.

I'm not sure exactly what approach to take. Whether to build on
rbeautify or not. I also need the functionality from my old shell script:

#!/usr/bin/env zsh

for file in $PWD/**/*(.); do

# Check if file is text.
#
if file -b $file | grep -q 'text'; then

# Remove CRLF, blank lines and trailing white space.
#
# In FreeBSD use: sed -e
#
tr -d '\r' < $file | sed -E -e 'v/\S/d' -e 's/[[:space:]]+$//' >
$file.tmp

mv -f $file.tmp $file

echo "$file"

fi

done

Would love to hear what you guys think.

All the best,
Kyrre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top