veewee 0.3.4 → 0.3.5

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.
@@ -4,23 +4,25 @@ module Veewee
4
4
  module BoxCommand
5
5
 
6
6
  def exists?
7
- command="#{@vboxcmd} list vms"
8
- shell_results=shell_exec("#{command}",{:mute => true})
9
- exists=shell_results.stdout.split(/\n/).grep(/\"#{name}\"/).size!=0
10
-
11
- env.logger.info("Vm exists? #{exists}")
12
- return exists
7
+ return check?(:exists)
13
8
  end
14
9
 
15
10
  def running?
16
- command="#{@vboxcmd} list runningvms"
11
+ return check?(:running)
12
+ end
13
+
14
+ private
15
+
16
+ def check? type
17
+ command = COMMANDS[type] % @vboxcmd
17
18
  shell_results=shell_exec("#{command}",{:mute => true})
18
- running=shell_results.stdout.split(/\n/).grep(/\"#{name}\"/).size!=0
19
+ status=shell_results.stdout.split(/\n/).grep(/\"#{Regexp.escape(name)}\"/).size!=0
19
20
 
20
- env.logger.info("Vm running? #{running}")
21
- return running
21
+ env.logger.info("Vm #{type}? #{status}")
22
+ return status
22
23
  end
23
24
 
25
+ COMMANDS = { :running => "%s list runningvms", :exists => "%s list vms" }
24
26
  end
25
27
  end
26
28
  end
@@ -4,5 +4,5 @@ end
4
4
 
5
5
  # Only set the version constant if it wasn't set before
6
6
  unless defined?(Veewee::VERSION)
7
- ::Veewee::VERSION="0.3.4"
7
+ ::Veewee::VERSION="0.3.5"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veewee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -1271,7 +1271,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1271
1271
  version: '0'
1272
1272
  segments:
1273
1273
  - 0
1274
- hash: 2390399721173866482
1274
+ hash: -1661245043997941021
1275
1275
  required_rubygems_version: !ruby/object:Gem::Requirement
1276
1276
  none: false
1277
1277
  requirements: