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 +4 -4
- data/lib/proxy_fetcher.rb +3 -1
- data/lib/proxy_fetcher/version.rb +1 -1
- data/spec/proxy_fetcher/manager_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b5976adc9dfa09ec920347577b06e900c094a6d
|
4
|
+
data.tar.gz: 1ffb7978312183ffffe89ec596426e2c64a4d51f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
56
|
+
return if index.nil?
|
55
57
|
|
56
58
|
proxy = @proxies.delete_at(index)
|
57
59
|
tail = @proxies[index..-1]
|
@@ -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
|