-
-
Save jtimberman/101173 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake' | |
require 'rake/tasklib' | |
class VMWare < ::Rake::TaskLib | |
def initialize(vm_path, vm_name) | |
@vmrun = '/Library/Application\ Support/VMware\ Fusion/vmrun' | |
@vm_path = vm_path | |
@vm_name = vm_name | |
define | |
end | |
def define | |
namespace :vmware do | |
namespace @vm_name.to_sym do | |
desc "list snapshots" | |
task :list_snapshots do | |
system("#{@vmrun} listSnapshots #{@vm_path}") | |
end | |
end | |
end | |
end | |
end | |
base_dir = Dir.new(File.expand_path('~/Documents/Virtual Machines.localized')) | |
available_vms = base_dir.find_all {|e| e =~ /vmwarevm$/} | |
available_vms.each do |vm| | |
name = vm.gsub('.vmwarevm', '').gsub(/\s+/, '_').downcase | |
vm_path = File.join(base_dir.path, vm).gsub(/ /, '\ ') | |
VMWare.new(vm_path, name) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment