Class: SiteValidator::Sitemap
- Inherits:
-
Object
- Object
- SiteValidator::Sitemap
- 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
-
#max_pages ⇒ Object
Returns the value of attribute max_pages.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#errors ⇒ Object
Returns the combined validation errors of all the pages.
-
#get_binding ⇒ Object
Returns the binding, needed to paint the ERB template when generating the HTML report (see site_validator/reporter.rb).
-
#initialize(url, max_pages = 100) ⇒ Sitemap
constructor
A new instance of Sitemap.
-
#pages ⇒ Object
Returns the first 250 unique URLs from the sitemap.
-
#warnings ⇒ Object
Returns the combined validation warnings of all the pages.
Constructor Details
#initialize(url, max_pages = 100) ⇒ Sitemap
Returns a new instance of Sitemap.
13 14 15 16 |
# File 'lib/site_validator/sitemap.rb', line 13 def initialize(url, max_pages = 100) @url = url @max_pages = max_pages end |
Instance Attribute Details
#max_pages ⇒ Object
Returns the value of attribute max_pages.
11 12 13 |
# File 'lib/site_validator/sitemap.rb', line 11 def max_pages @max_pages end |
#url ⇒ Object
Returns the value of attribute url.
11 12 13 |
# File 'lib/site_validator/sitemap.rb', line 11 def url @url end |
Instance Method Details
#errors ⇒ Object
Returns the combined validation errors of all the pages
26 27 28 |
# File 'lib/site_validator/sitemap.rb', line 26 def errors @errors ||= pages.map {|p| p.errors}.flatten.reject {|e| e.nil?} end |
#get_binding ⇒ Object
Returns the binding, needed to paint the ERB template when generating the HTML report (see site_validator/reporter.rb)
39 40 41 |
# File 'lib/site_validator/sitemap.rb', line 39 def get_binding binding end |
#pages ⇒ Object
Returns the first 250 unique URLs from the sitemap
20 21 22 |
# File 'lib/site_validator/sitemap.rb', line 20 def pages @pages ||= pages_in_sitemap.uniq {|p| p.url}[0..max_pages-1] end |
#warnings ⇒ Object
Returns the combined validation warnings of all the pages
32 33 34 |
# File 'lib/site_validator/sitemap.rb', line 32 def warnings @warnings ||= pages.map {|p| p.warnings}.flatten.reject {|e| e.nil?} end |