Sha256: 88fe08bacac64017068632e18b7ce6ab437bf19780ec9f76e12f83957cb7b76c
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
module LinkChecker module Typhoeus module Hydra class Task < ::LinkChecker::Task def run! request = ::Typhoeus::Request.new( uri, { method: method, followlocation: false, timeout: checker.timeout, connecttimeout: checker.connecttimeout, headers: { 'User-Agent' => checker.user_agent } } ) request.on_complete do |response| if response.timed_out? logger.debug "#{method} #{uri}: #{response.return_code}" result! ResultError.new(uri, method, original_uri, Timeout::Error.new, options) else logger.debug "#{method} #{uri}: #{response.code}" result! Result.new(uri, method, original_uri, request, response, options) end end checker._queue(request) end end class Checker < LinkChecker::Checker extend ::LinkChecker::Typhoeus::Hydra::Config attr_accessor(*LinkChecker::Typhoeus::Hydra::Config::ATTRIBUTES) def initialize(options = {}) LinkChecker::Typhoeus::Hydra::Config::ATTRIBUTES.each do |key| send("#{key}=", options[key] || LinkChecker::Typhoeus::Hydra::Config.send(key)) end @hydra = ::Typhoeus::Hydra.new(options[:hydra] || { max_concurrency: 10 }) super options end def run @hydra.run end def _queue(request) @hydra.queue(request) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-link-checker-0.1.0 | lib/ruby-link-checker/typhoeus/hydra/checker.rb |