polipus 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjU0MmViNGYzZWVjNDBkOTI1MDMwNjRlMTE0ZDVmN2RjODc4MGI2Mw==
4
+ ZTJkNWMwNzJlMzk1YTZkZTMwM2M3YTM0OTE1MzgyZjkwZWRiNTFiOQ==
5
5
  data.tar.gz: !binary |-
6
- YjQ3OTZmMThiNjI3ZTRiNTUxNWFlZjA1MGFiOGRhZTcxYzdiYTY0Ng==
6
+ YTVmZmQ2ZDhkMGQ2ZTk2M2ZmNzYwZTk3YjYzM2I3MTg0ZWRmYTlmMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Zjc0N2Q2NmM3Yzg0OTg5NTEwYjg2N2Q5ODk5ZjU2OWQzZWQyMzEwNjk4NmJi
10
- NzAxYzFlNDhhZGE1YzA0MGFiYjJiOWVlZThhMTFmZTM0YzAxZDE0MWE4MzAw
11
- NjU5NWI5OThjNWE2ZWMzNThmNDU5MmZkY2Q0ODAzNDdkYmNjOTU=
9
+ Y2MwNWI4ZGFlMDRiODkwYmFlNjE0Y2JmODQxOGU4OTIzYWI4MGM0NjNmOGVj
10
+ NGZjNzNmMDFkYzg4MzRlZTUxZDE1NzM3ZGRlZDRhNDkzZGI3YjBlMGM5MDQ2
11
+ ZmIxNzY1M2YzZDc4ZjE4MzFjODIzOWMzYzFhZWE4NTEzNDMwNTI=
12
12
  data.tar.gz: !binary |-
13
- ZWQ0MzFiMWYxNGRkNzAxM2FmZmFlYmVmNDljYTJjOGQxZGU4NjZjYTQ1ZjZi
14
- ZDU3ZGNjMDc4Njg1MzJkMjFjYjQwYjZjNGNlNTk2ODBjN2MxMTI1ZGMwY2Ix
15
- NjM4ZWFlY2U1NWYzZGE0NjFjNWZlYWE5Y2Y2NTA4ODk3NTIwMzU=
13
+ NmIzMWNlZGJiZDhiM2VhNGI5YmMyMGRhMDYxMGQ2Yjc4NWNiMjRkMGExMmVm
14
+ M2NiYjQ3YmIzM2JmZTlhNzRmNjE1YmI4MGE2YzRhNzA0NWIzMjRlYWVkOGQ4
15
+ ZjBhMzUyNzRlNmU5YmUzZTgxZDI4MDQyMWNlZDMyODYxYjNkM2I=
@@ -74,14 +74,24 @@ module Polipus
74
74
  # The proxy address string
75
75
  #
76
76
  def proxy_host
77
- @opts[:proxy_host]
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[:proxy_port]
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
@@ -1,4 +1,4 @@
1
1
  module Polipus
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  HOMEPAGE = "https://github.com/taganaka/polipus"
4
4
  end
@@ -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.3
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-03-17 00:00:00.000000000 Z
11
+ date: 2014-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-bloomfilter