Class: Label::SummaryExtractor
- Inherits:
-
Object
- Object
- Label::SummaryExtractor
- Defined in:
- lib/label/summary_extractor.rb
Overview
A class to extract the summary from the contents of a gemspec file
Constant Summary collapse
- STRING_REGEXPS =
[ /\"(?<content>[^"]*)\"/, /'(?<content>[^']*)'/, /%q\{(?<content>[^}]*)\}/i ]
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #extract_summary ⇒ Object
-
#initialize(content) ⇒ SummaryExtractor
constructor
A new instance of SummaryExtractor.
Constructor Details
#initialize(content) ⇒ SummaryExtractor
Returns a new instance of SummaryExtractor.
12 13 14 |
# File 'lib/label/summary_extractor.rb', line 12 def initialize content @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/label/summary_extractor.rb', line 4 def content @content end |
Instance Method Details
#extract_summary ⇒ Object
16 17 18 19 20 21 |
# File 'lib/label/summary_extractor.rb', line 16 def extract_summary STRING_REGEXPS.find do |regexp| md = content.match(/\w+\.summary\s+=\s+#{regexp}/) return md[:content] if md end end |