Class: Vagrant::Action::VM::SetupPackageFiles
- Inherits:
-
Object
- Object
- Vagrant::Action::VM::SetupPackageFiles
- Defined in:
- lib/vagrant/action/vm/setup_package_files.rb
Overview
Sets up the mapping of files to copy into the package and verifies that the files can be properly copied.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ SetupPackageFiles
constructor
A new instance of SetupPackageFiles.
Constructor Details
#initialize(app, env) ⇒ SetupPackageFiles
Returns a new instance of SetupPackageFiles.
9 10 11 12 13 14 |
# File 'lib/vagrant/action/vm/setup_package_files.rb', line 9 def initialize(app, env) @app = app env["package.include"] ||= [] env["package.vagrantfile"] ||= nil end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vagrant/action/vm/setup_package_files.rb', line 16 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 Errors::PackageIncludeMissing, :file => from if !File.exist?(from) end # Save the mapping env["package.files"] = files @app.call(env) end |