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
24 25 26 |
# File 'lib/rails/source_annotation_extractor.rb', line 24 def pattern @pattern end |
Instance Method Details
#annotations(file) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/rails/source_annotation_extractor.rb', line 26 def annotations(file) result = Prism.parse_file(file) return [] unless result.success? result.comments.filter_map do |comment| Annotation.new(comment.location.start_line, $1, $2) if comment.location.slice =~ pattern end end |