Class: Vagrant::Downloaders::File
- 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
Constructor Details
This class inherits a constructor from Vagrant::Downloaders::Base
Class Method Details
.match?(uri) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/vagrant/downloaders/file.rb', line 9 def self.match?(uri) extracted = URI.extract(uri, "file") # We match if we got a file URI. It doesn't matter here if the file # doesn't exist because we check again later as well. return true if extracted && extracted.include?(uri) # Otherwise we match if the file exists return ::File.file?(::File.(uri)) end |
Instance Method Details
#download!(source_url, destination_file) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/vagrant/downloaders/file.rb', line 20 def download!(source_url, destination_file) raise Errors::DownloaderFileDoesntExist if !::File.file?(::File.(source_url)) @ui.info I18n.t("vagrant.downloaders.file.download") FileUtils.cp(::File.(source_url), destination_file.path) end |