vagrant_cloud 0.4.1 → 0.4.2

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
  SHA1:
3
- metadata.gz: 6f775de1cb62e00b46563d91fac4dd85dec7c55c
4
- data.tar.gz: 3dda5f311191047248d72c56477adfc16ccb425f
3
+ metadata.gz: 655b657611c9e2117dfba4baf196bf3c0a6bea0f
4
+ data.tar.gz: ef550822667b5fcb60b2c2b62d8bff3a21abc3f0
5
5
  SHA512:
6
- metadata.gz: d64b1d9e391b675dd2fd5fc61abe9293558b9f42b30abeb90c3ed8ff761e940e38881f16098860581378ff681b322b2d62d74d77af8a198d2cf2ededc0f7391d
7
- data.tar.gz: 58c5acdae88765dff652da9756cab38a79a02d7d7d626ee4df0f84fee1a75401648cef4c2fbf6f9fd6c66f272488a770bff0c291358cbe0f4ab9730b901c8e59
6
+ metadata.gz: 2599abbfafadf62808ff6753033c1bdd5f12e30261083cca5ecddb41312c2d6a7da6feb905e9d211aba44c9d1e1d6f32cd6c3ccba123e66a0da847e9e92c9276
7
+ data.tar.gz: e23e005d8a806d6741b3ac913596ff99b557a97dd177495c9393b69edbef6f46b8c6fe63a9e0465e78b459afd65b25265ab95274d23e9ec0eee2c6130dcd5b1a
@@ -1,7 +1,5 @@
1
1
  module VagrantCloud
2
-
3
2
  class Account
4
-
5
3
  attr_accessor :username
6
4
  attr_accessor :access_token
7
5
 
@@ -26,7 +24,7 @@ module VagrantCloud
26
24
  params = box_params(*args)
27
25
  params[:name] = name
28
26
 
29
- data = request('post', '/boxes', {:box => params})
27
+ data = request('post', '/boxes', box: params)
30
28
  get_box(name, data)
31
29
  end
32
30
 
@@ -47,9 +45,9 @@ module VagrantCloud
47
45
 
48
46
  # Select elements from params that don't match what we have in the box
49
47
  # data. These are changed parameters and should be updated.
50
- update_params = params.select { |k,v|
48
+ update_params = params.select do |k, v|
51
49
  box.data[box.param_name(k)] != v
52
- }
50
+ end
53
51
 
54
52
  # Update the box with any params that had changed.
55
53
  box.update(update_params) unless update_params.empty?
@@ -64,14 +62,14 @@ module VagrantCloud
64
62
  def request(method, path, params = {})
65
63
  params[:access_token] = access_token
66
64
  result = RestClient::Request.execute(
67
- :method => method,
68
- :url => url_base + path,
69
- :payload => params,
70
- :ssl_version => 'TLSv1'
65
+ method: method,
66
+ url: url_base + path,
67
+ payload: params,
68
+ ssl_version: 'TLSv1'
71
69
  )
72
70
  result = JSON.parse(result)
73
71
  errors = result['errors']
74
- raise(RuntimeError, "Vagrant Cloud returned error: #{errors}") if errors
72
+ raise "Vagrant Cloud returned error: #{errors}" if errors
75
73
  result
76
74
  end
77
75
 
@@ -103,10 +101,9 @@ module VagrantCloud
103
101
  end
104
102
 
105
103
  # Default boxes to public can be overridden by providing :is_private
106
- params[:is_private] = false unless params.has_key?(:is_private)
104
+ params[:is_private] = false unless params.key?(:is_private)
107
105
 
108
106
  params
109
107
  end
110
-
111
108
  end
112
109
  end
@@ -1,7 +1,5 @@
1
1
  module VagrantCloud
2
-
3
2
  class Box
4
-
5
3
  attr_accessor :account
6
4
  attr_accessor :name
7
5
  attr_accessor :data
@@ -43,7 +41,7 @@ module VagrantCloud
43
41
 
44
42
  # @param [Hash] args
45
43
  def update(args = {})
46
- @data = account.request('put', "/box/#{account.username}/#{name}", {:box => args})
44
+ @data = account.request('put', "/box/#{account.username}/#{name}", box: args)
47
45
  end
48
46
 
49
47
  def delete
@@ -61,9 +59,9 @@ module VagrantCloud
61
59
  # @param [String] description
62
60
  # @return [Version]
63
61
  def create_version(name, description = nil)
64
- params = {:version => name}
62
+ params = { version: name }
65
63
  params[:description] = description if description
66
- data = account.request('post', "/box/#{account.username}/#{self.name}/versions", {:version => params})
64
+ data = account.request('post', "/box/#{account.username}/#{self.name}/versions", version: params)
67
65
  get_version(data['number'], data)
68
66
  end
69
67
 
@@ -72,10 +70,8 @@ module VagrantCloud
72
70
  # @return [Version]
73
71
  def ensure_version(name, description = nil)
74
72
  version = versions.select { |version| version.version == name }.first
75
- unless version
76
- version = create_version(name, description)
77
- end
78
- if description and (description != version.description)
73
+ version = create_version(name, description) unless version
74
+ if description && (description != version.description)
79
75
  version.update(description)
80
76
  end
81
77
  version
@@ -94,8 +90,8 @@ module VagrantCloud
94
90
  # Vagrant Cloud returns keys different from what you set for some params.
95
91
  # Values in this map should be strings.
96
92
  ATTR_MAP = {
97
- :is_private => 'private',
98
- :description => 'description_markdown',
99
- }
93
+ is_private: 'private',
94
+ description: 'description_markdown'
95
+ }.freeze
100
96
  end
101
97
  end
@@ -1,7 +1,5 @@
1
1
  module VagrantCloud
2
-
3
2
  class Provider
4
-
5
3
  attr_accessor :version
6
4
  attr_accessor :name
7
5
  attr_accessor :data
@@ -32,8 +30,8 @@ module VagrantCloud
32
30
 
33
31
  # @param [String] url
34
32
  def update(url)
35
- params = {:url => url}
36
- @data = account.request('put', "/box/#{account.username}/#{box.name}/version/#{version.number}/provider/#{name}", {:provider => params})
33
+ params = { url: url }
34
+ @data = account.request('put', "/box/#{account.username}/#{box.name}/version/#{version.number}/provider/#{name}", provider: params)
37
35
  end
38
36
 
39
37
  def delete
@@ -51,6 +49,5 @@ module VagrantCloud
51
49
  def account
52
50
  box.account
53
51
  end
54
-
55
52
  end
56
53
  end
@@ -1,7 +1,5 @@
1
1
  module VagrantCloud
2
-
3
2
  class Version
4
-
5
3
  attr_accessor :box
6
4
  attr_accessor :number
7
5
  attr_accessor :data
@@ -47,8 +45,8 @@ module VagrantCloud
47
45
 
48
46
  # @param [String] description
49
47
  def update(description)
50
- version = {:description => description}
51
- @data = account.request('put', "/box/#{account.username}/#{box.name}/version/#{number}", {:version => version})
48
+ version = { description: description }
49
+ @data = account.request('put', "/box/#{account.username}/#{box.name}/version/#{number}", version: version)
52
50
  end
53
51
 
54
52
  def delete
@@ -74,8 +72,8 @@ module VagrantCloud
74
72
  # @param [String] url
75
73
  # @return [Provider]
76
74
  def create_provider(name, url)
77
- params = {:name => name, :url => url}
78
- data = account.request('post', "/box/#{account.username}/#{box.name}/version/#{self.number}/providers", {:provider => params})
75
+ params = { name: name, url: url }
76
+ data = account.request('post', "/box/#{account.username}/#{box.name}/version/#{number}/providers", provider: params)
79
77
  get_provider(name, data)
80
78
  end
81
79
 
@@ -83,13 +81,9 @@ module VagrantCloud
83
81
  # @param [String] url
84
82
  # @return [Provider]
85
83
  def ensure_provider(name, url)
86
- provider = providers.select{ |provider| provider.name == name }.first
87
- unless provider
88
- provider = create_provider(name, url)
89
- end
90
- if url != provider.url
91
- provider.update(url)
92
- end
84
+ provider = providers.select { |provider| provider.name == name }.first
85
+ provider = create_provider(name, url) unless provider
86
+ provider.update(url) if url != provider.url
93
87
  provider
94
88
  end
95
89
 
@@ -99,6 +93,5 @@ module VagrantCloud
99
93
  def account
100
94
  box.account
101
95
  end
102
-
103
96
  end
104
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.21'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.41.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.41.2
69
83
  description: Minimalistic ruby client for the HashiCorp Atlas API (previously Vagrant
70
84
  Cloud API)
71
85
  email: tech@cargomedia.ch