SourceAnnotationExtractor


Files

Parent

Description

Implements the logic behind the rake tasks for annotations like

  rake notes
  rake notes:optimize

and friends. See rake -T notes and railties/lib/tasks/annotations.rake.

Annotation objects are triplets :line, :tag, :text that represent the line where the annotation lives, its tag, and its text. Note the filename is not stored.

Annotations are looked for in comments and modulus whitespace they have to start with the tag optionally followed by a colon. Everything up to the end of the line (or closing ERb comment tag) is considered to be their text.

Methods

Classes and Modules

Attributes

[R]

Public Class methods

enumerate (tag, options={})

Prints all annotations with tag tag under the root directories app, lib, and test (recursively). Only filenames with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, or +.erb+ are taken into account. The options hash is passed to each annotation‘s to_s.

This class method is the single entry point for the rake tasks.

new (tag)

Public Instance methods

display (results, options={})

Prints the mapping from filenames to annotations in results ordered by filename. The options hash is passed to each annotation‘s to_s.

extract_annotations_from (file, pattern)

If file is the filename of a file that contains annotations this method returns a hash with a single entry that maps file to an array of its annotations. Otherwise it returns an empty hash.

find (dirs=%w(app lib test))

Returns a hash that maps filenames under dirs (recursively) to arrays with their annotations. Only files with annotations are included, and only those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+ are taken into account.

find_in (dir)

Returns a hash that maps filenames under dir (recursively) to arrays with their annotations. Only files with annotations are included, and only those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+ are taken into account.