Class: Marcdouane::Rules::LineLength

Inherits:
Rule
  • Object
show all
Defined in:
lib/marcdouane/rules/line_length.rb

Overview

Ensure the line-length does not go over the default (80) character limit. Link references are not accounted for.

Constant Summary collapse

ERROR_MESSAGE =
"Line-length is over %s characters"

Instance Attribute Summary

Attributes inherited from Rule

#file, #markdown, #options

Instance Method Summary collapse

Methods inherited from Rule

#error!, #identifier, #initialize, #line_number_from_byte_range

Constructor Details

This class inherits a constructor from Marcdouane::Rules::Rule

Instance Method Details

#check!Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/marcdouane/rules/line_length.rb', line 16

def check!
  @markdown.source.lines.each_with_index do |line, index|
    if line.match?(/^\[.*\]: #{URI_REGEXP}$/)
      next
    elsif line.length > self.class.maximum_line_length
      error!(
        index,
        ERROR_MESSAGE % self.class.maximum_line_length
      )
    end
  end
end