Method: PuppetX::Rustup::Util.download
- Defined in:
- lib/puppet_x/rustup/util.rb
.download(url, basename = '') ⇒ Object
Make a download available as a ‘Tempfile` in a block.
download('https://example.com/test.sh', ['test', '.sh']) do |file|
puts "#{file.path} will be deleted after the block ends."
end
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet_x/rustup/util.rb', line 30 def self.download(url, basename = '') file = Tempfile.new(basename) begin Puppet.debug { "Downloading #{url.inspect} into #{file.path.inspect}" } PuppetX::Rustup::Util.download_into(url, file) file.flush yield(file) ensure Puppet.debug { "Deleting #{file.path.inspect}" } file.close file.unlink end end |