-class CopyMyConf < Vagrant::Provisioners::Base
-
- def prepare
- prepare_vim if config.vim
- prepare_git if config.git
- prepare_ssh if config.ssh
- end
-
- def provision!
- channel = env[:vm].channel
- provision_ssh(channel) if config.ssh
- provision_vim(channel) if config.vim
- provision_git(channel) if config.git
- end
-
- def self.config_class
- Config
- end
-
- class Config < Vagrant::Config::Base
- attr_accessor :ssh
- attr_accessor :vim
- attr_accessor :git
- attr_accessor :user_home
- end
-
-private
-
- def tmp_root
- "/tmp/copy_my_conf"
- end
-
- def prepare_ssh
- env[:vm].config.vm.share_folder("ssh", "#{tmp_root}/ssh", "~/.ssh")
- end
-
- def prepare_git
- `mkdir -p #{tmp_root}/git`
- `cp ~/.gitconfig #{tmp_root}/git/`
- env[:vm].config.vm.share_folder("git", "#{tmp_root}/git/", "#{tmp_root}/git")
- end
-
- def prepare_vim
- `mkdir -p #{tmp_root}/vim`
- ["~/.vimrc", "~/.vim"].each do |file|
- `cp -r #{file} #{tmp_root}/vim`
+require 'boot'
+module Vagrant
+ module Provisioners
+ class CopyMyConf < Base
+ def initialize *args
+ `rm -rf /tmp/copy_my_conf`
+ super *args
+ end
+
+ def prepare
+ @to_be_copied = []
+ config.all_true.each do |c|
+ conf = self.class.const_get(c.capitalize).new
+ @to_be_copied << conf
+ conf.prepare env[:vm].config.vm, tmp_root
+ end
+ end
+
+ def provision!
+ channel = env[:vm].channel
+ @to_be_copied.each do |conf|
+ conf.provision channel, user_home, tmp_root
+ end
+ end
+
+ def self.config_class
+ Config
+ end
+
+ private
+
+ def tmp_root
+ "/tmp/copy_my_conf"
+ end
+
+ def user_home
+ config.user_home || "/home/vagrant"
+ end