Sha256: b11d3d9ce8f9c8024914af2c85b6176ab7b44e31295fa930f69e721fc2b9c758

Contents?: true

Size: 797 Bytes

Versions: 13

Compression:

Stored size: 797 Bytes

Contents

module ::Nanoc::Checking::Checks
  # @api private
  class W3CValidator < ::Nanoc::Checking::Check
    def run
      require 'w3c_validators'
      require 'resolv-replace'

      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

    def extension
      raise NotImplementedError
    end

    def validator_class
      raise NotImplementedError
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
nanoc-4.7.9 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.8 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.7 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.6 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.5 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.4 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.3 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.2 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.1 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.7.0 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.6.4 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.6.3 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.6.2 lib/nanoc/checking/checks/w3c_validator.rb