Module: SiteValidator::Validator

Extended by:
Validator
Included in:
Validator
Defined in:
lib/site_validator/validator.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#printer=(value) ⇒ Object

Sets the attribute printer

Parameters:

  • value

    the value to set the attribute printer to.



9
10
11
# File 'lib/site_validator/validator.rb', line 9

def printer=(value)
  @printer = value
end

Instance Method Details

#check(url, filename, max_pages) ⇒ Object

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



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/site_validator/validator.rb', line 18

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