Redefine rake routes to add your own custom tag in Rails

by Deepak,

WTFs per minute

The only valid measurement of code quality is: WTFs/minute

Now Rails has this nifty rake task called rake notes. You can always see notes for a custom tag by:

~> rake notes:custom ANNOTATION=WTF

But rake notes by default only shows notes for OPTIMIZE, FIXME and TODO The Rakefile for changing those defaults is

# for re-defining the Rake task
# otherwise the previous Rake task is still called
task(:notes).clear

desc "Enumerate all annotations
      (use notes:optimize, :fixme, :todo, :wtf for focus)"
task :notes do
  SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO|WTF",
                                      :tag => true
end

namespace :notes do
  task(:wtf).clear
  task :wtf do
    SourceAnnotationExtractor.enumerate "WTF", :tag => true
  end
end

Here we have redefined rake notes. The only gotcha is to remember to clear the old rake task by calling task(:notes).clear

For other customizations eg. search the spec folder also you will have to monkey-patch the SourceAnnotationExtractor class

PS: also check this Stackoverflow thread for some fun picks

More articles

Turn Data into Insights with Apache Superset

Discover how to get started with Apache Superset, a powerful open-source platform for modern data visualization and exploration. From setting up our environment to building interactive dashboards and leveraging advanced analytics, this guide walks us through everything we need to unlock deeper insights from our data

Read more

Data Made Simple with Metabase

Learn how to set up and use Metabase, the open-source business intelligence platform that transforms your data into actionable insights. This comprehensive guide covers installation, dashboard creation, and advanced analytics features...

Read more

Ready to Build Something Amazing?

Codemancers can bring your vision to life and help you achieve your goals