module Selenium::WebDriver::Platform
@api private
Public Instance Methods
Source
# File lib/selenium/webdriver/common/platform.rb, line 141 def assert_executable(path) assert_file(path) return if File.executable? path raise Error::WebDriverError, "not executable: #{path.inspect}" end
Source
# File lib/selenium/webdriver/common/platform.rb, line 135 def assert_file(path) return if File.file? path raise Error::WebDriverError, "not a file: #{path.inspect}" end
Source
# File lib/selenium/webdriver/common/platform.rb, line 53 def ci if ENV['TRAVIS'] :travis elsif ENV['JENKINS'] :jenkins elsif ENV['APPVEYOR'] :appveyor elsif ENV['GITHUB_ACTIONS'] :github end end
Source
# File lib/selenium/webdriver/common/platform.rb, line 102 def cygwin? RUBY_PLATFORM.include?('cygwin') end
Source
# File lib/selenium/webdriver/common/platform.rb, line 114 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
Source
# File lib/selenium/webdriver/common/platform.rb, line 33 def engine @engine ||= RUBY_ENGINE.to_sym end
Source
# File lib/selenium/webdriver/common/platform.rb, line 149 def exit_hook pid = Process.pid at_exit { yield if Process.pid == pid } end
Source
# File lib/selenium/webdriver/common/platform.rb, line 29 def home @home ||= Dir.home end
Source
# File lib/selenium/webdriver/common/platform.rb, line 179 def interfaces interfaces = Socket.getaddrinfo('localhost', 8080).map { |e| e[3] } interfaces += ['0.0.0.0', Platform.ip] interfaces.compact.uniq end
Source
# File lib/selenium/webdriver/common/platform.rb, line 163 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
Source
# File lib/selenium/webdriver/common/platform.rb, line 65 def jruby? engine == :jruby end
Source
# File lib/selenium/webdriver/common/platform.rb, line 85 def linux? os == :linux end
Source
# File lib/selenium/webdriver/common/platform.rb, line 155 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
Source
# File lib/selenium/webdriver/common/platform.rb, line 131 def make_writable(file) File.chmod 0o766, file end
Source
# File lib/selenium/webdriver/common/platform.rb, line 106 def null_device File::NULL end
Source
# File 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
Source
# File lib/selenium/webdriver/common/platform.rb, line 73 def ruby_version RUBY_VERSION end
Source
# File lib/selenium/webdriver/common/platform.rb, line 69 def truffleruby? engine == :truffleruby end
Source
# File lib/selenium/webdriver/common/platform.rb, line 123 def unix_path(path) path.tr(File::ALT_SEPARATOR, File::SEPARATOR) end
Source
# File lib/selenium/webdriver/common/platform.rb, line 77 def windows? os == :windows end
Source
# File lib/selenium/webdriver/common/platform.rb, line 127 def windows_path(path) path.tr(File::SEPARATOR, File::ALT_SEPARATOR) end
Source
# File lib/selenium/webdriver/common/platform.rb, line 110 def wrap_in_quotes_if_necessary(str) windows? && !cygwin? ? %("#{str}") : str end
Source
# File lib/selenium/webdriver/common/platform.rb, line 93 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