I wrote a Rails plugin which uses simian to look for duplicates lines in
your
code and reports in html format, Textmate or Netbeans.
I wrote it using RSpec and I have included a RSpec custom matcher:
it { rails_application.
with_threshold_of_duplicate_lines(4).
should be_DRY }
If you use Autotest, your specs will fail the next time you do a nasty
copy-paste !!!
More details in 21 croissants' Blog: DRY
Feedback and patches (with specs!) welcome
Jean-Michel
View this message in context:
http://www.nabble.com/Sharing%3A-dont_repeat_yourself-plugin-custom-RSpec-matcher-tp16965619p16965619.html
Sent from the rspec-users mailing list archive at Nabble.com.
On 29 Apr 2008, at 18:25, 21croissants wrote:
copy-paste !!!
More details in 21 croissants' Blog: DRY
Feedback and patches (with specs!) welcome
Sounds good! Any reason why you wrote it as a Rails plugin though?
This could be used for any ruby project⌠except mine of course, I
never copy and paste, honest :o)
Ashley
â
http://www.patchspace.co.uk/
On 1 May 2008, at 16:00, 21croissants wrote:
Youâre right and one of my next action will be to create a gem so it
can be
use in any ruby project, I will keep the Rails plugin of course.
Cool, be sure to post here when youâve gemified it
It will generate the report (HTML, Textmate) in a file called
DRY_report.html at the root folder of your rails app.
I reckon this is not very handy - you need to create a Rails project
and
install the plugin - but it will soon improve!
As a spoilt Rails developer I demand that everything written in Ruby
works magically whatever I am doing :o)
This reminds me a bit of a time when I created a Rails project just to
use AR migrations. I think Iâll wait for now until there is a gem
version.
Just out of curiosity, have you run your DRY reporter against the
Rails code itself? Might be interesting to see the resultsâŚ
Ashley
â
http://www.patchspace.co.uk/
Ashley, I ran the DRY reporter on Rails 2.0.2 and youâll find the
results on
http://www.21croissants.com/files/rails_2_0_2_DRY_report.html
I have done a lot of refactoring lately (but did not changed the
external
API) and will commit my code soon âŚ
Ashley M.-4 wrote:
Just out of curiosity, have you run your DRY reporter against the
Rails code itself? Might be interesting to see the resultsâŚ
Ashley
â
View this message in context:
http://www.nabble.com/Sharing%3A-dont_repeat_yourself-plugin%2C-will-report-duplicate-lines-in-your-code!-tp16965619p17323753.html
Sent from the rspec-users mailing list archive at Nabble.com.
thanks for your feedback Ashley.
Youâre right and one of my next action will be to create a gem so it can
be
use in any ruby project, I will keep the Rails plugin of course.
At the moment, you can write :
require ⌠specific your location ⌠+
â/lib/dont_repeat_yourself/reporterâ
dry_reporter = DontRepeatYourself::Reporter.new
dry_reporter.configure_simian_for_ruby_project(â/home/jeanmichel/ruby/projects/dry-report/rails_plugin/vendor/plugins/dont_repeat_yourselfâ)
dry_reporter.html_rails_report
It will generate the report (HTML, Textmate) in a file called
DRY_report.html at the root folder of your rails app.
I reckon this is not very handy - you need to create a Rails project and
install the plugin - but it will soon improve!
JM
Ashley M.-4 wrote:
Sounds good! Any reason why you wrote it as a Rails plugin though?
This could be used for any ruby project⌠except mine of course, I
never copy and paste, honest :o)
Ashley
â
View this message in context:
http://www.nabble.com/Sharing%3A-dont_repeat_yourself-plugin%2C-will-report-duplicate-lines-in-your-code!-tp16965619p16993286.html
Sent from the rspec-users mailing list archive at Nabble.com.
On 19 May 2008, at 18:21, 21croissants wrote:
Ashley, I ran the DRY reporter on Rails 2.0.2 and youâll find the
results on
http://www.21croissants.com/files/rails_2_0_2_DRY_report.html
Wow, thatâs really interesting. Some things are trivial mini-methods,
eg âdef to_param; to_s; endâ. But there are some huge chunks of
complex logic in there!
I wonder how so much duplication got in there, and if some of it is
justified?
I have done a lot of refactoring lately (but did not changed the
external
API) and will commit my code soon âŚ
Cool. Is it still a Rails plugin or can you run it on standalone
code? Itâd make a great gem with a binary.
Be sure to post when you commit!
Ashley
â
http://www.patchspace.co.uk/