Module: Typhoeus

Defined in:
lib/typhoeus.rb,
lib/typhoeus/curl.rb,
lib/typhoeus/easy.rb,
lib/typhoeus/form.rb,
lib/typhoeus/hydra.rb,
lib/typhoeus/multi.rb,
lib/typhoeus/utils.rb,
lib/typhoeus/filter.rb,
lib/typhoeus/header.rb,
lib/typhoeus/remote.rb,
lib/typhoeus/request.rb,
lib/typhoeus/version.rb,
lib/typhoeus/easy/ssl.rb,
lib/typhoeus/response.rb,
lib/typhoeus/easy/auth.rb,
lib/typhoeus/easy/infos.rb,
lib/typhoeus/easy/proxy.rb,
lib/typhoeus/hydra_mock.rb,
lib/typhoeus/easy/options.rb,
lib/typhoeus/remote_method.rb,
lib/typhoeus/easy/callbacks.rb,
lib/typhoeus/hydra/stubbing.rb,
lib/typhoeus/easy/ffi_helper.rb,
lib/typhoeus/hydra/callbacks.rb,
lib/typhoeus/param_processor.rb,
lib/typhoeus/remote_proxy_object.rb,
lib/typhoeus/hydra/connect_options.rb

Defined Under Namespace

Modules: ClassMethods, Curl, EasyFu, Utils Classes: Easy, Filter, Form, Header, Hydra, HydraMock, MockExpectedError, Multi, ParamProcessor, RemoteMethod, RemoteProxyObject, Request, Response

Constant Summary collapse

USER_AGENT =
"Typhoeus - http://github.com/dbalatero/typhoeus/tree/master"
VERSION =
'0.4.2'

Class Method Summary collapse

Class Method Details

.add_easy_request(easy_object) ⇒ Object



43
44
45
46
# File 'lib/typhoeus.rb', line 43

def self.add_easy_request(easy_object)
  Thread.current[:curl_multi] ||= Typhoeus::Multi.new
  Thread.current[:curl_multi].add(easy_object)
end

.easy_object_poolObject



20
21
22
# File 'lib/typhoeus.rb', line 20

def self.easy_object_pool
  @easy_objects ||= []
end

.get_easy_objectObject



35
36
37
38
39
40
41
# File 'lib/typhoeus.rb', line 35

def self.get_easy_object
  if easy_object_pool.empty?
    Typhoeus::Easy.new
  else
    easy_object_pool.pop
  end
end

.included(base) ⇒ Object



4
5
6
# File 'lib/typhoeus/remote.rb', line 4

def self.included(base)
  base.extend ClassMethods
end

.init_easy_object_poolObject



24
25
26
27
28
# File 'lib/typhoeus.rb', line 24

def self.init_easy_object_pool
  20.times do
    easy_object_pool << Typhoeus::Easy.new
  end
end

.perform_easy_requestsObject



48
49
50
51
52
53
54
55
# File 'lib/typhoeus.rb', line 48

def self.perform_easy_requests
  multi = Thread.current[:curl_multi]
  start_time = Time.now
  multi.easy_handles.each do |easy|
    easy.start_time = start_time
  end
  multi.perform
end

.release_easy_object(easy) ⇒ Object



30
31
32
33
# File 'lib/typhoeus.rb', line 30

def self.release_easy_object(easy)
  easy.reset
  easy_object_pool << easy
end