Sha256: 8485de335235809317864c9b3821935df19653f5dd8dd3e0f6a5c32f3710e1a5

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

module VagrantPlugins
  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
            @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RubyGems')
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vagrant-cachier-0.5.1 lib/vagrant-cachier/bucket/gem.rb
vagrant-cachier-0.5.0 lib/vagrant-cachier/bucket/gem.rb
vagrant-cachier-0.4.1 lib/vagrant-cachier/bucket/gem.rb
vagrant-cachier-0.4.0 lib/vagrant-cachier/bucket/gem.rb
vagrant-cachier-0.3.3 lib/vagrant-cachier/bucket/gem.rb
vagrant-cachier-0.3.2 lib/vagrant-cachier/bucket/gem.rb
vagrant-cachier-0.3.1 lib/vagrant-cachier/bucket/gem.rb
vagrant-cachier-0.3.0 lib/vagrant-cachier/bucket/gem.rb