Sha256: cc756ea50479a8f5e97d1e0f03426f4290e138bc8f433a0d72307cce4d312c25
Contents?: true
Size: 935 Bytes
Versions: 3
Compression:
Stored size: 935 Bytes
Contents
require "hwacha/version" require "hwacha/config" require "typhoeus" class Hwacha attr_reader :config def initialize(max_concurrent_requests=20) config = Hwacha::Config.new # support the simple legacy API config.max_concurrent_requests = max_concurrent_requests # the nice configuration object API yield config if block_given? @config = config end def check(urls) hydra = build_hydra Array(urls).each do |url| request = Typhoeus::Request.new(url, config.request_options) request.on_complete do |response| yield response.effective_url, response end hydra.queue request end hydra.run end def find_existing(urls) check(urls) do |url, response| yield url if response.success? end end # Hwacha!!! alias :fire :check alias :strike_true :find_existing def build_hydra Typhoeus::Hydra.new(config.hydra_options) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hwacha-1.0.2 | lib/hwacha.rb |
hwacha-1.0.1 | lib/hwacha.rb |
hwacha-1.0.0 | lib/hwacha.rb |