Sha256: 83d0515a506b8ed12908a4ab1c5150a57726d84e86bd1583b2537bba50412400

Contents?: true

Size: 956 Bytes

Versions: 7

Compression:

Stored size: 956 Bytes

Contents

module CMSScanner
  # Options available in the Browser
  class Browser
    OPTIONS = [
      :cache_ttl,
      :cookie_jar,
      :cookie_string,
      :connect_timeout,
      :http_auth,
      :max_threads,
      :proxy,
      :proxy_auth,
      :request_timeout,
      :user_agent
    ]

    attr_accessor(*OPTIONS)

    # @param [ Hash ] options
    def load_options(options = {})
      OPTIONS.each do |sym|
        send("#{sym}=", options[sym]) if options.key?(sym)
      end
    end

    def hydra
      @hydra ||= Typhoeus::Hydra.new(max_concurrency: max_threads || 1)
    end

    # Set the threads attribute and update
    # the max_concurrency of Typhoeus::Hydra
    #
    # @param [ Integer ] number
    def max_threads=(number)
      @max_threads = number.to_i > 0 ? number.to_i : 1
      hydra.max_concurrency = @max_threads
    end

    # Default user agent
    def user_agent
      @user_agent ||= "CMSScanner v#{VERSION}"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cms_scanner-0.0.20 lib/cms_scanner/browser/options.rb
cms_scanner-0.0.19 lib/cms_scanner/browser/options.rb
cms_scanner-0.0.18 lib/cms_scanner/browser/options.rb
cms_scanner-0.0.17 lib/cms_scanner/browser/options.rb
cms_scanner-0.0.16 lib/cms_scanner/browser/options.rb
cms_scanner-0.0.15 lib/cms_scanner/browser/options.rb
cms_scanner-0.0.14 lib/cms_scanner/browser/options.rb