Class: PeekAView::Tools::HtmlValidator
- Defined in:
- lib/peek_a_view/tools/html_validator.rb
Instance Method Summary collapse
- #check(uri) ⇒ Object
-
#initialize(options) ⇒ HtmlValidator
constructor
A new instance of HtmlValidator.
- #report(uri) ⇒ Object
Methods inherited from Checker
Constructor Details
#initialize(options) ⇒ HtmlValidator
Returns a new instance of HtmlValidator.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/peek_a_view/tools/html_validator.rb', line 9 def initialize() validator_uri = .delete(:validator_uri) raise ArgumentError, "Option validator_uri must be specified" unless validator_uri super # Somehow the validator does not get this from the response charset = ([:charset] || 'UTF-8').upcase @validator = W3CValidators::NuValidator.new( validator_uri: validator_uri, charset: charset ) end |
Instance Method Details
#check(uri) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/peek_a_view/tools/html_validator.rb', line 23 def check(uri) results = validate(uri) puts "Valid: #{results.is_valid?}" puts puts 'Errors' puts results.errors.map(&:message) puts puts 'Warnings' puts results.warnings.map(&:message) puts end |
#report(uri) ⇒ Object
35 36 37 38 |
# File 'lib/peek_a_view/tools/html_validator.rb', line 35 def report(uri) results = validate(uri) write_report(uri, results) end |