Class: Relevance::Tarantula::TidyHandler

Inherits:
Object
  • Object
show all
Includes:
Relevance::Tarantula
Defined in:
lib/relevance/tarantula/tidy_handler.rb

Constant Summary

Constants included from Relevance::Tarantula

VERSION

Instance Method Summary collapse

Methods included from Relevance::Tarantula

#log, #rails_root, #tarantula_home, #verbose

Constructor Details

#initialize(options = {}) ⇒ TidyHandler

Returns a new instance of TidyHandler



15
16
17
# File 'lib/relevance/tarantula/tidy_handler.rb', line 15

def initialize(options = {})
  @options = {:show_warnings=>true}.merge(options)
end

Instance Method Details

#handle(result) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/relevance/tarantula/tidy_handler.rb', line 18

def handle(result)
  response = result.response
  return unless response.html?
  tidy = Tidy.open(@options) do |tidy|
    xml = tidy.clean(response.body)
    tidy
  end
  unless tidy.errors.blank?
    error_result = result.dup
    error_result.description = "Bad HTML (Tidy)"
    error_result.data = tidy.errors.inspect
    error_result
  end
end