lib/hwacha.rb in hwacha-0.2.0 vs lib/hwacha.rb in hwacha-0.3.0

- old
+ new

@@ -1,26 +1,26 @@ require "hwacha/version" require "hwacha/config" require "typhoeus" class Hwacha - attr_reader :max_concurrent_requests + 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? - @max_concurrent_requests = config.max_concurrent_requests + @config = config end def check(urls) - hydra = Typhoeus::Hydra.new(:max_concurrency => @max_concurrent_requests) + hydra = build_hydra Array(urls).each do |url| request = Typhoeus::Request.new(url) request.on_complete do |response| yield response.effective_url, response @@ -38,6 +38,10 @@ end # Hwacha!!! alias :fire :check alias :strike_true :find_existing + + def build_hydra + Typhoeus::Hydra.new(config.options) + end end