instance method extract_annotations_from

Ruby on Rails 3.2.22.5

Since v2.2.3 Last seen in v5.2.8.1

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1

Signature

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.

Parameters

file req
pattern req
Source
# File railties/lib/rails/source_annotation_extractor.rb, line 83
  def extract_annotations_from(file, pattern)
    lineno = 0
    result = File.readlines(file).inject([]) do |list, line|
      lineno += 1
      next list unless line =~ pattern
      list << Annotation.new(lineno, $1, $2)
    end
    result.empty? ? {} : { file => result }
  end

Defined in railties/lib/rails/source_annotation_extractor.rb line 83 · View on GitHub · Improve this page · Find usages on GitHub

Defined in SourceAnnotationExtractor

Type at least 2 characters to search.

↑↓ navigate · open · esc close