Class: Blinkr::TyphoeusWrapper
- Inherits:
-
Object
- Object
- Blinkr::TyphoeusWrapper
- Includes:
- HttpUtils
- Defined in:
- lib/blinkr/typhoeus_wrapper.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#hydra ⇒ Object
readonly
Returns the value of attribute hydra.
Instance Method Summary collapse
- #debug(url) ⇒ Object
-
#initialize(config, context) ⇒ TyphoeusWrapper
constructor
A new instance of TyphoeusWrapper.
- #name ⇒ Object
- #process(url, limit, &block) ⇒ Object
- #process_all(urls, limit, &block) ⇒ Object
Methods included from HttpUtils
Constructor Details
#initialize(config, context) ⇒ TyphoeusWrapper
Returns a new instance of TyphoeusWrapper.
14 15 16 17 18 19 |
# File 'lib/blinkr/typhoeus_wrapper.rb', line 14 def initialize config, context @config = config.validate @hydra = Typhoeus::Hydra.new(max_concurrency: 200) @count = 0 @context = context end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
12 13 14 |
# File 'lib/blinkr/typhoeus_wrapper.rb', line 12 def count @count end |
#hydra ⇒ Object (readonly)
Returns the value of attribute hydra.
12 13 14 |
# File 'lib/blinkr/typhoeus_wrapper.rb', line 12 def hydra @hydra end |
Instance Method Details
#debug(url) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/blinkr/typhoeus_wrapper.rb', line 31 def debug url process(url, @config.max_retrys) do |resp| puts "\n++++++++++" puts "+ Blinkr +" puts "++++++++++" puts "\nRequest" puts "=======" puts "Method: #{resp.request.options[:method]}" puts "Max redirects: #{resp.request.options[:maxredirs]}" puts "Follow location header: #{resp.request.options[:followlocation]}" puts "Timeout (s): #{resp.request.options[:timeout] || 'none'}" puts "Connection timeout (s): #{resp.request.options[:connecttimeout] || 'none'}" puts "\nHeaders" puts "-------" unless resp.request.[:headers].nil? resp.request.[:headers].each do |name, value| puts "#{name}: #{value}" end end puts "\nResponse" puts "========" puts "Status Code: #{resp.code}" puts "Status Message: #{resp.status_message}" puts "Message: #{resp.return_message}" unless resp..nil? || resp. == 'No error' puts "\nHeaders" puts "-------" puts resp.response_headers end @hydra.run end |
#name ⇒ Object
62 63 64 |
# File 'lib/blinkr/typhoeus_wrapper.rb', line 62 def name 'typhoeus' end |
#process(url, limit, &block) ⇒ Object
27 28 29 |
# File 'lib/blinkr/typhoeus_wrapper.rb', line 27 def process url, limit, &block _process url, limit, limit, &block end |
#process_all(urls, limit, &block) ⇒ Object
21 22 23 24 25 |
# File 'lib/blinkr/typhoeus_wrapper.rb', line 21 def process_all urls, limit, &block urls.each do |url| process url, limit, &block end end |