Class: Nanoc::Checking::Checks::W3CValidator Private

Inherits:
Nanoc::Checking::Check show all
Defined in:
lib/nanoc/checking/checks/w3c_validator.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

CSS, HTML

Instance Attribute Summary

Attributes inherited from Nanoc::Checking::Check

#issues

Instance Method Summary collapse

Methods inherited from Nanoc::Checking::Check

#add_issue, create, define, #excluded_patterns, #initialize, #output_filenames, #output_html_filenames

Constructor Details

This class inherits a constructor from Nanoc::Checking::Check

Instance Method Details

#extensionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/nanoc/checking/checks/w3c_validator.rb', line 24

def extension
  raise NotImplementedError
end

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nanoc/checking/checks/w3c_validator.rb', line 8

def run
  require 'w3c_validators'

  Dir[@config.output_dir + '/**/*.' + extension].each do |filename|
    results = validator_class.new.validate_file(filename)
    lines = File.readlines(filename)
    results.errors.each do |e|
      line_num = e.line.to_i - 1
      line = lines[line_num]
      message = e.message.gsub(%r{\s+}, ' ').strip.sub(/\s+:$/, '')
      desc = "line #{line_num + 1}: #{message}: #{line}"
      add_issue(desc, subject: filename)
    end
  end
end

#validator_classObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/nanoc/checking/checks/w3c_validator.rb', line 28

def validator_class
  raise NotImplementedError
end