Project

todonotes

0.01
No commit activity in last 3 years
No release in over 3 years
Support programming by fixme/todo commands.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.1.1, ~> 0

Runtime

~> 1
 Project Readme

todonotes¶ ↑

Define todo- and fixme-command to mark open topics during software development.

Usage:¶ ↑

Add todo and fixme to your code and get track of your todos during runtime of your code.

Productive programms should not use this gem.

When you pass a todo/fixme during execution, you get a logging information.

todo ('message' ) { "temporary result" }
fixme ('message' ) { "temporary result" }

todo and fixme have the same syntax, the sematic meaning is:

  • ToDo: Mark missing code.

  • FixMe: Mark code to repair.

Disadvantage:

  • Does not replace a good IDE to find the ToDo/Fixmes.

This Gem is based on a proposal in forum.ruby-portal.de/viewtopic.php?f=11&t=11957

Example¶ ↑

Think, you have to write a script to count all prime between 1 to 10.

You don’t know how to check for primes, but at least you know, primes must be odd.

So you can start your program:

require 'todonotes'

primecount = 0
for i in 1..10
        if fixme "Calculate if prime, temporary: true for odd numbers" do 
              i.odd?  #tempory: odd = prim
            end
          primecount += 1 
          puts "#{i} is a prime number"
        else
          puts "#{i} is no prime number"
        end
end

todo "Return total number of primes"

Or

require 'todonotes'
class Fixnum
  def prime?
      fixme "Calculate if prime" do 
              self.odd?  #tempory: odd = prim
      end    
  end
end

primecount = 0
for i in 1..10
        if i.prime?
          primecount += 1 
          puts "#{i} is a prime number"
        else
          puts "#{i} is no prime number"
        end
end

todo "Return total number of primes"

Now you get a output like this:

FixMe: todonotes_prim2.rb:12 Calculate if prime misssing (temporary: true)
1 is a prime number
FixMe: todonotes_prim2.rb:12(2) Calculate if prime misssing (temporary: false)
2 is no prime number
FixMe: todonotes_prim2.rb:12(3) Calculate if prime misssing (temporary: true)
...
ToDo : todonotes_prim2.rb:27 Return total number of primes (temporary: nil)

The Todonotes is warning about a wrong or uncompleted code piece.

The ToDo is warning for a missing code piece.

You are informed about source code file and line number. In braces you get the number of calls.

The todo/fixme command evaluates the optional block. The result is returned as a temporary result (in this example: odd numbers are primes.).

Please refer the examples folder for more details.

Logging¶ ↑

The Fixme’s and ToDo’s are reported via a logger (log4r).

The first call of a fixme/todo is a warning, the next call is an information. With this logic you can decide, if you want to see each call or only the first call.

You may change the level with:

Todonotes.logger.level = Log4r::WARN #only first time of a call of a fixme/todo
Todonotes.logger.level = Log4r::INFO   #report all calls of fixme/todo

You can log the fixme/todos to a file:

Todonotes.log2file()

Get Overview¶ ↑

You may print an overview on all fixme/todos:

Todonotes.print_stats()

Example:

List of ToDos/Fixmes:
todonotes_prim.rb:11:   10 calls
todonotes_prim.rb:21:    1 call

There is a fixme/todo in line 11 and 21 in todonotes_prim.rb.

Go productive¶ ↑

Before you go productive with your application you should remove this gem and delete all fixme- and todo-commands.

You may also set

Todonotes::TODONOTES.raise_fixme = true
Todonotes::TODONOTES.raise_todo = true

After this you will get a ImplementationError-Exception if Kernel#fixme or Kernel.todo is called.