cubesmart 0.5.0 → 0.6.0
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 +4 -4
- data/README.md +1 -0
- data/lib/cubesmart/config.rb +44 -0
- data/lib/cubesmart/crawler.rb +2 -0
- data/lib/cubesmart/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85d1ddedfe264f2f4222c108695490f532df6c6e4ca15603793ab238ae252d6a
|
4
|
+
data.tar.gz: 9fa27011d2d71cb6a88ba3d94ea5aa66425d3c16c44a64bb598f550ebaf9e1c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05f744c51f4a5e7f0690e48b04241d74e042aaff8f0463c6ac2464022fd1ebda9fa31163acd342a0f61edb9b580d7fc6872d5cab5a2112ccc537922575d31c56
|
7
|
+
data.tar.gz: 5d264cd65e2a48d0bb2efe3e16aa7992b98c6f1666f74edc94495cba81d5eb156ce9aabd09ead70e0b2024f4e197844da0456e7778d4d5206c505b6f2aa536ec
|
data/README.md
CHANGED
@@ -20,6 +20,7 @@ require 'cubesmart'
|
|
20
20
|
CubeSmart.configure do |config|
|
21
21
|
config.user_agent = '../..' # ENV['CUBESMART_USER_AGENT']
|
22
22
|
config.timeout = 30 # ENV['CUBESMART_TIMEOUT']
|
23
|
+
config.proxy_url = 'http://user:pass@superproxy.zenrows.com:1337' # ENV['CUBESMART_PROXY_URL']
|
23
24
|
end
|
24
25
|
```
|
25
26
|
|
data/lib/cubesmart/config.rb
CHANGED
@@ -11,9 +11,53 @@ module CubeSmart
|
|
11
11
|
# @return [Integer]
|
12
12
|
attr_accessor :timeout
|
13
13
|
|
14
|
+
# @attribute [rw] proxy_url
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :proxy_url
|
17
|
+
|
14
18
|
def initialize
|
15
19
|
@user_agent = ENV.fetch('CUBESMART_USER_AGENT', "cubesmart.rb/#{VERSION}")
|
16
20
|
@timeout = Integer(ENV.fetch('CUBESMART_TIMEOUT', 60))
|
21
|
+
@proxy_url = ENV.fetch('CUBESMART_PROXY_URL', nil)
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Boolean]
|
25
|
+
def proxy?
|
26
|
+
!@proxy_url.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [URI]
|
30
|
+
def proxy_uri
|
31
|
+
@proxy_uri ||= URI.parse(proxy_url) if proxy?
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Integer]
|
35
|
+
def proxy_port
|
36
|
+
proxy_uri&.port
|
37
|
+
end
|
38
|
+
|
39
|
+
def proxy_host
|
40
|
+
proxy_uri&.host
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [String]
|
44
|
+
def proxy_scheme
|
45
|
+
proxy_uri&.scheme
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String]
|
49
|
+
def proxy_username
|
50
|
+
proxy_uri&.user
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [String]
|
54
|
+
def proxy_password
|
55
|
+
proxy_uri&.password
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [Array]
|
59
|
+
def proxy_options
|
60
|
+
[proxy_host, proxy_port, proxy_username, proxy_password]
|
17
61
|
end
|
18
62
|
end
|
19
63
|
end
|
data/lib/cubesmart/crawler.rb
CHANGED
@@ -27,6 +27,8 @@ module CubeSmart
|
|
27
27
|
connection = HTTP.persistent(HOST)
|
28
28
|
connection = connection.headers('User-Agent' => config.user_agent) if config.user_agent
|
29
29
|
connection = connection.timeout(config.timeout) if config.timeout
|
30
|
+
connection = connection.via(*config.proxy_options) if config.proxy?
|
31
|
+
|
30
32
|
connection
|
31
33
|
end
|
32
34
|
end
|
data/lib/cubesmart/version.rb
CHANGED