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
- .assert_executable(path) ⇒ Object private
- .assert_file(path) ⇒ Object private
- .ci ⇒ Object private
- .cygwin? ⇒ Boolean private
- .cygwin_path(path, only_cygwin: false, **opts) ⇒ Object private
- .engine ⇒ Object private
- .exit_hook ⇒ Object private
- .home ⇒ Object private
- .interfaces ⇒ Object private
- .ip ⇒ Object private
- .jruby? ⇒ Boolean private
- .linux? ⇒ Boolean private
- .localhost ⇒ Object private
- .mac? ⇒ Boolean private
- .make_writable(file) ⇒ Object private
- .null_device ⇒ Object private
- .os ⇒ Object private
- .ruby_version ⇒ Object private
- .truffleruby? ⇒ Boolean private
- .unix? ⇒ Boolean private
- .unix_path(path) ⇒ Object private
- .windows? ⇒ Boolean private
- .windows_path(path) ⇒ Object private
- .wrap_in_quotes_if_necessary(str) ⇒ Object private
- .wsl? ⇒ Boolean private
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.
141 142 143 144 145 146 147 |
# 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 |
.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.
135 136 137 138 139 |
# 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 |
.ci ⇒ 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.
53 54 55 56 57 58 59 60 61 62 63 |
# 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 |
.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.
102 103 104 |
# File 'lib/selenium/webdriver/common/platform.rb', line 102 def cygwin? RUBY_PLATFORM.include?('cygwin') end |
.cygwin_path(path, only_cygwin: false, **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.
114 115 116 117 118 119 120 121 |
# 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 |
.engine ⇒ 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.
33 34 35 |
# File 'lib/selenium/webdriver/common/platform.rb', line 33 def engine @engine ||= RUBY_ENGINE.to_sym end |
.exit_hook ⇒ 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.
149 150 151 152 153 |
# File 'lib/selenium/webdriver/common/platform.rb', line 149 def exit_hook pid = Process.pid at_exit { yield if Process.pid == pid } end |
.home ⇒ 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.
29 30 31 |
# File 'lib/selenium/webdriver/common/platform.rb', line 29 def home @home ||= Dir.home end |
.interfaces ⇒ 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.
179 180 181 182 183 184 |
# 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 |
.ip ⇒ 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.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# 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 |
.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.
65 66 67 |
# File 'lib/selenium/webdriver/common/platform.rb', line 65 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.
85 86 87 |
# File 'lib/selenium/webdriver/common/platform.rb', line 85 def linux? os == :linux end |
.localhost ⇒ 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.
155 156 157 158 159 160 161 |
# 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 |
.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.
81 82 83 |
# File 'lib/selenium/webdriver/common/platform.rb', line 81 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.
131 132 133 |
# File 'lib/selenium/webdriver/common/platform.rb', line 131 def make_writable(file) File.chmod 0o766, file end |
.null_device ⇒ 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 |
# File 'lib/selenium/webdriver/common/platform.rb', line 106 def null_device File::NULL end |
.os ⇒ 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.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 |
.ruby_version ⇒ 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.
73 74 75 |
# File 'lib/selenium/webdriver/common/platform.rb', line 73 def ruby_version RUBY_VERSION end |
.truffleruby? ⇒ 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.
69 70 71 |
# File 'lib/selenium/webdriver/common/platform.rb', line 69 def truffleruby? engine == :truffleruby end |
.unix? ⇒ 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.
89 90 91 |
# File 'lib/selenium/webdriver/common/platform.rb', line 89 def unix? os == :unix end |
.unix_path(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.
123 124 125 |
# File 'lib/selenium/webdriver/common/platform.rb', line 123 def unix_path(path) path.tr(File::ALT_SEPARATOR, File::SEPARATOR) 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.
77 78 79 |
# File 'lib/selenium/webdriver/common/platform.rb', line 77 def windows? os == :windows end |
.windows_path(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.
127 128 129 |
# File 'lib/selenium/webdriver/common/platform.rb', line 127 def windows_path(path) path.tr(File::SEPARATOR, File::ALT_SEPARATOR) 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.
110 111 112 |
# File 'lib/selenium/webdriver/common/platform.rb', line 110 def wrap_in_quotes_if_necessary(str) windows? && !cygwin? ? %("#{str}") : str end |
.wsl? ⇒ 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.
93 94 95 96 97 98 99 100 |
# 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 |