Sha256: 95981f21209425423ea62b90357128cabe34ba3cf6fbaf59c2b138138c04c3c8

Contents?: true

Size: 876 Bytes

Versions: 9

Compression:

Stored size: 876 Bytes

Contents

begin
  require 'tidy'
rescue LoadError
  puts "Tidy gem not available -- 'gem install tidy' to get it."
end

if defined? Tidy
  Tidy.path = ENV['TIDY_PATH'] if ENV['TIDY_PATH']

  module Relevance
    module Tarantula

      class TidyHandler
        include Relevance::Tarantula
        def initialize(options = {})
          @options = {:show_warnings=>true}.merge(options)
        end
        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
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
codez-tarantula-0.5.5 lib/relevance/tarantula/tidy_handler.rb
codez-tarantula-0.5.4 lib/relevance/tarantula/tidy_handler.rb
codez-tarantula-0.5.3 lib/relevance/tarantula/tidy_handler.rb
codez-tarantula-0.5.1 lib/relevance/tarantula/tidy_handler.rb
codez-tarantula-0.5.0 lib/relevance/tarantula/tidy_handler.rb
tarantula-0.5.1 lib/relevance/tarantula/tidy_handler.rb
tarantula-0.5.0 lib/relevance/tarantula/tidy_handler.rb
tarantula-0.4.3 lib/relevance/tarantula/tidy_handler.rb
tarantula-0.4.2 lib/relevance/tarantula/tidy_handler.rb