parallel_http 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/parallel_http.rb +7 -7
  2. metadata +1 -1
data/lib/parallel_http.rb CHANGED
@@ -2,7 +2,7 @@ require 'eventmachine'
2
2
  require 'em-http-request'
3
3
 
4
4
  class ParallelHttp
5
- def self.exec requests, options
5
+ def self.exec requests, options={}
6
6
  @@results = []
7
7
  @@request_size = requests.size
8
8
  if EM.reactor_running?
@@ -17,7 +17,7 @@ class ParallelHttp
17
17
  @@results
18
18
  end
19
19
 
20
- def self.exec_result id, result, errors=nil
20
+ def self.exec_result id, result, error=nil
21
21
  body = ''
22
22
  if RUBY_VERSION.to_f < 1.9
23
23
  body = Iconv.iconv('UTF-8//IGNORE', 'UTF-8', result.response)
@@ -33,18 +33,18 @@ class ParallelHttp
33
33
  end
34
34
 
35
35
  def self.single request, options
36
- # puts "making a request #{request[:url]}, #{request[:verb]}, #{request[:options]}"
36
+ puts "making a request #{request[:url]}, #{request[:verb]}, #{request[:options]}"
37
37
  opts = request[:options] || {}
38
38
  http = EventMachine::HttpRequest.new(request[:url], options).send(request[:verb].downcase, opts)
39
39
  http.callback do
40
- @@success = request[:options][:query][:url]
41
- # puts "SUCCESS: #{request[:options][:query][:url]}"
40
+ puts "SUCCESS: #{request[:id]}"
41
+ @@success = request[:id]
42
42
  ParallelHttp.exec_result(request[:id], http)
43
43
  http.close(nil)
44
44
  end
45
45
  http.errback do |h|
46
- if request[:options][:query][:url] != @@success
47
- # puts "FAILURE: #{request[:options][:query][:url]}"
46
+ if @@success != request[:id]
47
+ puts "FAILURE: #{request[:id]}"
48
48
  ParallelHttp.exec_result(request[:id], h, h.error)
49
49
  http.close(nil)
50
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: