21croissants
2008-Apr-29 17:25 UTC
[rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher
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 http://21croissants.blogspot.com/2008/03/dry.html 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.
Ashley Moran
2008-Apr-29 19:36 UTC
[rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher
On 29 Apr 2008, at 18:25, 21croissants wrote:> 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 http://21croissants.blogspot.com/2008/03/dry.html > > 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/ http://aviewfromafar.net/
21croissants
2008-May-01 15:00 UTC
[rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher
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 Moran-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%21-tp16965619p16993286.html Sent from the rspec-users mailing list archive at Nabble.com.
Ashley Moran
2008-May-01 16:07 UTC
[rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher
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 :)> 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!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/ http://aviewfromafar.net/
21croissants
2008-May-19 17:21 UTC
[rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher
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 Moran-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%21-tp16965619p17323753.html Sent from the rspec-users mailing list archive at Nabble.com.
Ashley Moran
2008-May-19 19:50 UTC
[rspec-users] Sharing: dont_repeat_yourself plugin custom RSpec matcher
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.htmlWow, 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/ http://aviewfromafar.net/
Apparently Analagous Threads
- sharing my netvibes tab about rspec
- Where to place uploaded files for later download?
- Rails 1.2.0 RC2 has 4125 duplicate lines
- RSpec 1.1.3 + ZenTest 3.9.1 + Rails 1.2.6 do NOT ignore folders ^vendor/*
- Solution for undefined method `use_transactional_fixtures=' ... problem