Sha256: f8a2063b737a69d26d072def66257b482caedc1245e23e7bd6848b20ce5971b0

Contents?: true

Size: 828 Bytes

Versions: 30

Compression:

Stored size: 828 Bytes

Contents

# frozen_string_literal: true

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

30 entries across 30 versions & 1 rubygems

Version Path
nanoc-4.9.4 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.9.3 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.9.2 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.9.1 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.9.0 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.19 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.18 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.17 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.16 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.15 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.14 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.13 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.12 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.11 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.10 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.9 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.8 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.7 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.6 lib/nanoc/checking/checks/w3c_validator.rb
nanoc-4.8.5 lib/nanoc/checking/checks/w3c_validator.rb