Skip to Content Skip to Search

class Rails::SourceAnnotationExtractor::Annotation

Inherits From

Public class methods

Source code GitHub
# File railties/lib/rails/source_annotation_extractor.rb, line 55
def self.directories
  @@directories ||= %w(app config db lib test)
end
Source code GitHub
# File railties/lib/rails/source_annotation_extractor.rb, line 75
def self.extensions
  @@extensions ||= {}
end

Registers additional directories to be included

Rails::SourceAnnotationExtractor::Annotation.register_directories("spec", "another")
Source code GitHub
# File railties/lib/rails/source_annotation_extractor.rb, line 61
def self.register_directories(*dirs)
  directories.push(*dirs)
end

Registers new Annotations File Extensions

Rails::SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
Source code GitHub
# File railties/lib/rails/source_annotation_extractor.rb, line 81
def self.register_extensions(*exts, &block)
  extensions[/\.(#{exts.join("|")})$/] = block
end

Registers additional tags

Rails::SourceAnnotationExtractor::Annotation.register_tags("TESTME", "DEPRECATEME")
Source code GitHub
# File railties/lib/rails/source_annotation_extractor.rb, line 71
def self.register_tags(*additional_tags)
  tags.push(*additional_tags)
end
Source code GitHub
# File railties/lib/rails/source_annotation_extractor.rb, line 65
def self.tags
  @@tags ||= %w(OPTIMIZE FIXME TODO)
end

Public instance methods

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.

Source code GitHub
# File railties/lib/rails/source_annotation_extractor.rb, line 107
def to_s(options = {})
  s = +"[#{line.to_s.rjust(options[:indent])}] "
  s << "[#{tag}] " if options[:tag]
  s << text
end

Definition files