Class: Applitools::EyesUniversal::UniversalBinaryManager

Inherits:
Object
  • Object
show all
Defined in:
lib/applitools/eyes_universal/universal_binary_manager.rb

Class Method Summary collapse

Class Method Details

.filenameObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/applitools/eyes_universal/universal_binary_manager.rb', line 39

def filename
  return 'core-win.exe' if Gem.win_platform?

  platform = RUBY_PLATFORM.downcase

  # First, handle specific platform combinations
  if platform.include?('darwin')
    if platform.include?('arm64') || platform.include?('aarch64')
      return 'core-macos-arm64'
    else
      return 'core-macos'
    end
  elsif platform.include?('linux')
    if platform.include?('arm64') || platform.include?('aarch64')
      return 'core-linux-arm64'
    elsif platform.include?('musl')
      return 'core-alpine'
    else
      return 'core-linux'
    end
  elsif platform.match?(/mswin|mingw|windows/)
    return 'core-win.exe'
  end

  raise "Unsupported platform: #{RUBY_PLATFORM}"
end

.prepare_server(to) ⇒ Object

install



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/applitools/eyes_universal/universal_binary_manager.rb', line 17

def prepare_server(to) # install
  where = tar_gz_filepath(to)
  puts "[eyes-universal] prepare server : #{where}"

  Gem::Package::TarReader.new(Zlib::GzipReader.open(where)) do |tar|
    tar.each do |entry|
      binary_filename = File.basename(entry.full_name)
      if filename != binary_filename
        puts "[eyes-universal] skip #{binary_filename}"
        next
      end
      puts "[eyes-universal] process #{binary_filename}"
      unpacked_binary = File.expand_path(binary_filename, to)
      File.open(unpacked_binary, 'wb') {|f| f.print entry.read }

      FileUtils.chmod('+x', unpacked_binary)
      # binary_version = `#{unpacked_binary} --version`
      puts "[eyes-universal] Binary ready #{binary_filename} (#{Applitools::EyesUniversal::VERSION}) at #{unpacked_binary}"
    end
  end
end

.tar_gz_filenameObject



66
67
68
# File 'lib/applitools/eyes_universal/universal_binary_manager.rb', line 66

def tar_gz_filename
  'core.tar.gz'
end

.tar_gz_filepath(to) ⇒ Object



12
13
14
# File 'lib/applitools/eyes_universal/universal_binary_manager.rb', line 12

def tar_gz_filepath(to)
  File.expand_path(tar_gz_filename, to)
end