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: 6eb54128846f78c91dd63f9221875fb5ca98f37f
4
- data.tar.gz: d4ab2b392a6cdf4a406604d35dc84854595f1519
3
+ metadata.gz: 7098ab59c66af8e70c2cf0f229fdb93d83750f12
4
+ data.tar.gz: 70f746d614bc0f88f30aba9f6c7aebfea69a1c66
5
5
  SHA512:
6
- metadata.gz: 5d42594d216558d795623e67e759fa2e2f4a18b882b103135982c7c0c59ba061d3865ffb76d3754e8049e8076c8ce21c3b6e48e514b2cd3fdf5b9341ad3a2c11
7
- data.tar.gz: 5e53cb6f55d095fd077941d48284257211a782b103befadfc1d409c10825dd2d0228a5c7647e3d3aeb4bfdde229928013ac086c108873d44d096feecf28651a6
6
+ metadata.gz: fb0cd53269182cc43b9e33c466ffa8b5433e3cc6114cbedd200b2646acd15780e334ecc5b74ebb341749673053155be2c043cf96ce2972e9bd1207a342d46d29
7
+ data.tar.gz: 51476cc914528b81b40a68db2fa88858fb568ce482ebc87ac3db0a0969eba4b8222f2c5f4ff357b3bf24427c8e50aed3887a97f82aae9a61aace157b4815beb2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.6.4
1
+ 1.2.6.5
@@ -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.4"
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"
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module HttpUtilities
3
- VERSION = "1.2.6.4"
3
+ VERSION = "1.2.6.5"
4
4
 
5
5
  require File.join(File.dirname(__FILE__), 'http_utilities/railtie') if defined?(Rails)
6
6
 
@@ -31,10 +31,14 @@ module HttpUtilities
31
31
  return proxies
32
32
  end
33
33
 
34
- def get_random_proxy(protocol: :all, proxy_type: :all, maximum_failed_attempts: nil, retries: 3)
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 get_random_proxy(protocol: :all, proxy_type: :all, maximum_failed_attempts: nil)
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
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-07-17 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday