Class: Todonotes::Todo
- Inherits:
-
Object
- Object
- Todonotes::Todo
- Defined in:
- lib/todonotes/todo.rb
Overview
Report the ToDo/FixMe and count occurence.
The first occurence is reported as a warning, next occurences are informations.
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#result ⇒ Object
readonly
Temporary result of the Todo.
-
#short_description ⇒ Object
readonly
Returns the value of attribute short_description.
Instance Method Summary collapse
-
#call ⇒ Object
Todo/Fixme is called again.
-
#infoline(settings) ⇒ Object
Return a single line with status of the todo.
-
#initialize(codeline, type, comment, logger, &block) ⇒ Todo
constructor
A new instance of Todo.
- #to_s ⇒ Object
Constructor Details
#initialize(codeline, type, comment, logger, &block) ⇒ Todo
Returns a new instance of Todo.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/todonotes/todo.rb', line 14 def initialize(codeline, type, comment, logger, &block) @logger = logger @count = 1 @codeline = codeline @type = type @shortdescription = comment #Build result @result = yield if block_given? #The Todonotes::FixmeFormatter can handle array in a special way to reformat the output. @logger.warn([@type, "#{@codeline} #{@shortdescription} (temporary: #{@result.inspect})"]) end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
30 31 32 |
# File 'lib/todonotes/todo.rb', line 30 def count @count end |
#result ⇒ Object (readonly)
Temporary result of the Todo. This result should become a ‘real’ value
28 29 30 |
# File 'lib/todonotes/todo.rb', line 28 def result @result end |
#short_description ⇒ Object (readonly)
Returns the value of attribute short_description.
29 30 31 |
# File 'lib/todonotes/todo.rb', line 29 def short_description @short_description end |
Instance Method Details
#call ⇒ Object
Todo/Fixme is called again
34 35 36 37 38 39 |
# File 'lib/todonotes/todo.rb', line 34 def call() #The Todonotes::FixmeFormatter can handle array in a special way to reformat the output. @logger.info([@type, "#{@codeline}(#{@count}) #{@shortdescription} (temporary: #{@result.inspect})"]) @count += 1 @result = yield if block_given? #re-evaluate block end |
#infoline(settings) ⇒ Object
Return a single line with status of the todo.
Depending on with_type you get also the type (ToDo/FixMe)
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/todonotes/todo.rb', line 50 def (settings) res = @codeline.dup res << " (%-5s)" % @type if settings.include?(:with_type) res << ": %4i call%s" % [ @count, @count > 1 ? 's': '' ] res << " (%s)" % @shortdescription if settings.include?(:with_shortdescription) res << " = '#{@result.inspect}'" if settings.include?(:with_result) res end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/todonotes/todo.rb', line 42 def to_s() "#{@type}: #{@codeline}" end |