Class: Packer::Binary::Executable
- Inherits:
-
Object
- Object
- Packer::Binary::Executable
- Includes:
- Helpers
- Defined in:
- lib/packer/binary/executable.rb
Instance Method Summary collapse
- #binary ⇒ Object
- #download ⇒ Object
-
#initialize ⇒ Executable
constructor
A new instance of Executable.
Methods included from Helpers
debug, err, msg, stderr, stdout, system_command
Constructor Details
#initialize ⇒ Executable
Returns a new instance of Executable.
6 7 8 9 10 11 12 13 14 |
# File 'lib/packer/binary/executable.rb', line 6 def initialize @packer_version = Packer::Binary.config.version @download_path = "#{Packer::Binary.config.download_path.chomp('/')}/packer-binary/#{@packer_version}/bin" @download_filename = "#{@packer_version}-packer.zip" FileUtils.mkdir_p @download_path raise 'Your OS is not supported' unless supported? end |
Instance Method Details
#binary ⇒ Object
16 17 18 |
# File 'lib/packer/binary/executable.rb', line 16 def binary Dir["#{@download_path}/packer*"][0] end |
#download ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/packer/binary/executable.rb', line 20 def download return "#{binary} already exists" if binary_exist? msg("Downloading https://#{download_domain}/#{download_uri}") require 'open-uri' File.open("#{@download_path}/#{@download_filename}", "wb") do |saved_file| # the following "open" is provided by open-uri open("https://#{download_domain}/#{download_uri}", "rb") do |read_file| saved_file.write(read_file.read) end end extract make_exe end |