Module: Selenium::WebDriver::Platform
- Defined in:
- lib/selenium/webdriver/common/platform.rb
Class Method Summary collapse
- .assert_executable(path) ⇒ Object
- .bitsize ⇒ Object
- .engine ⇒ Object
- .find_binary(*binary_names) ⇒ Object
- .home ⇒ Object
- .ironruby? ⇒ Boolean
- .jruby? ⇒ Boolean
- .linux? ⇒ Boolean
- .mac? ⇒ Boolean
- .make_writable(file) ⇒ Object
- .os ⇒ Object
- .ruby187? ⇒ Boolean
- .ruby19? ⇒ Boolean
- .win? ⇒ Boolean
- .wrap_in_quotes_if_necessary(str) ⇒ Object
Class Method Details
.assert_executable(path) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/selenium/webdriver/common/platform.rb', line 94 def assert_executable(path) unless File.file? path raise Error::WebDriverError, "not a file: #{path.inspect}" end unless File.executable? path raise Error::WebDriverError, "not executable: #{path.inspect}" end end |
.bitsize ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/selenium/webdriver/common/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 |
.engine ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/selenium/webdriver/common/platform.rb', line 16 def engine @engine ||= ( if defined? RUBY_ENGINE RUBY_ENGINE.to_sym else :ruby end ) end |
.find_binary(*binary_names) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/selenium/webdriver/common/platform.rb', line 104 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 |
.home ⇒ Object
11 12 13 14 |
# File 'lib/selenium/webdriver/common/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
62 63 64 |
# File 'lib/selenium/webdriver/common/platform.rb', line 62 def ironruby? engine == :ironruby end |
.jruby? ⇒ Boolean
58 59 60 |
# File 'lib/selenium/webdriver/common/platform.rb', line 58 def jruby? engine == :jruby end |
.linux? ⇒ Boolean
82 83 84 |
# File 'lib/selenium/webdriver/common/platform.rb', line 82 def linux? os == :linux end |
.mac? ⇒ Boolean
78 79 80 |
# File 'lib/selenium/webdriver/common/platform.rb', line 78 def mac? os == :macosx end |
.make_writable(file) ⇒ Object
90 91 92 |
# File 'lib/selenium/webdriver/common/platform.rb', line 90 def make_writable(file) File.chmod 0766, file end |
.os ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/selenium/webdriver/common/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
66 67 68 |
# File 'lib/selenium/webdriver/common/platform.rb', line 66 def ruby187? !!(RUBY_VERSION =~ /^1\.8\.7/) end |
.ruby19? ⇒ Boolean
70 71 72 |
# File 'lib/selenium/webdriver/common/platform.rb', line 70 def ruby19? !!(RUBY_VERSION =~ /^1\.9/) end |
.win? ⇒ Boolean
74 75 76 |
# File 'lib/selenium/webdriver/common/platform.rb', line 74 def win? os == :windows end |
.wrap_in_quotes_if_necessary(str) ⇒ Object
86 87 88 |
# File 'lib/selenium/webdriver/common/platform.rb', line 86 def wrap_in_quotes_if_necessary(str) win? ? %{"#{str}"} : str end |