http_utilities 1.2.6.4 → 1.2.6.5
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7098ab59c66af8e70c2cf0f229fdb93d83750f12
|
4
|
+
data.tar.gz: 70f746d614bc0f88f30aba9f6c7aebfea69a1c66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb0cd53269182cc43b9e33c466ffa8b5433e3cc6114cbedd200b2646acd15780e334ecc5b74ebb341749673053155be2c043cf96ce2972e9bd1207a342d46d29
|
7
|
+
data.tar.gz: 51476cc914528b81b40a68db2fa88858fb568ce482ebc87ac3db0a0969eba4b8222f2c5f4ff357b3bf24427c8e50aed3887a97f82aae9a61aace157b4815beb2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.6.
|
1
|
+
1.2.6.5
|
data/http_utilities.gemspec
CHANGED
@@ -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.2.6.
|
6
|
+
s.version = "1.2.6.5"
|
7
7
|
|
8
8
|
s.authors = ["Sebastian Johnsson"]
|
9
9
|
s.description = "Wrapper for Faraday with additional functionality"
|
data/lib/http_utilities.rb
CHANGED
@@ -31,10 +31,14 @@ module HttpUtilities
|
|
31
31
|
return proxies
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def get_valid_proxies(protocol: :all, proxy_type: :all, maximum_failed_attempts: nil, retries: 3)
|
35
35
|
proxies = get_proxies_for_protocol_and_proxy_type(protocol, proxy_type)
|
36
36
|
proxies = proxies.where(valid_proxy: true)
|
37
37
|
proxies = proxies.where(:failed_attempts.lte => maximum_failed_attempts) if maximum_failed_attempts
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_random_proxy(protocol: :all, proxy_type: :all, maximum_failed_attempts: nil, retries: 3)
|
41
|
+
proxies = get_valid_proxies(protocol: protocol, proxy_type: proxy_type, maximum_failed_attempts: maximum_failed_attempts)
|
38
42
|
proxy = nil
|
39
43
|
|
40
44
|
begin
|
@@ -20,10 +20,16 @@ module HttpUtilities
|
|
20
20
|
return proxies
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def get_valid_proxies(protocol: :all, proxy_type: :all, maximum_failed_attempts: nil)
|
24
24
|
proxies = get_proxies_for_protocol_and_proxy_type(protocol, proxy_type)
|
25
25
|
proxies = proxies.where(["valid_proxy = ? AND last_checked_at IS NOT NULL", true])
|
26
26
|
proxies = proxies.where(["failed_attempts <= ?", maximum_failed_attempts]) if maximum_failed_attempts
|
27
|
+
|
28
|
+
return proxies
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_random_proxy(protocol: :all, proxy_type: :all, maximum_failed_attempts: nil)
|
32
|
+
proxies = get_valid_proxies(protocol: protocol, proxy_type: proxy_type, maximum_failed_attempts: maximum_failed_attempts)
|
27
33
|
|
28
34
|
order_clause = case ActiveRecord::Base.connection.class.name
|
29
35
|
when "ActiveRecord::ConnectionAdapters::MysqlAdapter", "ActiveRecord::ConnectionAdapters::Mysql2Adapter"
|
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.2.6.
|
4
|
+
version: 1.2.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Johnsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|