Class: Rails::SourceAnnotationExtractor::ParserExtractor
- Inherits:
-
Struct
- Object
- Struct
- Rails::SourceAnnotationExtractor::ParserExtractor
- Defined in:
- lib/rails/source_annotation_extractor.rb
Overview
Wraps a regular expression that will be tested against each of the source file’s comments.
Defined Under Namespace
Classes: Parser
Instance Attribute Summary collapse
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Instance Method Summary collapse
Instance Attribute Details
#pattern ⇒ Object
Returns the value of attribute pattern
18 19 20 |
# File 'lib/rails/source_annotation_extractor.rb', line 18 def pattern @pattern end |
Instance Method Details
#annotations(file) ⇒ Object
33 34 35 36 37 |
# File '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 |