123456789_123456789_123456789_123456789_123456789_

Class: Rails::SourceAnnotationExtractor::Annotation

Relationships & Source Files
Inherits: Struct
  • ::Object
Defined in: railties/lib/rails/source_annotation_extractor.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Class Method Details

.directories

[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 72

def self.directories
  @@directories ||= %w(app config db lib test)
end

.extensions

[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 92

def self.extensions
  @@extensions ||= {}
end

.register_directories(*dirs)

Registers additional directories to be included

Rails::SourceAnnotationExtractor::Annotation.register_directories("spec", "another")
[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 78

def self.register_directories(*dirs)
  directories.push(*dirs)
end

.register_extensions(*exts, &block)

Registers new Annotations File Extensions

Rails::SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 98

def self.register_extensions(*exts, &block)
  extensions[/\.(#{exts.join("|")})$/] = block
end

.register_tags(*additional_tags)

Registers additional tags

Rails::SourceAnnotationExtractor::Annotation.register_tags("TESTME", "DEPRECATEME")
[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 88

def self.register_tags(*additional_tags)
  tags.push(*additional_tags)
end

.tags

[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 82

def self.tags
  @@tags ||= %w(OPTIMIZE FIXME TODO)
end

Instance Attribute Details

#line (rw)

[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 71

class Annotation < Struct.new(:line, :tag, :text)

#tag (rw)

[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 71

class Annotation < Struct.new(:line, :tag, :text)

#text (rw)

[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 71

class Annotation < Struct.new(:line, :tag, :text)

Instance Method Details

#to_s(options = {})

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.

[ GitHub ]

  
# File 'railties/lib/rails/source_annotation_extractor.rb', line 124

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