Class: BrowserStack::LocalBinary

Inherits:
Object
  • Object
show all
Defined in:
lib/browserstack/localbinary.rb

Constant Summary collapse

BASE_RETRIES =
9
FALLBACK_TRIGGER_RETRY =
4

Instance Method Summary collapse

Constructor Details

#initialize(conf = {}) ⇒ LocalBinary

Returns a new instance of LocalBinary.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/browserstack/localbinary.rb', line 17

def initialize(conf = {})
  @auth_token = conf[:auth_token] || ENV['BROWSERSTACK_ACCESS_KEY']
  @proxy_host = conf[:proxy_host]
  @proxy_port = conf[:proxy_port]
  @user_agent = conf[:user_agent] || "browserstack-local-ruby/#{BrowserStack::VERSION}"

  @windows = !!(RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/)
  @binary_filename = compute_binary_filename
  @source_url = nil
  @download_error_message = nil

  @ordered_paths = [
    File.join(File.expand_path('~'), '.browserstack'),
    Dir.pwd,
    Dir.tmpdir
  ]
end

Instance Method Details

#binary_pathObject



35
36
37
38
39
40
41
42
43
# File 'lib/browserstack/localbinary.rb', line 35

def binary_path
  dest_parent_dir = get_available_dirs
  bin_path = File.join(dest_parent_dir, dest_binary_name)

  return bin_path if File.exist?(bin_path) && verify_binary(bin_path)

  File.delete(bin_path) if File.exist?(bin_path)
  download_with_retries(bin_path)
end