123456789_123456789_123456789_123456789_123456789_

Class: Rails::SourceAnnotationExtractor::ParserExtractor

Relationships & Source Files
Namespace Children
Classes:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::Struct
Instance Chain:
self, ::Struct
Inherits: Struct
Defined in: railties/lib/rails/source_annotation_extractor.rb

Overview

Wraps a regular expression that will be tested against each of the source file’s comments.

Instance Attribute Summary

  • #pattern rw

    Wraps a regular expression that will be tested against each of the source file’s comments.

Instance Method Summary

Instance Attribute Details

#pattern (rw)

Wraps a regular expression that will be tested against each of the source file’s comments.

[ GitHub ]

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

class ParserExtractor < Struct.new(:pattern)

Instance Method Details

#annotations(file)

[ GitHub ]

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

def annotations(file)
  contents = File.read(file, encoding: Encoding::BINARY)
  parser = Parser.new(contents, pattern: pattern).tap(&:parse)
  parser.error? ? [] : parser.comments
end