Sha256: 82495ae5720f2662334309f6aad98a3f5893e6172673918b605ae0888eaddf52

Contents?: true

Size: 1.37 KB

Versions: 26

Compression:

Stored size: 1.37 KB

Contents

module VagrantPlugins
  module Parallels
    module Action
      class SetupPackageFiles
        def initialize(app, env)
          @app = app

          env["package.include"] ||= []
          env["package.vagrantfile"] ||= nil
        end

        def call(env)
          files = {}
          env["package.include"].each do |file|
            source = Pathname.new(file)
            dest   = nil

            # If the source is relative then we add the file as-is to the include
            # directory. Otherwise, we copy only the file into the root of the
            # include directory. Kind of strange, but seems to match what people
            # expect based on history.
            if source.relative?
              dest = source
            else
              dest = source.basename
            end

            # Assign the mapping
            files[file] = dest
          end

          if env["package.vagrantfile"]
            # Vagrantfiles are treated special and mapped to a specific file
            files[env["package.vagrantfile"]] = "_Vagrantfile"
          end

          # Verify the mapping
          files.each do |from, _|
            raise Vagrant::Errors::PackageIncludeMissing,
              :file => from if !File.exist?(from)
          end

          # Save the mapping
          env["package.files"] = files

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
vagrant-parallels-1.1.0 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.9.rc1 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.8 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.7 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.6 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.6.rc1 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.5 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.4 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.3 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.2 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.1 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-1.0.0 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-0.2.2 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-0.2.2.rc1 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-0.2.1 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-0.2.0 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-0.1.3 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-0.1.2 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-0.1.1 lib/vagrant-parallels/action/setup_package_files.rb
vagrant-parallels-0.1.0 lib/vagrant-parallels/action/setup_package_files.rb