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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4632b3c1c352b868287bc92291fb0535ee9bf4b0c419a9501cdf60ebc4ca272c
4
- data.tar.gz: 9839c357de5c6337185a84592f626bd8e39b1effc586dacf9a1685dc05474bed
3
+ metadata.gz: 85d1ddedfe264f2f4222c108695490f532df6c6e4ca15603793ab238ae252d6a
4
+ data.tar.gz: 9fa27011d2d71cb6a88ba3d94ea5aa66425d3c16c44a64bb598f550ebaf9e1c8
5
5
  SHA512:
6
- metadata.gz: 43f365fb2584f00de5dce8ecb4199fdb8659db50c2b59a61d0f0891b58b099403a65e0fd0c8b1b8e4bb58b72fb82c2b30590951a9d597f99b82466806f9b7ce2
7
- data.tar.gz: 3fc196914dde673a3e95111204a1ba1d282ccc3d0d4fe99db571cb2a646f4ccd125dc38b454ee4a4221e9875229a40a038694fe6066d384b0165547dacb07966
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
 
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CubeSmart
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cubesmart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre