Class: Rack::TidyResponse
- Inherits:
-
Object
- Object
- Rack::TidyResponse
- Defined in:
- lib/rack/tidy_response.rb
Instance Method Summary collapse
-
#initialize(body) ⇒ TidyResponse
constructor
A new instance of TidyResponse.
- #to_s ⇒ Object
- #w3c_errors ⇒ Object
Constructor Details
#initialize(body) ⇒ TidyResponse
Returns a new instance of TidyResponse.
6 7 8 9 |
# File 'lib/rack/tidy_response.rb', line 6 def initialize(body) @body = body ::Tidy.path = '/usr/lib/libtidy.A.dylib' end |
Instance Method Details
#to_s ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/rack/tidy_response.rb', line 11 def to_s tidy = Tidy.open tidy.clean(@body) tidy.errors.join("<br />") + @body end |
#w3c_errors ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rack/tidy_response.rb', line 19 def w3c_errors response = Net::HTTP.post_form( URI.parse("http://validator.w3.org/check"), { 'ss'=>0, 'fragment'=>@body } ) status = response['x-w3c-validator-status'] if status != 'Valid' response.body else nil end end |