Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A simple indent formatter for ruby
branch: master

This branch is 3 commits behind sbeckeriv:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
patchs
CHANGELOG
README
formatter.rb
simple_formatter.rb
test_file.rb

README

 == Synopsis

 Simple Ruby Formatter

 Created by: Stephen Becker IV
 Contributions: Andrew Nutter-Upham
 Contact: sbeckeriv@gmail.com
 SVN: http://svn.stephenbeckeriv.com/code/ruby_formatter/

 Its been done before RadRails did,
 http://vim.sourceforge.net/tips/tip.php?tip_id = 1368 that guy did it, but I did
 not look for a ruby formatter until i was done.

 It is called simple formatting because it is. I have the concept of 3 differnt
 indent actions In, Out and Both. I have mixed the concept of indenting and
 outdenting. Out means you have added white space and in means you remove a layer
 of white space.

 Basic logic
 Decrease current depth if
 ((the it is not a one line if unless statment
 (need to lookfor more oneline blocks) and it ends with end
 or if the } count is larger then {)
 or
 the first word is in the both list)

 and
 depth is larger then zero

 Increase current depth if
 It is not a one liner
 and
 (the word is in the out list
 or
 the word is in the both list
 or
 it looks like a start block)
 and
 temp_depth is nil (used for = comment blocks)


 Sure there are some regx's and a crap load of gsubs, but it still simple. Its
 not like its a pychecker (http://www.metaslash.com/brochure/ipc10.html)

 == Usage

 ruby [options] filelist

 options:
 -s # will change the indent to a space count of # per level
 by default we space with 1 tab per level
 -b # create a backup file

 examples:
 ruby simple_formatter.rb -s 3 -b /moo/cluck/cow.rb
 runs with the indent of 3 spaces,creates a backup file, and formats moo/cluck/cow.rb


 Tested with random files off of koders.com
Something went wrong with that request. Please try again.