Sha256: f84ab89d3f70b981ae658f947a11ff82da57002a93ef1b43e8b255b35cebf6d6

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# -*- encoding: utf-8 -*-

module W3Clove
  ##
  # Validator module is the one in charge of doing the validation loop
  # for all pages on a sitemap and output the errors
  #
  module Validator
    attr_writer :printer

    extend self

    ##
    # Parses a remote xml sitemap and checks markup validation for each url
    # Shows progress on dot-style (...F...FFE..). A dot is a valid page,
    # an F is a page with errors, and an E is an exception
    # After the checking is done, a detailed summary is generated
    def check(url)
      sitemap = W3Clove::Sitemap.new(url)
      say "Validating #{sitemap.pages.length} pages"

      sitemap.pages.each do |page|
        say_inline page.valid? ? "." : (page.errors.nil? ? 'E' : 'F')
      end

      W3Clove::Reporter.generate_html(sitemap)
      say "\nValidation finished, see the report at w3clove.html"
    end

    private

    def printer
      @printer ||= STDOUT
    end

    ##
    # A shorter alias for printer.puts
    def say(text)
      printer.puts text
    end

    ##
    # A shorter alias for printer.print
    def say_inline(text)
      printer.print text
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
w3clove-0.3.0 lib/w3clove/validator.rb