Class: HtmlMockup::Rack::HtmlValidator
- Inherits:
-
Object
- Object
- HtmlMockup::Rack::HtmlValidator
- Defined in:
- lib/html_mockup/rack/html_validator.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ HtmlValidator
constructor
A new instance of HtmlValidator.
Constructor Details
#initialize(app) ⇒ HtmlValidator
Returns a new instance of HtmlValidator.
7 8 9 |
# File 'lib/html_mockup/rack/html_validator.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/html_mockup/rack/html_validator.rb', line 11 def call(env) resp = @app.call(env) if resp[1]["Content-Type"].to_s.include?("html") str = "" resp[2].each{|c| str << c} validator = W3CValidator.new(str) validator.validate! if !validator.valid env["rack.errors"].puts "Validation failed on #{env["PATH_INFO"]}: (errors: #{validator.errors}, warnings: #{validator.warnings})" end end resp end |