Class: Git::Lint::Validators::RepeatedWord
- Inherits:
-
Object
- Object
- Git::Lint::Validators::RepeatedWord
- Defined in:
- lib/git/lint/validators/repeated_word.rb
Overview
Validates content has no repeated words.
Constant Summary collapse
- PATTERNS =
{ word: / \w+(?=\s) # Match word with trailing space. | # Or. (?<=\s)\w+(?=\s) # Match word between two spaces. | # Or. (?<=\s)\w+ # Match word with leading space. /x, exclude: / ( # Conditional start. `.+` # Code blocks. | # Or. \d+\. # Digits followed by periods. ) # Conditional end. /x }.freeze
Instance Method Summary collapse
- #call(content) ⇒ Object
-
#initialize(patterns: PATTERNS) ⇒ RepeatedWord
constructor
A new instance of RepeatedWord.
Constructor Details
#initialize(patterns: PATTERNS) ⇒ RepeatedWord
Returns a new instance of RepeatedWord.
27 28 29 |
# File 'lib/git/lint/validators/repeated_word.rb', line 27 def initialize patterns: PATTERNS @patterns = patterns end |
Instance Method Details
#call(content) ⇒ Object
31 |
# File 'lib/git/lint/validators/repeated_word.rb', line 31 def call(content) = content ? scan(content) : Core::EMPTY_ARRAY |