Module: SeleniumPrep::System::Path

Defined in:
lib/selenium-prep/system/path.rb

Class Method Summary collapse

Class Method Details

.pathObject



39
40
41
42
# File 'lib/selenium-prep/system/path.rb', line 39

def self.path
  ConfigChecker.new
  ENV['PATH']
end

.setObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/selenium-prep/system/path.rb', line 7

def self.set
  ConfigChecker.new
  case ENV['SE_OS_TYPE']
  when 'win32', 'win64'
    ENV['PATH'] = "#{ENV['PATH']};#{ENV['SE_DOWNLOAD_LOCATION']}"
    require 'win32/registry'
    Win32::Registry::HKEY_LOCAL_MACHINE.open(
      "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
      Win32::Registry::KEY_WRITE) do |key|
        key['PATH'] = ENV['PATH']
      end
    broadcast_windows_system_message
  when 'mac32', 'linux32', 'linux64'
    unless set?
      unless bash_updated?
        system("echo 'export PATH=$PATH:#{ENV['SE_DOWNLOAD_LOCATION']}' | sudo tee -a ~/.bash_profile")
      end
      system('source ~/.bash_profile')
      ENV['PATH'] = "#{ENV['PATH']}:/#{ENV['SE_DOWNLOAD_LOCATION']}"
    end
  end
end

.set?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/selenium-prep/system/path.rb', line 30

def self.set?
  case ENV['SE_OS_TYPE']
  when 'win32', 'win64'
    path.include?(ENV['SE_DOWNLOAD_LOCATION'])
  when 'mac32', 'linux32', 'linux64'
    path.include?(ENV['SE_DOWNLOAD_LOCATION']) && bash_updated?
  end
end