Module: Selenium::WebDriver::Platform Private
    Do not use.  This module is for internal use only.
  
| Relationships & Source Files | |
| Defined in: | rb/lib/selenium/webdriver/common/platform.rb | 
Class Attribute Summary
- .cygwin? ⇒ Boolean readonly Internal use only mod_func
- .jruby? ⇒ Boolean readonly Internal use only mod_func
- .linux? ⇒ Boolean readonly Internal use only mod_func
- .mac? ⇒ Boolean readonly Internal use only mod_func
- .truffleruby? ⇒ Boolean readonly Internal use only mod_func
- .unix? ⇒ Boolean readonly Internal use only mod_func
- .windows? ⇒ Boolean readonly Internal use only mod_func
- .wsl? ⇒ Boolean readonly Internal use only mod_func
Class Method Summary
- .assert_executable(path) Internal use only mod_func
- .assert_file(path) Internal use only mod_func
- .ci Internal use only mod_func
- .cygwin_path(path, only_cygwin: false, **opts) Internal use only mod_func
- .engine Internal use only mod_func
- .exit_hook Internal use only mod_func
- .home Internal use only mod_func
- .interfaces Internal use only mod_func
- .ip Internal use only mod_func
- .localhost Internal use only mod_func
- .make_writable(file) Internal use only mod_func
- .null_device Internal use only mod_func
- .os Internal use only mod_func
- .ruby_version Internal use only mod_func
- .unix_path(path) Internal use only mod_func
- .windows_path(path) Internal use only mod_func
- .wrap_in_quotes_if_necessary(str) Internal use only mod_func
Class Attribute Details
    .cygwin?  ⇒ Boolean  (readonly, mod_func)
  
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 100
def cygwin? RUBY_PLATFORM.include?('cygwin') end
    .jruby?  ⇒ Boolean  (readonly, mod_func)
  
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 63
def jruby? engine == :jruby end
    .linux?  ⇒ Boolean  (readonly, mod_func)
  
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 83
def linux? os == :linux end
    .mac?  ⇒ Boolean  (readonly, mod_func)
  
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 79
def mac? os == :macosx end
    .truffleruby?  ⇒ Boolean  (readonly, mod_func)
  
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 67
def truffleruby? engine == :truffleruby end
    .unix?  ⇒ Boolean  (readonly, mod_func)
  
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 87
def unix? os == :unix end
    .windows?  ⇒ Boolean  (readonly, mod_func)
  
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 75
def windows? os == :windows end
    .wsl?  ⇒ Boolean  (readonly, mod_func)
  
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 91
def wsl? return false unless linux? File.read('/proc/version').downcase.include?('microsoft') rescue Errno::EACCES # the file cannot be accessed on Linux on DeX false end
Class Method Details
.assert_executable(path) (mod_func)
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 139
def assert_executable(path) assert_file(path) return if File.executable? path raise Error::WebDriverError, "not executable: #{path.inspect}" end
.assert_file(path) (mod_func)
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 133
def assert_file(path) return if File.file? path raise Error::WebDriverError, "not a file: #{path.inspect}" end
.ci (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 53
def ci if ENV['JENKINS'] :jenkins elsif ENV['APPVEYOR'] :appveyor elsif ENV['GITHUB_ACTIONS'] :github end end
.cygwin_path(path, only_cygwin: false, **opts) (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 112
def cygwin_path(path, only_cygwin: false, **opts) return path if only_cygwin && !cygwin? flags = [] opts.each { |k, v| flags << "--#{k}" if v } `cygpath #{flags.join ' '} "#{path}"`.strip end
.engine (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 33
def engine @engine ||= RUBY_ENGINE.to_sym end
.exit_hook (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 147
def exit_hook pid = Process.pid at_exit { yield if Process.pid == pid } end
.home (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 29
def home @home ||= Dir.home end
.interfaces (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 177
def interfaces interfaces = Socket.getaddrinfo('localhost', 8080).map { |e| e[3] } interfaces += ['0.0.0.0', Platform.ip] interfaces.compact.uniq end
.ip (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 161
def ip orig = Socket.do_not_reverse_lookup Socket.do_not_reverse_lookup = true begin UDPSocket.open do |s| s.connect '8.8.8.8', 53 return s.addr.last end ensure Socket.do_not_reverse_lookup = orig end rescue Errno::ENETUNREACH, Errno::EHOSTUNREACH # no external ip end
.localhost (mod_func)
# File 'rb/lib/selenium/webdriver/common/platform.rb', line 153
def localhost info = Socket.getaddrinfo 'localhost', 80, Socket::AF_INET, Socket::SOCK_STREAM return info[0][3] unless info.empty? raise Error::WebDriverError, "unable to translate 'localhost' for TCP + IPv4" end
.make_writable(file) (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 129
def make_writable(file) File.chmod 0o766, file end
.null_device (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 104
def null_device File::NULL end
.os (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 37
def os host_os = RbConfig::CONFIG['host_os'] @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
.ruby_version (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 71
def ruby_version RUBY_VERSION end
.unix_path(path) (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 121
def unix_path(path) path.tr(File::ALT_SEPARATOR, File::SEPARATOR) end
.windows_path(path) (mod_func)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/platform.rb', line 125
def windows_path(path) path.tr(File::SEPARATOR, File::ALT_SEPARATOR) end