vagrant_cloud 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vagrant_cloud/client.rb +21 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4768031887b3a27585e8cf55091810654545e2aee475d7e2b2dbff927e8c7d6f
4
- data.tar.gz: 480e6a69c2eac82185ff3cd9d90a30f00cd26e4a7d45c548ed2ba2785ecef96d
3
+ metadata.gz: 06ac337d41c05fa0ab3f4dba19eb4b48369b7b21e87adea9beaf22c24d7a06ec
4
+ data.tar.gz: 20c9e7e4c6c6a045a34a5509e05e626a159069d76993d3f70bdf2f333a219083
5
5
  SHA512:
6
- metadata.gz: 7343ea8f89e7e4ecb8f9f2e0f1f5478a37382e3c4de44bb61ec40fcebd18b5e65f302365cfa02aead507d28883a3ab561bf3af949f77418e46366043ee7eddea
7
- data.tar.gz: 50b74d2dcf7f8671afa67bfec5d0fdeebdf40b51206a48f53a35f21b63f65674e1859bcdcaeb2f9d79e940870df50c75b4e6fc9b412b86b1c028bcac9c9f2bcd
6
+ metadata.gz: 0c4fd65d40092ff9161d5330afda571efc2d852b23aedf7f8327d803eb2e096792999ebb3f69dd3cbce4663d5c6b79db121531737258084e18c634f626d25d35
7
+ data.tar.gz: 69eb59e4a61257533baf2707b998b29a6f88f8b37a4c54f6dea8daca3f19e0c93d479d68ae42a277f1ee3c972622625b380fbd7f5db9bfd8e212a583fa706118
@@ -49,7 +49,7 @@ module VagrantCloud
49
49
  remote_url = URI.parse(url_base)
50
50
  @url_base = "#{remote_url.scheme}://#{remote_url.host}"
51
51
  @path_base = remote_url.path
52
- if @path_base == API_V1_PATH || @path_base == API_V2_PATH
52
+ if @path_base.empty? || @path_base == API_V1_PATH || @path_base == API_V2_PATH
53
53
  @path_base = nil
54
54
  end
55
55
  @access_token = access_token.dup.freeze if access_token
@@ -98,19 +98,28 @@ module VagrantCloud
98
98
  # @param [Hash] params Parameters to send with request
99
99
  # @return [Hash]
100
100
  def request(path:, method: :get, params: {}, api_version: 2)
101
- if path_base.nil? || !path.start_with?(path_base)
102
- if !path_base.nil?
103
- start_path = path_base
104
- elsif api_version == 1
105
- start_path = API_V1_PATH
106
- elsif api_version == 2
107
- start_path = API_V2_PATH
108
- else
109
- raise "Unsupported API version provided"
101
+ # Apply any path modifications that are required
102
+ catch(:done) do
103
+ # If a base path is defined, and the provided path
104
+ # is already properly prefixed with it, do nothing.
105
+ throw :done if !path_base.nil? && path.start_with?(path_base)
106
+
107
+ # If the path does not include an API version
108
+ # prefix, add it now.
109
+ if !path.start_with?(API_V1_PATH) && !path.start_with?(API_V2_PATH)
110
+ case api_version
111
+ when 1
112
+ start_path = API_V1_PATH
113
+ when 2
114
+ start_path = API_V2_PATH
115
+ else
116
+ raise ArgumentError, "Unsupported API version provided"
117
+ end
110
118
  end
111
- # Build the full path for the request and clean it
112
- path = [start_path, path].compact.join("/").gsub(/\/{2,}/, "/")
119
+
120
+ path = [path_base, start_path, path].compact.join("/").gsub(/\/{2,}/, "/")
113
121
  end
122
+
114
123
  method = method.to_s.downcase.to_sym
115
124
 
116
125
  # Build base request parameters
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - HashiCorp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-25 00:00:00.000000000 Z
12
+ date: 2024-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon