module SiteValidator::Validator

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

Attributes

printer[W]

Public Instance Methods

check(url, filename, max_pages) click to toggle source

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

# File lib/site_validator/validator.rb, line 17
def check(url, filename, max_pages)
  sitemap = SiteValidator::Sitemap.new(url, max_pages.to_i)
  say "Validating #{sitemap.pages.length} pages"

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

  SiteValidator::Reporter.generate_html(sitemap, filename)
  say "\nValidation finished, see the report at #{filename}"
end

Private Instance Methods

printer() click to toggle source
# File lib/site_validator/validator.rb, line 31
def printer
  @printer ||= STDOUT
end
say(text) click to toggle source

A shorter alias for printer.puts

# File lib/site_validator/validator.rb, line 37
def say(text)
  printer.puts text
end
say_inline(text) click to toggle source

A shorter alias for printer.print

# File lib/site_validator/validator.rb, line 43
def say_inline(text)
  printer.print text
end