Class: ArduinoCI::ArduinoDownloaderWindows

Inherits:
ArduinoDownloader show all
Defined in:
lib/arduino_ci/arduino_downloader_windows.rb

Overview

Manage the POSIX download & install of Arduino

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ArduinoDownloader

autolocated_executable, downloader, #execute, existing_executable, #initialize, #install, must_implement, #package_url, #prepare

Constructor Details

This class inherits a constructor from ArduinoCI::ArduinoDownloader

Class Method Details

.extract(package_file) ⇒ bool

Extract the package_file to extracted_file

Returns:

  • (bool)

    whether successful



40
41
42
43
44
45
46
# File 'lib/arduino_ci/arduino_downloader_windows.rb', line 40

def self.extract(package_file)
  Zip::File.open(package_file) do |zip|
    zip.each do |file|
      file.extract(file.name)
    end
  end
end

.extracted_filestring

The local file (dir) name of the extracted IDE package (zip/tar/etc)

Returns:

  • (string)


50
51
52
# File 'lib/arduino_ci/arduino_downloader_windows.rb', line 50

def self.extracted_file
  "arduino-cli.exe"
end

.extractorstring

The technology that will be used to extract the download (for logging purposes)

Returns:

  • (string)


34
35
36
# File 'lib/arduino_ci/arduino_downloader_windows.rb', line 34

def self.extractor
  "Expand-Archive"
end

.force_installed_executablePathname

The executable Arduino file in a forced installation, or nil

Returns:

  • (Pathname)


56
57
58
# File 'lib/arduino_ci/arduino_downloader_windows.rb', line 56

def self.force_installed_executable
  Pathname.new(Host.windows_to_pathname(ENV['HOME'])) + self.extracted_file
end

Instance Method Details

#downloadbool

Download the package_url to package_file

Returns:

  • (bool)

    whether successful



15
16
17
18
19
20
21
22
23
# File 'lib/arduino_ci/arduino_downloader_windows.rb', line 15

def download
  # Turned off ssl verification
  # This should be acceptable because it won't happen on a user's machine, just CI
  open(URI.parse(package_url), ssl_verify_mode: 0) do |url|
    File.open(package_file, 'wb') { |file| file.write(url.read) }
  end
rescue Net::OpenTimeout, Net::ReadTimeout, OpenURI::HTTPError, URI::InvalidURIError => e
  @output.puts "\nArduino force-install failed downloading #{package_url}: #{e}"
end

#package_filestring

The local filename of the desired IDE package (zip/tar/etc)

Returns:

  • (string)


27
28
29
# File 'lib/arduino_ci/arduino_downloader_windows.rb', line 27

def package_file
  "arduino-cli_#{@desired_version}_Windows_64bit.zip"
end