Sha256: d3b20e8043180dd7eb15a18cdb208fef0f4431f8bef0352d651347b302d52093

Contents?: true

Size: 759 Bytes

Versions: 21

Compression:

Stored size: 759 Bytes

Contents

require 'rubygems'
begin
  gem 'tidy'
  require 'tidy'
rescue Gem::LoadError
  # tidy not available
end

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

  class Relevance::Tarantula::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

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
relevance-tarantula-0.0.1 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.0.2 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.0.3 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.0.5 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.0.6 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.0.7.1 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.0.7 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.0.8.0 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.0.8.1 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.1.0 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.1.1 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.1.2 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.1.3 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.1.4 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.1.5 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.1.6 lib/relevance/tarantula/tidy_handler.rb
relevance-tarantula-0.1.7 lib/relevance/tarantula/tidy_handler.rb
tarantula-0.0.8.1 lib/relevance/tarantula/tidy_handler.rb
tarantula-0.0.5 lib/relevance/tarantula/tidy_handler.rb
tarantula-0.1.4 lib/relevance/tarantula/tidy_handler.rb