Class: Vagrant::Downloaders::File

Inherits:
Base
  • Object
show all
Defined in:
lib/vagrant/downloaders/file.rb

Overview

“Downloads” a file to a temporary file. Basically, this downloader simply does a file copy.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Vagrant::Downloaders::Base

Class Method Details

.match?(uri) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/vagrant/downloaders/file.rb', line 8

def self.match?(uri)
  ::File.file?(::File.expand_path(uri))
end

Instance Method Details

#download!(source_url, destination_file) ⇒ Object



16
17
18
19
# File 'lib/vagrant/downloaders/file.rb', line 16

def download!(source_url, destination_file)
  @ui.info I18n.t("vagrant.downloaders.file.download")
  FileUtils.cp(::File.expand_path(source_url), destination_file.path)
end

#prepare(source_url) ⇒ Object



12
13
14
# File 'lib/vagrant/downloaders/file.rb', line 12

def prepare(source_url)
  raise Errors::DownloaderFileDoesntExist if !::File.file?(::File.expand_path(source_url))
end