2013-06-08 02:37:02 +00:00
|
|
|
module VagrantPlugins
|
2013-05-22 22:38:26 +00:00
|
|
|
module Cachier
|
|
|
|
class Bucket
|
|
|
|
class Gem < Bucket
|
|
|
|
def self.capability
|
|
|
|
:gemdir
|
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
|
|
|
machine = @env[:machine]
|
|
|
|
guest = machine.guest
|
|
|
|
|
|
|
|
if guest.capability?(:gemdir)
|
|
|
|
if gemdir_path = guest.capability(:gemdir)
|
|
|
|
prefix = gemdir_path.split('/').last
|
|
|
|
bucket_path = "/tmp/vagrant-cache/#{@name}/#{prefix}"
|
|
|
|
machine.communicate.tap do |comm|
|
|
|
|
comm.execute("mkdir -p #{bucket_path}")
|
|
|
|
|
|
|
|
gem_cache_path = "#{gemdir_path}/cache"
|
|
|
|
|
|
|
|
@env[:cache_dirs] << gem_cache_path
|
|
|
|
|
|
|
|
unless comm.test("test -L #{gem_cache_path}")
|
|
|
|
comm.sudo("rm -rf #{gem_cache_path}")
|
|
|
|
comm.sudo("mkdir -p `dirname #{gem_cache_path}`")
|
|
|
|
comm.sudo("ln -s #{bucket_path} #{gem_cache_path}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2014-01-24 16:31:55 +00:00
|
|
|
Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RubyGems')
|
2013-05-22 22:38:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|