123456789_123456789_123456789_123456789_123456789_

Class: Rails::SourceAnnotationExtractor::PatternExtractor

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

Overview

Wraps a regular expression that will iterate through a file’s lines and test each one for the given pattern.

Instance Attribute Summary

  • #pattern rw

    Wraps a regular expression that will iterate through a file’s lines and test each one for the given pattern.

Instance Method Summary

Instance Attribute Details

#pattern (rw)

Wraps a regular expression that will iterate through a file’s lines and test each one for the given pattern.

[ GitHub ]

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

class PatternExtractor < Struct.new(:pattern)

Instance Method Details

#annotations(file)

[ GitHub ]

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

def annotations(file)
  lineno = 0

  File.readlines(file, encoding: Encoding::BINARY).inject([]) do |list, line|
    lineno += 1
    next list unless line =~ pattern
    list << Annotation.new(lineno, $1, $2)
  end
end