Sha256: c5f88de090af5ed5ffd7c108ce8e3442c580b14fc97c7646fa5afbac813c1143

Contents?: true

Size: 1.13 KB

Versions: 38

Compression:

Stored size: 1.13 KB

Contents

require 'fileutils'

require 'vagrant/action/general/package'

module VagrantPlugins
  module Parallels
    module Action
      class Package < Vagrant::Action::General::Package
        # Doing this so that we can test that the parent is properly
        # called in the unit tests.
        alias_method :general_call, :call
        def call(env)
          # Setup the temporary directory
          @temp_dir = env[:tmp_path].join(Time.now.to_i.to_s)
          env["export.temp_dir"] = @temp_dir
          FileUtils.mkpath(env["export.temp_dir"])

          # Just match up a couple environmental variables so that
          # the superclass will do the right thing. Then, call the
          # superclass
          env["package.directory"] = env["export.temp_dir"]

          general_call(env)

          # Always call recover to clean up the temp dir
          clean_temp_dir
        end

        def recover(env)
          clean_temp_dir
          super
        end

        protected

        def clean_temp_dir
          if @temp_dir && File.exist?(@temp_dir)
            FileUtils.rm_rf(@temp_dir)
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
vagrant-parallels-1.4.2 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.4.1 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.4.0 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.4.0.rc1 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.13 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.12 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.10 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.9 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.8 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.7 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.6 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.5 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.4 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.3 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.3.rc1 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.2 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.1 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.3.0 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.2.2 lib/vagrant-parallels/action/package.rb
vagrant-parallels-1.2.1 lib/vagrant-parallels/action/package.rb