Module: Selenium::WebDriver::Platform

Defined in:
lib/selenium/webdriver/platform.rb

Class Method Summary collapse

Class Method Details

.bitsizeObject


44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/selenium/webdriver/platform.rb', line 44

def bitsize
  @bitsize ||= (
    if defined?(FFI::BITSIZE)
      FFI::BITSIZE
    elsif defined?(FFI)
      FFI.type_size(:pointer) == 4 ? 32 : 64
    elsif jruby?
      Integer(ENV_JAVA['sun.arch.data.model'])
    else
      1.size == 4 ? 32 : 64
    end
  )
end

.engineObject


16
17
18
19
20
21
22
23
24
# File 'lib/selenium/webdriver/platform.rb', line 16

def engine
  @engine ||= (
    if defined? RUBY_ENGINE
      RUBY_ENGINE.to_sym
    else
      :ruby
    end
  )
end

.find_binary(*binary_names) ⇒ Object


94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/selenium/webdriver/platform.rb', line 94

def find_binary(*binary_names)
  paths = ENV['PATH'].split(File::PATH_SEPARATOR)
  binary_names.map! { |n| "#{n}.exe" } if win?

  binary_names.each do |binary_name|
    paths.each do |path|
      exe = File.join(path, binary_name)
      return exe if File.executable?(exe)
    end
  end

  nil
end

.homeObject


11
12
13
14
# File 'lib/selenium/webdriver/platform.rb', line 11

def home
  # jruby has an issue with ENV['HOME'] on Windows
  @home ||= jruby? ? ENV_JAVA['user.home'] : ENV['HOME']
end

.ironruby?Boolean

Returns:

  • (Boolean)

62
63
64
# File 'lib/selenium/webdriver/platform.rb', line 62

def ironruby?
  engine == :ironruby
end

.jruby?Boolean

Returns:

  • (Boolean)

58
59
60
# File 'lib/selenium/webdriver/platform.rb', line 58

def jruby?
  engine == :jruby
end

.linux?Boolean

Returns:

  • (Boolean)

82
83
84
# File 'lib/selenium/webdriver/platform.rb', line 82

def linux?
  os == :linux
end

.mac?Boolean

Returns:

  • (Boolean)

78
79
80
# File 'lib/selenium/webdriver/platform.rb', line 78

def mac?
  os == :macosx
end

.make_writable(file) ⇒ Object


90
91
92
# File 'lib/selenium/webdriver/platform.rb', line 90

def make_writable(file)
  File.chmod 0766, file
end

.osObject


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/selenium/webdriver/platform.rb', line 26

def os
  @os ||= (
    host_os = RbConfig::CONFIG['host_os']
    case host_os
    when /mswin|msys|mingw32/
      :windows
    when /darwin|mac os/
      :macosx
    when /linux/
      :linux
    when /solaris|bsd/
      :unix
    else
      raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
    end
  )
end

.ruby187?Boolean

Returns:

  • (Boolean)

66
67
68
# File 'lib/selenium/webdriver/platform.rb', line 66

def ruby187?
  !!(RUBY_VERSION =~ /^1\.8\.7/)
end

.ruby19?Boolean

Returns:

  • (Boolean)

70
71
72
# File 'lib/selenium/webdriver/platform.rb', line 70

def ruby19?
  !!(RUBY_VERSION =~ /^1\.9/)
end

.win?Boolean

Returns:

  • (Boolean)

74
75
76
# File 'lib/selenium/webdriver/platform.rb', line 74

def win?
  os == :windows
end

.wrap_in_quotes_if_necessary(str) ⇒ Object


86
87
88
# File 'lib/selenium/webdriver/platform.rb', line 86

def wrap_in_quotes_if_necessary(str)
  win? ? %{"#{str}"} : str
end