Class: W3Clove::Sitemap

Inherits:
Object
  • Object
show all
Defined in:
lib/w3clove/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.



15
16
17
18
# File 'lib/w3clove/sitemap.rb', line 15

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

Instance Attribute Details

#timeoutObject

Returns the value of attribute timeout.



13
14
15
# File 'lib/w3clove/sitemap.rb', line 13

def timeout
  @timeout
end

#urlObject

Returns the value of attribute url.



13
14
15
# File 'lib/w3clove/sitemap.rb', line 13

def url
  @url
end

Instance Method Details

#errorsObject

Returns the combined validation errors of all the pages



28
29
30
# File 'lib/w3clove/sitemap.rb', line 28

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 w3clove/reporter.rb)



41
42
43
# File 'lib/w3clove/sitemap.rb', line 41

def get_binding
  binding
end

#pagesObject

Returns the first 250 unique URLs from the sitemap



22
23
24
# File 'lib/w3clove/sitemap.rb', line 22

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

#warningsObject

Returns the combined validation warnings of all the pages



34
35
36
# File 'lib/w3clove/sitemap.rb', line 34

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