Class: SiteValidator::Sitemap

Inherits:
Object
  • Object
show all
Defined in:
lib/site_validator/sitemap.rb

Overview

A sitemap has an URL, and holds a collection of pages to be validated

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, timeout = 20) ⇒ Sitemap

Returns a new instance of Sitemap.



14
15
16
17
# File 'lib/site_validator/sitemap.rb', line 14

def initialize(url, timeout = 20)
  @url      = url
  @timeout  = timeout
end

Instance Attribute Details

#timeoutObject

Returns the value of attribute timeout.



12
13
14
# File 'lib/site_validator/sitemap.rb', line 12

def timeout
  @timeout
end

#urlObject

Returns the value of attribute url.



12
13
14
# File 'lib/site_validator/sitemap.rb', line 12

def url
  @url
end

Instance Method Details

#errorsObject

Returns the combined validation errors of all the pages



27
28
29
# File 'lib/site_validator/sitemap.rb', line 27

def errors
  @errors ||= pages.map {|p| p.errors}.flatten.reject {|e| e.nil?}
end

#get_bindingObject

Returns the binding, needed to paint the ERB template when generating the HTML report (see site_validator/reporter.rb)



40
41
42
# File 'lib/site_validator/sitemap.rb', line 40

def get_binding
  binding
end

#pagesObject

Returns the first 250 unique URLs from the sitemap



21
22
23
# File 'lib/site_validator/sitemap.rb', line 21

def pages
  @pages ||= pages_in_sitemap.uniq {|p| p.url}[0..249]
end

#warningsObject

Returns the combined validation warnings of all the pages



33
34
35
# File 'lib/site_validator/sitemap.rb', line 33

def warnings
  @warnings ||= pages.map {|p| p.warnings}.flatten.reject {|e| e.nil?}
end