cubesmart 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85d1ddedfe264f2f4222c108695490f532df6c6e4ca15603793ab238ae252d6a
4
- data.tar.gz: 9fa27011d2d71cb6a88ba3d94ea5aa66425d3c16c44a64bb598f550ebaf9e1c8
3
+ metadata.gz: faf820da6f1fc7571b5558fe7bc2fea1471f180485cfa1d6433aa5163ae0f613
4
+ data.tar.gz: 41b35c9acf309ee0439794ba50322c4e7bca51efcf1827dd6cc6bb4a68fc235d
5
5
  SHA512:
6
- metadata.gz: 05f744c51f4a5e7f0690e48b04241d74e042aaff8f0463c6ac2464022fd1ebda9fa31163acd342a0f61edb9b580d7fc6872d5cab5a2112ccc537922575d31c56
7
- data.tar.gz: 5d264cd65e2a48d0bb2efe3e16aa7992b98c6f1666f74edc94495cba81d5eb156ce9aabd09ead70e0b2024f4e197844da0456e7778d4d5206c505b6f2aa536ec
6
+ metadata.gz: 69bc03009bd047ed9e46e5b9747e214b7955b91bbcde1cb208b6a52c035769888376143abcd333c478bdb1b1a80594e3eabb1b3bcabd317f06cd037c24886127
7
+ data.tar.gz: 73b9a9ffa0e8aabf140a4be5f1ffcdbe8b7dae833ee2f39ed835cdb2b72239813c83232607c3db376d05ddd88df7b7ea2ad795ce18ac8b50f43054e656d412d6
@@ -3,6 +3,10 @@
3
3
  module CubeSmart
4
4
  # The core configuration.
5
5
  class Config
6
+ # @attribute [rw] accept_language
7
+ # @return [String]
8
+ attr_accessor :accept_language
9
+
6
10
  # @attribute [rw] user_agent
7
11
  # @return [String]
8
12
  attr_accessor :user_agent
@@ -16,48 +20,39 @@ module CubeSmart
16
20
  attr_accessor :proxy_url
17
21
 
18
22
  def initialize
23
+ @accept_language = ENV.fetch('CUBESMART_ACCEPT_LANGUAGE', 'en-US,en;q=0.9')
19
24
  @user_agent = ENV.fetch('CUBESMART_USER_AGENT', "cubesmart.rb/#{VERSION}")
20
25
  @timeout = Integer(ENV.fetch('CUBESMART_TIMEOUT', 60))
21
26
  @proxy_url = ENV.fetch('CUBESMART_PROXY_URL', nil)
22
27
  end
23
28
 
24
29
  # @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
30
+ def headers?
31
+ !@user_agent.nil?
41
32
  end
42
33
 
43
- # @return [String]
44
- def proxy_scheme
45
- proxy_uri&.scheme
34
+ # @return [Boolean]
35
+ def timeout?
36
+ !@timeout.zero?
46
37
  end
47
38
 
48
- # @return [String]
49
- def proxy_username
50
- proxy_uri&.user
39
+ # @return [Boolean]
40
+ def proxy?
41
+ !@proxy_url.nil?
51
42
  end
52
43
 
53
- # @return [String]
54
- def proxy_password
55
- proxy_uri&.password
44
+ # @return [Hash<String, String>] e.g { 'User-Agent' => 'cubesmart.rb/1.0.0' }
45
+ def headers
46
+ {
47
+ 'Accept-Language' => @accept_language,
48
+ 'User-Agent' => @user_agent
49
+ }
56
50
  end
57
51
 
58
- # @return [Array]
59
- def proxy_options
60
- [proxy_host, proxy_port, proxy_username, proxy_password]
52
+ # @return [Array] e.g. ['proxy.example.com', 8080, 'user', 'pass']
53
+ def via
54
+ proxy_uri = URI.parse(@proxy_url)
55
+ [proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password]
61
56
  end
62
57
  end
63
58
  end
@@ -24,10 +24,10 @@ module CubeSmart
24
24
  @connection ||= begin
25
25
  config = CubeSmart.config
26
26
 
27
- connection = HTTP.persistent(HOST)
28
- connection = connection.headers('User-Agent' => config.user_agent) if config.user_agent
29
- connection = connection.timeout(config.timeout) if config.timeout
30
- connection = connection.via(*config.proxy_options) if config.proxy?
27
+ connection = HTTP.use(:auto_deflate).use(:auto_inflate).persistent(HOST)
28
+ connection = connection.headers(config.headers) if config.headers?
29
+ connection = connection.timeout(config.timeout) if config.timeout?
30
+ connection = connection.via(*config.via) if config.proxy?
31
31
 
32
32
  connection
33
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CubeSmart
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cubesmart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-05 00:00:00.000000000 Z
11
+ date: 2024-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http