Sha256: 20c32d9eb5bbebf6bd97ba33af889fe1315aa8d24ff28fe6c637b2f4238b9620

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 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 written to filename
    def check(url, filename, timeout)
      sitemap = W3Clove::Sitemap.new(url, timeout.to_f)
      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, filename)
      say "\nValidation finished, see the report at #{filename}"
    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

11 entries across 11 versions & 1 rubygems

Version Path
w3clove-0.8 lib/w3clove/validator.rb
w3clove-0.7.11 lib/w3clove/validator.rb
w3clove-0.7.10 lib/w3clove/validator.rb
w3clove-0.7.9 lib/w3clove/validator.rb
w3clove-0.7.8 lib/w3clove/validator.rb
w3clove-0.7.7 lib/w3clove/validator.rb
w3clove-0.7.6 lib/w3clove/validator.rb
w3clove-0.7.5 lib/w3clove/validator.rb
w3clove-0.7.4 lib/w3clove/validator.rb
w3clove-0.7.3 lib/w3clove/validator.rb
w3clove-0.7.2 lib/w3clove/validator.rb