Class: Gitnesse::FeatureExtractor
- Inherits:
-
Object
- Object
- Gitnesse::FeatureExtractor
- Defined in:
- lib/gitnesse/feature_extractor.rb
Class Method Summary collapse
-
.contains_features?(string) ⇒ Boolean
Checks if a string contains a Cucumber feature.
-
.extract!(string) ⇒ Object
Extracts Cucumber features from a Markdown-formatted string.
Class Method Details
.contains_features?(string) ⇒ Boolean
Checks if a string contains a Cucumber feature
string - Markdown-formatted string to check for Cucumber features in
Returns true if there are features, false otherwise
25 26 27 |
# File 'lib/gitnesse/feature_extractor.rb', line 25 def self.contains_features?(string) string.scan(/\u0060{3}gherkin\s*(.+?)\u0060{3}/im).flatten.any? end |
.extract!(string) ⇒ Object
Extracts Cucumber features from a Markdown-formatted string
string - Markdown-formatted string to find Cucumber features in
Returns an array of matches
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gitnesse/feature_extractor.rb', line 9 def self.extract!(string) matches = string.scan(/\u0060{3}gherkin\s*(.+?)\u0060{3}/im).flatten if matches.any? # Remove newline characters from beginning/end of each feature matches.map { |m| m.lstrip! ; m.chomp! } else [] end end |