http_utilities 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: decfb9fe1f727937094df0974e3629ad5ca1f5f244e10d5a8e23044e189a266a
4
- data.tar.gz: edaa2d78def545bd34fd3bce759b645da7ee778a84aa3fe51a6165a5fe3a0d3f
3
+ metadata.gz: 24370403c5f8396cac1f6fbf76af2bfce33b594d494725f11f4b7dd7e54763a5
4
+ data.tar.gz: f0e387ec4cfc14c5caa1edf1041c393b0b1aec7a2242fd666e5a595e843522ea
5
5
  SHA512:
6
- metadata.gz: 13a753076e2eba04b84cdbf5b75f939740fea97dd9e39f33d4fe49308fb2bc107d26f5af707c7e77150df432348bf10038a1d5d6d204c8b66a7c064c078f788d
7
- data.tar.gz: c6f2e4ad1e670c8df318356cec55ad535984acb6c26c7ed425449a58c70acdf592fa4b4a8efa24469ed27b683e425a0ce191ee93d4d3e1a9b4fd20401c751a76
6
+ metadata.gz: 82c7226e7d4d2a7aa535e86bc6f19f83bfc9a2d127ae2c33ee7ff417dbb53f10ddf3ef5148560e7b9241c37dcd2536c3aadd7df9fda5b9a2c41b49737a3bba9e
7
+ data.tar.gz: c227b8881310827ab34b7ab3a4c50c118c668021afccd8573010c4be89067104a5d15d3d5d6a8bb24bcb7c6caf4a8cd4ee2850c570162fbb91995a9f9a466086
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.2
1
+ 1.3.3
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = "http_utilities"
6
- s.version = "1.3.2"
6
+ s.version = "1.3.3"
7
7
 
8
8
  s.authors = ["Sebastian Johnsson"]
9
9
  s.description = "Wrapper for Faraday with additional functionality"
@@ -56,7 +56,7 @@ module HttpUtilities
56
56
  request.set_proxy_options(options)
57
57
 
58
58
  proxy_options = request.generate_proxy_options
59
- client_options = client_options.merge(proxy: proxy_options) unless proxy_options.empty?
59
+ client_options = client_options.merge(proxy: proxy_options) if proxy_options && !proxy_options.empty?
60
60
 
61
61
  connection = Faraday.new(client_options) do |builder|
62
62
  builder.headers[:user_agent] = request.user_agent
@@ -14,8 +14,7 @@ module HttpUtilities
14
14
  proxy_protocol = options.fetch(:proxy_protocol, :all)
15
15
 
16
16
  if use_proxy || specific_proxy
17
- self.proxy[:protocol] = proxy_protocol
18
- self.proxy[:type] = proxy_type
17
+ self.proxy ||= {}
19
18
 
20
19
  if specific_proxy && specific_proxy.is_a?(String)
21
20
  specific_proxy = specific_proxy.gsub(/^http(s)?:\/\//i, "")
@@ -34,7 +33,7 @@ module HttpUtilities
34
33
  if specific_proxy && specific_proxy.is_a?(::Proxy)
35
34
  proxy_object = specific_proxy
36
35
  else
37
- proxy_object = ::Proxy.get_random_proxy(protocol: self.proxy[:protocol], proxy_type: self.proxy[:type])
36
+ proxy_object = ::Proxy.get_random_proxy(protocol: proxy_protocol, proxy_type: proxy_type)
38
37
  end
39
38
 
40
39
  #log(:info, "[HttpUtilities::Http::ProxySupport] - Randomized Proxy object: #{proxy_object.inspect}")
@@ -42,13 +41,13 @@ module HttpUtilities
42
41
  if proxy_object
43
42
  self.proxy[:host] = proxy_object.host
44
43
  self.proxy[:port] = proxy_object.port
45
- proxy_username = proxy_object.username.present? ? proxy_object.username : nil
46
- proxy_password = proxy_object.password.present? ? proxy_object.password : nil
44
+ proxy_username = !proxy_object.username.to_s.empty? ? proxy_object.username : nil
45
+ proxy_password = !proxy_object.password.to_s.empty? ? proxy_object.password : nil
47
46
  end
48
47
  end
48
+
49
+ set_proxy_credentials(proxy_username, proxy_password, proxy_credentials)
49
50
  end
50
-
51
- set_proxy_credentials(proxy_username, proxy_password, proxy_credentials)
52
51
  end
53
52
 
54
53
  def set_proxy_credentials(proxy_username, proxy_password, proxy_credentials)
@@ -73,22 +72,24 @@ module HttpUtilities
73
72
  end
74
73
 
75
74
  def proxy_model_defined?
76
- defined = Module.const_get("Proxy").is_a?(Class) rescue false
77
- defined = (defined && ::Proxy.respond_to?(:get_random_proxy))
75
+ defined = Module.const_get("Proxy").is_a?(Class) rescue false
76
+ defined = (defined && ::Proxy.respond_to?(:get_random_proxy))
78
77
 
79
78
  return defined
80
79
  end
81
80
 
82
81
  def generate_proxy_options
83
- proxy_options = {}
82
+ proxy_options = {}
84
83
 
85
- proxy_options[:uri] = "http://#{self.proxy[:host]}:#{self.proxy[:port]}"
86
- proxy_options[:user] = self.proxy[:username] if self.proxy[:username] && !self.proxy[:username].empty?
87
- proxy_options[:password] = self.proxy[:password] if self.proxy[:password] && !self.proxy[:password].empty?
84
+ if !self.proxy[:host].to_s.empty? && !self.proxy[:port].to_s.empty?
85
+ proxy_options[:uri] = "http://#{self.proxy[:host]}:#{self.proxy[:port]}"
86
+ proxy_options[:user] = self.proxy[:username] if !self.proxy[:username].to_s.empty?
87
+ proxy_options[:password] = self.proxy[:password] if !self.proxy[:password].to_s.empty?
88
+ end
88
89
 
89
90
  return proxy_options
90
91
  end
91
92
 
92
93
  end
93
94
  end
94
- end
95
+ end
@@ -7,7 +7,7 @@ module HttpUtilities
7
7
 
8
8
  attr_accessor :interface, :proxy, :user_agent
9
9
 
10
- def initialize(interface: nil, proxy: {}, options: {})
10
+ def initialize(interface: nil, proxy: nil, options: {})
11
11
  self.interface = interface
12
12
  self.proxy = proxy
13
13
 
@@ -16,4 +16,4 @@ module HttpUtilities
16
16
 
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -5,7 +5,7 @@ require "faraday_middleware"
5
5
  require "mechanize"
6
6
 
7
7
  module HttpUtilities
8
- VERSION = "1.3.2"
8
+ VERSION = "1.3.3"
9
9
 
10
10
  require File.join(File.dirname(__FILE__), 'http_utilities/railtie') if defined?(Rails)
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Johnsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-15 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday