The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Organise your code comments with rake notes:todo!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
Organise your code comments with rake notes:todo! Posted: Nov 24, 2009 12:17 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jan Lelis.
Original Post: Organise your code comments with rake notes:todo!
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;). So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

Advertisement

Lots of IDEs (e.g. Netbeans) and some editors (e.g. gedit with plugins) have a nice feature: They show comments, which start with something like TODO or FIXME. Those annotations are quickly written and they make it harder to forget some things you wanted to (or have to) do.

I have just discovered that Rails has this feature already built-in!

rake notes

Just browse to your rails directory and type one of the following rake tasks:

rake notes:todo rake notes:fixme rake notes:optimize

It will show a nice comprehensive list of the files and lines, which have TODO, FIXME, or OPTIMIZE annotations. Note, that they are case sensitive and have to be written at the beginning of a comment. The shortcut rake notes combines the three of them.
You can also use your own words, but the resulting syntax is not so cool anymore…:

rake notes:custom ANNOTATION=COOL

Do not forget, that your own annotations are also case sensitive.

Search for thoughts

You can abuse the last command, to search through your whole rails project comments. This is possible, because the pattern is inserted as a part of this regexp: /#\s*(find_me):?\s*(.*)$/. So it is possible to run

rake notes:custom ANNOTATION=.*find_me

It works, but probably, the output after the line number is not that speaking anymore… But you can work around that by adding brackets:

rake notes:custom ANNOTATION=\(.*find_me.*\)

You have to escape some of the characters you pass (e.g. the brackets). One last hint: to use spaces in the search pattern, you can do something like this: find\\sme

I also noticed a little (but unimportant) bug.. because of the easy regexp, which is used for getting the only the comments, it sometimes gets false positives, when # is used for string interpolation.

CC-BY (DE)

Read: Organise your code comments with rake notes:todo!

Topic: Ext.ux.Exporter – export any Grid to Excel or CSV Previous Topic   Next Topic Topic: Declarative Tests

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use