Class: CodeNotes::SourceAnnotationExtractor::Annotation

Inherits:
Struct
  • Object
show all
Defined in:
lib/code_notes/source_annotation_extractor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



17
18
19
# File 'lib/code_notes/source_annotation_extractor.rb', line 17

def line
  @line
end

#tagObject

Returns the value of attribute tag

Returns:

  • (Object)

    the current value of tag



17
18
19
# File 'lib/code_notes/source_annotation_extractor.rb', line 17

def tag
  @tag
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



17
18
19
# File 'lib/code_notes/source_annotation_extractor.rb', line 17

def text
  @text
end

Class Method Details

.default_directoriesObject



18
19
20
# File 'lib/code_notes/source_annotation_extractor.rb', line 18

def self.default_directories
  %w(app config db lib test spec features)
end

.directoriesObject



22
23
24
# File 'lib/code_notes/source_annotation_extractor.rb', line 22

def self.directories
  @@directories ||= default_directories + (ENV['SOURCE_ANNOTATION_DIRECTORIES'] || '').split(',')
end

Instance Method Details

#to_s(options = {}) ⇒ Object

Returns a representation of the annotation that looks like this:

[126] [TODO] This algorithm is simple and clearly correct, make it faster.

If options has a flag :tag the tag is shown as in the example above. Otherwise the string contains just line and text.



32
33
34
35
36
# File 'lib/code_notes/source_annotation_extractor.rb', line 32

def to_s(options={})
  s = "[#{line.to_s.rjust(options[:indent])}] "
  s << "[#{tag}] " if options[:tag]
  s << text
end