Module: Selenium::WebDriver::Platform Private

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

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.assert_executable(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


112
113
114
115
116
117
118
# File 'lib/selenium/webdriver/common/platform.rb', line 112

def assert_executable(path)
  assert_file(path)

  unless File.executable? path
    raise Error::WebDriverError, "not executable: #{path.inspect}"
  end
end

.assert_file(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


106
107
108
109
110
# File 'lib/selenium/webdriver/common/platform.rb', line 106

def assert_file(path)
  unless File.file? path
    raise Error::WebDriverError, "not a file: #{path.inspect}"
  end
end

.bitsizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

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

.cygwin?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

def cygwin?
  !!(RUBY_PLATFORM =~ /cygwin/)
end

.cygwin_path(path, opts = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


95
96
97
98
99
100
# File 'lib/selenium/webdriver/common/platform.rb', line 95

def cygwin_path(path, opts = {})
  flags = []
  opts.each { |k,v| flags << "--#{k}" if v }

  `cygpath #{flags.join ' '} "#{path}"`.strip
end

.engineObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

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

.exit_hook(&blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


120
121
122
123
124
125
126
# File 'lib/selenium/webdriver/common/platform.rb', line 120

def exit_hook(&blk)
  pid = Process.pid

  at_exit do
    yield if Process.pid == pid
  end
end

.find_binary(*binary_names) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/selenium/webdriver/common/platform.rb', line 128

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

  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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

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

.ironruby?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

def ironruby?
  engine == :ironruby
end

.jruby?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

def jruby?
  engine == :jruby
end

.linux?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

def linux?
  os == :linux
end

.localhostObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


142
143
144
145
146
147
148
149
150
# File 'lib/selenium/webdriver/common/platform.rb', line 142

def localhost
  info = Socket.getaddrinfo "localhost", 80, Socket::AF_INET, Socket::SOCK_STREAM

  if info.empty?
    raise Error::WebDriverError, "unable to translate 'localhost' for TCP + IPv4"
  end

  info[0][3]
end

.mac?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

def mac?
  os == :macosx
end

.make_writable(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


102
103
104
# File 'lib/selenium/webdriver/common/platform.rb', line 102

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

.osObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

def os
  @os ||= (
    host_os = RbConfig::CONFIG['host_os']
    case host_os
    when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
      :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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

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

.ruby19?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

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

.windows?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

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

def windows?
  os == :windows
end

.wrap_in_quotes_if_necessary(str) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

def wrap_in_quotes_if_necessary(str)
  windows? && !cygwin? ? %{"#{str}"} : str
end