10 November 2008

dont_repeat_youself ruby gem

Matt wynne sent me a link from rubyinside about three tools to for DRYing Your Ruby Code. It also seems that the number of tools available for ruby to analyze the code quality and detect code smells is improving, that's a very good new!

It seems a good timing to officially announce my first gem: dont_repeat_youself
My idea was to take Simon Harris ' Simian and to add a few features:

  • generate reports (HTML, Textmate, Netbeans) of duplicate lines in your code:


  • integrates nicely withandand it opens the guilty class directly in your favourite IDE. This should save a bit of time!


  • integrates with unit testing frameworks:



# RSpec
it { rails_application.
with_threshold_of_duplicate_lines(4).
should be_DRY }

# Test::Unit
assert_DRY(ruby_code_in_rails_plugin("dont_repeat_yourself"))

Combine it with autotest & Continuous Integration and your tests / builds will fail if the code contains too many duplicate lines.

To start playing:
Your FeedBACK is more than welcome! Post a comment in this blog or contact me

If you want to contribute, please use the git repository:
http://github.com/garnierjm/dry-report/

Cool DRY logo by CodeSmack (Please send me the t-shirt guys!)


Based on Simian (Similarity Analyser) by Simon Harris from RedHill Consulting, see http://www.redhillconsulting.com.au/products/simian/
Copyright (c) 2003-08 RedHill Consulting Pty. Ltd. All rights reserved.

No comments: