Class: SiteHealth::Checkers::HTMLPage
- Inherits:
-
Object
- Object
- SiteHealth::Checkers::HTMLPage
- Defined in:
- lib/site_health/checkers/html_page.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
- #check_content ⇒ W3CValidators::Results
-
#initialize(page) ⇒ HTMLPage
constructor
A new instance of HTMLPage.
- #missing_title? ⇒ Boolean
Constructor Details
#initialize(page) ⇒ HTMLPage
Returns a new instance of HTMLPage.
11 12 13 14 |
# File 'lib/site_health/checkers/html_page.rb', line 11 def initialize(page) @page = page @url = page.url end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
8 9 10 |
# File 'lib/site_health/checkers/html_page.rb', line 8 def page @page end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/site_health/checkers/html_page.rb', line 8 def url @url end |
Class Method Details
.check(page) ⇒ Object
4 5 6 |
# File 'lib/site_health/checkers/html_page.rb', line 4 def self.check(page) new(page).check end |
Instance Method Details
#check ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/site_health/checkers/html_page.rb', line 16 def check result = check_content HTMLJournal.new( url: url, page: page, missing_title: missing_title?, errors: result.errors.map { |e| W3CJournalBuilder.build(e) }, warnings: result.warnings.map { |e| W3CJournalBuilder.build(e) } ) end |
#check_content ⇒ W3CValidators::Results
35 36 37 38 |
# File 'lib/site_health/checkers/html_page.rb', line 35 def check_content validator = W3CValidators::NuValidator.new validator.validate_uri(url) end |
#missing_title? ⇒ Boolean
28 29 30 |
# File 'lib/site_health/checkers/html_page.rb', line 28 def missing_title? page.title.to_s.strip.empty? end |