polipus 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/polipus/http.rb +14 -2
- data/lib/polipus/version.rb +1 -1
- data/spec/http_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTJkNWMwNzJlMzk1YTZkZTMwM2M3YTM0OTE1MzgyZjkwZWRiNTFiOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTVmZmQ2ZDhkMGQ2ZTk2M2ZmNzYwZTk3YjYzM2I3MTg0ZWRmYTlmMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2MwNWI4ZGFlMDRiODkwYmFlNjE0Y2JmODQxOGU4OTIzYWI4MGM0NjNmOGVj
|
10
|
+
NGZjNzNmMDFkYzg4MzRlZTUxZDE1NzM3ZGRlZDRhNDkzZGI3YjBlMGM5MDQ2
|
11
|
+
ZmIxNzY1M2YzZDc4ZjE4MzFjODIzOWMzYzFhZWE4NTEzNDMwNTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmIzMWNlZGJiZDhiM2VhNGI5YmMyMGRhMDYxMGQ2Yjc4NWNiMjRkMGExMmVm
|
14
|
+
M2NiYjQ3YmIzM2JmZTlhNzRmNjE1YmI4MGE2YzRhNzA0NWIzMjRlYWVkOGQ4
|
15
|
+
ZjBhMzUyNzRlNmU5YmUzZTgxZDI4MDQyMWNlZDMyODYxYjNkM2I=
|
data/lib/polipus/http.rb
CHANGED
@@ -74,14 +74,24 @@ module Polipus
|
|
74
74
|
# The proxy address string
|
75
75
|
#
|
76
76
|
def proxy_host
|
77
|
-
@opts[:
|
77
|
+
return proxy_host_port.first unless @opts[:proxy_host_port].nil?
|
78
|
+
@opts[:proxy_host].respond_to?(:call) ? @opts[:proxy_host].call(self) : @opts[:proxy_host]
|
78
79
|
end
|
79
80
|
|
80
81
|
#
|
81
82
|
# The proxy port
|
82
83
|
#
|
83
84
|
def proxy_port
|
84
|
-
@opts[:
|
85
|
+
return proxy_host_port.last unless @opts[:proxy_host_port].nil?
|
86
|
+
@opts[:proxy_port].respond_to?(:call) ? @opts[:proxy_port].call(self) : @opts[:proxy_port]
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# Shorthand to get proxy info with a single call
|
91
|
+
# It returns an array of ['addr', port]
|
92
|
+
#
|
93
|
+
def proxy_host_port
|
94
|
+
@opts[:proxy_host_port].respond_to?(:call) ? @opts[:proxy_host_port].call(self) : @opts[:proxy_host_port]
|
85
95
|
end
|
86
96
|
|
87
97
|
#
|
@@ -168,6 +178,8 @@ module Polipus
|
|
168
178
|
end
|
169
179
|
|
170
180
|
def refresh_connection(url)
|
181
|
+
proxy_host, proxy_port = proxy_host_port unless @opts[:proxy_host_port].nil?
|
182
|
+
|
171
183
|
http = Net::HTTP.new(url.host, url.port, proxy_host, proxy_port)
|
172
184
|
|
173
185
|
http.read_timeout = read_timeout if !!read_timeout
|
data/lib/polipus/version.rb
CHANGED
data/spec/http_spec.rb
CHANGED
@@ -28,4 +28,26 @@ describe Polipus::HTTP do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
describe 'proxy settings' do
|
32
|
+
it 'should set proxy correctly using a procedure' do
|
33
|
+
http = Polipus::HTTP.new({proxy_host: -> con { "127.0.0.0" }, proxy_port: -> con { 8080 }})
|
34
|
+
http.proxy_host.should eq "127.0.0.0"
|
35
|
+
http.proxy_port.should be 8080
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should set proxy correctly using shorthand method' do
|
39
|
+
http = Polipus::HTTP.new({proxy_host_port: -> con {["127.0.0.0", 8080] }})
|
40
|
+
http.proxy_host_port.should eq ["127.0.0.0", 8080]
|
41
|
+
http.proxy_port.should be 8080
|
42
|
+
http.proxy_host.should eq "127.0.0.0"
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should set proxy settings' do
|
46
|
+
http = Polipus::HTTP.new({proxy_host: "127.0.0.0", proxy_port: 8080 })
|
47
|
+
http.proxy_port.should be 8080
|
48
|
+
http.proxy_host.should eq "127.0.0.0"
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
31
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polipus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Laurita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-bloomfilter
|