Sha256: 6e197df62e5bfa53f755434f06abdbeb8e954e2dcddf36ed72d050484038724b

Contents?: true

Size: 780 Bytes

Versions: 14

Compression:

Stored size: 780 Bytes

Contents

module ::Nanoc::Extra::Checking::Checks
  # @api private
  class W3CValidator < ::Nanoc::Extra::Checking::Check
    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

    def extension
      raise NotImplementedError
    end

    def validator_class
      raise NotImplementedError
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
nanoc-4.3.7 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.3.6 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.3.5 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.3.4 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.3.3 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.3.2 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.3.1 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.3.0 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.2.4 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.2.3 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.2.2 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.2.1 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.2.0 lib/nanoc/extra/checking/checks/w3c_validator.rb
nanoc-4.2.0b1 lib/nanoc/extra/checking/checks/w3c_validator.rb