Flay analyzes ruby code for structural similarities. Differences in literal values, names, whitespace, and programming style are all ignored.
Code that flay reports as similar is a good candidate for refactoring.
Try this:
% sudo gem install flay
% flay lib/*.rb
and see what you find.