lib/virtualbox/command.rb in virtualbox-0.1.1 vs lib/virtualbox/command.rb in virtualbox-0.2.0

- old
+ new

@@ -12,26 +12,35 @@ # class Command @@vboxmanage = "VBoxManage" class <<self + # Returns true if the last run command was a success. Obviously this + # will introduce all sorts of thread-safe problems. Those will have to + # be addressed another time. + def success? + $?.to_i == 0 + end + # Sets the path to VBoxManage, which is required for this gem to # work. def vboxmanage=(path) @@vboxmanage = path end # Runs a VBoxManage command and returns the output. def vboxmanage(command) - execute("#{@@vboxmanage} #{command}") + result = execute("#{@@vboxmanage} #{command}") + raise Exceptions::CommandFailedException.new(result) if !Command.success? + result end # Runs a command and returns a boolean result showing # if the command ran successfully or not based on the # exit code. def test(command) execute(command) - $?.to_i == 0 + success? end # Runs a command and returns the STDOUT result. The reason this is # a method at the moment is because in the future we may want to # change the way commands are run (replace the backticks), plus it \ No newline at end of file