fog-vsphere 0.5.0 → 0.6.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
  SHA1:
3
- metadata.gz: 96a65cbc2b8dff64e149f6e108ef19d5ddaa5011
4
- data.tar.gz: a531b24b12fe6410476a4532f9c4c5584125bb12
3
+ metadata.gz: 7a12e272a23029a875c210283a8eb747464ab79c
4
+ data.tar.gz: aa09039e8d0942692daf330100baeb066e165a2a
5
5
  SHA512:
6
- metadata.gz: a323cdbb8d6541a7a9597e9bf7628b71e13993a322334ed4beeec504ac68ec87a4d7342a850213c2f6b0f352fceb5343cddab989f5cb05556aba748795c0e834
7
- data.tar.gz: d52f7e564b586cd2eb5727b260f5e51c2394486175d55a975a69d72fd3591acf727a85032bf92ef272d06224b1b15f8431c4e7c1bdebf5c5105b61c38d5d5a3c
6
+ metadata.gz: 073803f1b3a086c7f807a5fe4744c703c22609e2788b007551871214e50aeb5afe40038f9921c45a14752ccb7622929533f4eb91e5c96f8a3aa6d4b3b9c0d0db
7
+ data.tar.gz: dc797b1e4678a88293944451e1350466bd4a033c67230cd5980b160436dcfbdf8707966e801440bc861b9fde204a4c721f6de871863221cc7a1e472130058e77
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.6.0 1/28/2016
2
+
3
+ * Improvements to upload_iso method
4
+ * Minor refactoring of unnecessarily complex code
5
+
1
6
  ## v0.5.0 1/18/2016
2
7
 
3
8
  * Fix wrong string assignment in storage pods
data/fog-vsphere.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'bundler', '~> 1.10'
28
28
  spec.add_development_dependency 'pry', '~> 0.10'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'minitest', '~> 5.8'
30
31
  spec.add_development_dependency 'rubocop', '~> 0.34'
31
32
  spec.add_development_dependency 'shindo', '~> 0.3'
32
33
  end
data/lib/fog/vsphere.rb CHANGED
@@ -17,27 +17,12 @@ module Fog
17
17
  service(:compute, 'Compute')
18
18
 
19
19
  # This helper was originally added as Fog.class_as_string and moved to core but only used here
20
- def self.class_from_string classname, defaultpath=""
21
- if classname and classname.is_a? String then
22
- chain = classname.split("::")
23
- klass = Kernel
24
- chain.each do |klass_string|
25
- klass = klass.const_get klass_string
26
- end
27
- if klass.is_a? Class then
28
- klass
29
- elsif defaultpath != nil then
30
- class_from_string((defaultpath.split("::")+chain).join("::"), nil)
31
- else
32
- nil
33
- end
34
- elsif classname and classname.is_a? Class then
35
- classname
36
- else
37
- nil
38
- end
20
+ def self.class_from_string(name, default_path = '')
21
+ const = default_path.empty? ? name.to_s : "#{default_path}::#{name}"
22
+ klass = const.split('::').inject(Object) { |m, c| m.const_get(c) }
23
+ return klass unless klass == Object
39
24
  rescue NameError
40
- defaultpath != nil ? class_from_string((defaultpath.split("::")+chain).join("::"), nil) : nil
25
+ nil
41
26
  end
42
27
  end
43
28
  end
@@ -19,14 +19,15 @@ module Fog
19
19
  def upload_iso(options = {})
20
20
  options = upload_iso_check_options(options)
21
21
  datastore = get_raw_datastore(options['datastore'], options['datacenter'])
22
- datacenter = get_datacenter(options['datacenter'])
22
+ datacenter = get_raw_datacenter(options['datacenter'])
23
23
  filename = options['filename'] || File.basename(options['local_path'])
24
24
  unless datastore.exists? options['upload_directory']+'/'
25
- @connection.serviceContent.fileManager.MakeDirectory :name => "[#{options['datastore']}] #{options['directory']}",
25
+ @connection.serviceContent.fileManager.MakeDirectory :name => "[#{options['datastore']}] #{options['upload_directory']}",
26
26
  :datacenter => datacenter,
27
27
  :createParentDirectories => false
28
28
  end
29
29
  datastore.upload options['upload_directory']+'/'+filename, options['local_path']
30
+ datastore.exists? options['upload_directory']+'/'+filename
30
31
  end
31
32
  end
32
33
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '0.5.0'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
@@ -0,0 +1,33 @@
1
+ require_relative './helper'
2
+
3
+ class A; class B; class C; end; end; end
4
+
5
+ class TestClassFromString < Minitest::Test
6
+ def test_empty_string
7
+ assert_equal(nil, Fog::Vsphere.class_from_string(''))
8
+ end
9
+
10
+ def test_nil
11
+ assert_equal(nil, Fog::Vsphere.class_from_string(nil))
12
+ end
13
+
14
+ def test_name_as_class
15
+ assert_equal(A, Fog::Vsphere.class_from_string(A))
16
+ end
17
+
18
+ def test_name_as_string
19
+ assert_equal(A, Fog::Vsphere.class_from_string('A'))
20
+ end
21
+
22
+ def test_unexpected_input
23
+ assert_equal(nil, Fog::Vsphere.class_from_string(8))
24
+ end
25
+
26
+ def test_nested_class_without_default_path
27
+ assert_equal(A::B::C, Fog::Vsphere.class_from_string(A::B::C))
28
+ end
29
+
30
+ def test_nested_class_with_default_path
31
+ assert_equal(A::B::C, Fog::Vsphere.class_from_string('C', 'A::B'))
32
+ end
33
+ end
data/tests/helper.rb CHANGED
@@ -5,4 +5,6 @@ rescue LoadError => e
5
5
  $stderr.puts "not recording test coverage: #{e.inspect}"
6
6
  end
7
7
 
8
+ require 'minitest/autorun'
9
+
8
10
  require File.expand_path('../../lib/fog/vsphere', __FILE__)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-vsphere
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
  - J.R. Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-18 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.8'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -230,6 +244,7 @@ files:
230
244
  - lib/fog/vsphere/requests/compute/vm_reconfig_memory.rb
231
245
  - lib/fog/vsphere/requests/compute/vm_take_snapshot.rb
232
246
  - lib/fog/vsphere/version.rb
247
+ - tests/class_from_string_tests.rb
233
248
  - tests/compute_tests.rb
234
249
  - tests/helper.rb
235
250
  - tests/helpers/mock_helper.rb
@@ -286,6 +301,7 @@ signing_key:
286
301
  specification_version: 4
287
302
  summary: Module for the 'fog' gem to support VMware vSphere.
288
303
  test_files:
304
+ - tests/class_from_string_tests.rb
289
305
  - tests/compute_tests.rb
290
306
  - tests/helper.rb
291
307
  - tests/helpers/mock_helper.rb