proxy_fetcher 0.1.3 → 0.1.4

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: 5350053943ea06b5eea6f0aae059ae35cda79350
4
- data.tar.gz: 8fa58f71797bb165c06d6f8508058c92273b5e8b
3
+ metadata.gz: 9b5976adc9dfa09ec920347577b06e900c094a6d
4
+ data.tar.gz: 1ffb7978312183ffffe89ec596426e2c64a4d51f
5
5
  SHA512:
6
- metadata.gz: 6a137676022ff0ed952383ce6868d2104c18c5ddb2389819525b20f00a97e00c43a2ff4f1366c5125ee8cd6224aa759299f2946e1634eaf2bafe2c705c50f050
7
- data.tar.gz: 02ea4aa5f43892386fa4f50ea2fff7b7db432790aef2bcfb42ffa49e6940b97b150ab15a08bc4397d0f49699e3f1908e63a72a66b58b6bd188bfbc0ddd80fe40
6
+ metadata.gz: 0b65e73a438263f073e344550a87f438c0045f5b521b3e063c292a72838cbbf8a316b48dc0d47aacba797fb3a7244db03cbe8288e78f104a1681ad402fcd3a59
7
+ data.tar.gz: 2983502c4ba43fe5db8b9496f4ee973c78c13eb0fb4d8cd8dfafc21bd96568a19724423d8f517ff2f239c5742d764ac1c256463455624c96d43067e18f964716
data/lib/proxy_fetcher.rb CHANGED
@@ -39,6 +39,8 @@ module ProxyFetcher
39
39
 
40
40
  # Pop just first proxy (and back it to the end of the proxy list)
41
41
  def get
42
+ return if @proxies.empty?
43
+
42
44
  first_proxy = @proxies.shift
43
45
  @proxies << first_proxy
44
46
 
@@ -51,7 +53,7 @@ module ProxyFetcher
51
53
  # Invalid proxies will be removed from the list
52
54
  def get!
53
55
  index = @proxies.find_index(&:connectable?)
54
- return if index < 0
56
+ return if index.nil?
55
57
 
56
58
  proxy = @proxies.delete_at(index)
57
59
  tail = @proxies[index..-1]
@@ -9,7 +9,7 @@ module ProxyFetcher
9
9
  # Minor version number
10
10
  MINOR = 1
11
11
  # Smallest version number
12
- TINY = 3
12
+ TINY = 4
13
13
 
14
14
  # Full version number
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
@@ -61,4 +61,11 @@ describe ProxyFetcher::Manager do
61
61
  expect(manager.get!).to eq(connectable_proxy)
62
62
  expect(manager.proxies.size).to be(1)
63
63
  end
64
+
65
+ it 'returns nothing if proxy list is empty' do
66
+ manager = described_class.new(refresh: false)
67
+
68
+ expect(manager.get).to be_nil
69
+ expect(manager.get!).to be_nil
70
+ end
64
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_fetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Bulai