webdrivers 3.7.1 → 3.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57609975e2a5d45294e3bc698ded693c3c6eef7df57b758264afb9e5d132c71a
4
- data.tar.gz: 8975564b199c769158c5bd4cf247b84276ac4718fafbce031fc025d2a4150e19
3
+ metadata.gz: 6ef60a7f9627b14fa90b684a1f807e8b853a0eda388bd21d8a3017ca98da585d
4
+ data.tar.gz: 8d221be9ff66fd793c50934990c12236349a0ad04a1b0e9a9fcfc7d65632231a
5
5
  SHA512:
6
- metadata.gz: 4e69935404700371ab1bad72ce3122064e850e8d89ae152b25cefe97ad7282527340c8f3e4f7fb2e45bed124ca248795f9b483393f72c6f606898c118f859b34
7
- data.tar.gz: 4ce41c8a7fe0d16825828865bee12166557092f6ef633e728042118ffc1b05f6edb5457d69c787f513d98e319729b54b4bd0d65786a15f95c4d6063a3f956535
6
+ metadata.gz: 32bb8a8f53ad38f1d6a6e7f25c62787039db4e4e165f5d52f08877a05da8230bcb1fc2387cfd8cd75aa653aed689ee06eb21ea0fd25e3b491c0605d5f2c0ca86
7
+ data.tar.gz: 3dc0a5206c967a98b25aa5e0bf1b257769d362894f4f00141a988b6fdd6bd395cbc40785dee73c88e016b0cb40c3b0198696e950db4a6cdda43e38d1278349f5
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- chromedriver.log
6
- /.idea/
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ chromedriver.log
6
+ /.idea/
7
+ coverage/
@@ -0,0 +1,19 @@
1
+ require: rubocop-rspec
2
+ Metrics/LineLength:
3
+ Enabled: false
4
+ Metrics/MethodLength:
5
+ Enabled: false
6
+ Metrics/BlockLength:
7
+ Enabled: false
8
+ Metrics/ClassLength:
9
+ Enabled: false
10
+ Metrics/AbcSize:
11
+ Enabled: false
12
+ Metrics/CyclomaticComplexity:
13
+ Enabled: false
14
+ Style/Documentation:
15
+ Enabled: false
16
+ RSpec/ExampleLength:
17
+ Enabled: false
18
+ RSpec/MultipleExpectations:
19
+ Enabled: false
@@ -1,4 +1,3 @@
1
- sudo: required
2
1
  os:
3
2
  - linux
4
3
  - osx
@@ -6,9 +5,12 @@ language: ruby
6
5
  cache: bundler
7
6
  rvm:
8
7
  - 2.4.1
8
+ - 2.5
9
+ - 2.6
9
10
  - jruby-9.2.0.0
10
11
  addons:
12
+ apt:
13
+ packages:
14
+ - chromium-browser
15
+ - libgconf-2-4
11
16
  chrome: stable
12
-
13
- before_script:
14
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install chromium-browser libgconf-2-4 ; fi
@@ -1,3 +1,8 @@
1
+ ### 3.7.2 (2019-03-29)
2
+ * Fix bugs in methods that retrieve Chrome/Chromium version. See [#43](https://github.com/titusfortner/webdrivers/pull/43) and [#52](https://github.com/titusfortner/webdrivers/issues/52).
3
+ * Add workaround for a Jruby bug when retrieving Chrome version on Windows. See [#41](https://github.com/titusfortner/webdrivers/issues/41).
4
+ * Update README with more information.
5
+
1
6
  ### 3.7.1 (2019-03-25)
2
7
  * Use `Selenium::WebDriver::Chrome#path` to check for a user given browser executable before defaulting to Google Chrome. Addresses [#38](https://github.com/titusfortner/webdrivers/issues/38).
3
8
  * Download `chromedriver` v2.46 if Chrome/Chromium version is less than 70.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in webdrivers.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in webdrivers.gemspec
4
+ gemspec
@@ -1,22 +1,22 @@
1
- (The MIT License)
2
-
3
- Copyright (c) 2017: Titus Fortner
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- 'Software'), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017: Titus Fortner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -7,19 +7,12 @@ Run Selenium tests more easily with automatic installation and updates for all s
7
7
 
8
8
  # Description
9
9
 
10
- `webdrivers` downloads drivers and directs Selenium to use them.
10
+ `webdrivers` downloads drivers and directs Selenium to use them. Currently supports:
11
11
 
12
- Currently supported:
13
- * `chromedriver`
14
- * `geckodriver`
15
- * `IEDriverServer`
16
- * `MicrosoftWebDriver`
17
-
18
- Drivers are stored in `~/.webdrivers` directory, and this is configurable:
19
-
20
- ```ruby
21
- Webdrivers.install_dir = '/webdrivers/install/dir'
22
- ```
12
+ * [chromedriver](http://chromedriver.chromium.org/)
13
+ * [geckodriver](https://github.com/mozilla/geckodriver)
14
+ * [IEDriverServer](https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver)
15
+ * [MicrosoftWebDriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/)
23
16
 
24
17
  # Usage
25
18
 
@@ -33,6 +26,44 @@ In your project:
33
26
  require 'webdrivers'
34
27
  ```
35
28
 
29
+ The drivers will now be automatically downloaded or updated when you launch a browser
30
+ through Selenium.
31
+
32
+ **Download Location**
33
+
34
+ The default download location is `~/.webdrivers` directory, and this is configurable:
35
+
36
+ ```ruby
37
+ Webdrivers.install_dir = '/webdrivers/install/dir'
38
+ ```
39
+
40
+ **Version Pinning**
41
+
42
+ If you would like to use a specific (older or beta) version, you can specify it for each driver. Otherwise, the latest (stable)
43
+ driver will be downloaded and passed to Selenium.
44
+
45
+ ```ruby
46
+ # Chrome
47
+ Webdrivers::Chromedriver.version = '2.46'
48
+
49
+ # Firefox
50
+ Webdrivers::Geckodriver.version = '0.23.0'
51
+
52
+ # Microsoft Internet Explorer
53
+ Webdrivers::IEdriver.version = '3.14.0'
54
+
55
+ # Microsoft Edge
56
+ Webdrivers::MSWebdriver.version = '17134'
57
+ ```
58
+
59
+ You can also trigger the update in your code, but it is not required:
60
+
61
+ ```ruby
62
+ Webdrivers::Chromedriver.update
63
+ ```
64
+
65
+ # Proxy
66
+
36
67
  If there is a proxy between you and the Internet then you will need to configure
37
68
  the gem to use the proxy. You can do this by calling the `configure` method.
38
69
 
@@ -45,33 +76,43 @@ Webdrivers.configure do |config|
45
76
  end
46
77
  ````
47
78
 
48
- If you are getting an error like this (especially common on Windows)
79
+ If you are getting an error like this (especially common on Windows):
80
+
49
81
  `SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed`
50
82
 
51
- add the following to your code:
83
+ Add the following to your code:
52
84
 
53
85
  ````ruby
54
86
  Webdrivers.net_http_ssl_fix
55
87
  ````
56
88
 
57
- You can also specify the webdriver versions if you don't want the latest:
89
+ # Logging
90
+
91
+ The logging level can be configured for debugging purpose:
58
92
 
59
93
  ```ruby
60
- Webdrivers::Chromedriver.version = '2.46'
61
- Webdrivers::Geckodriver.version = '0.17.0'
62
- Webdrivers::IEdriver.version = '3.14.0'
63
- Webdrivers::MSWebdriver.version = '17134'
94
+ Webdrivers.logger.level = :DEBUG
64
95
  ```
65
96
 
66
- **Note when using Chrome/Chromium with Selenium**
97
+ # Browser Specific Notes
67
98
 
68
- You can configure the gem to use a specific browser version (Chrome vs Chromium) by providing the path to its binary:
99
+ **When using Chrome/Chromium**
100
+
101
+ The version of `chromedriver` will depend on the version of Chrome you are using it with:
102
+
103
+ * For versions >= 70, the downloaded version of `chromedriver` will match the installed version of Google Chrome. More information [here](http://chromedriver.chromium.org/downloads/version-selection).
104
+ * For versions <= 69, `chromedriver` version 2.46 will be downloaded.
105
+ * For beta versions, you'll have to set the desired beta version of `chromedriver` using `Webdrivers::Chromedriver.version`.
106
+
107
+ The gem, by default, looks for the Google Chrome version. You can override this by providing a path to the Chromium binary:
69
108
 
70
109
  ```ruby
71
- Selenium::WebDriver::Chrome.path = '/chromium/install/path'
110
+ Selenium::WebDriver::Chrome.path = '/chromium/install/path/to/binary'
72
111
  ```
73
112
 
74
- **Note when using Microsoft Edge**
113
+ This is also required if Google Chrome is not installed in its [default location](https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver).
114
+
115
+ **When using Microsoft Edge**
75
116
 
76
117
  After updating Microsoft Edge on Windows 10, you will need to delete the existing binary (`%USERPROFILE%/.webdrivers/MicrosoftWebDriver.exe`) to
77
118
  to be able to download the latest version through this gem.
@@ -83,6 +124,10 @@ expected version and skips the download process.
83
124
 
84
125
  If you continue with the outdated binary, Selenium will throw an error: `unable to connect to MicrosoftWebDriver localhost:17556`.
85
126
 
127
+ # Wiki
128
+
129
+ Please see the [wiki](https://github.com/titusfortner/webdrivers/wiki) for solutions to commonly reported issues.
130
+
86
131
  # License
87
132
 
88
133
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT),
@@ -91,7 +136,7 @@ see LICENSE.txt for full details and copyright.
91
136
 
92
137
  # Contributing
93
138
 
94
- Bug reports and pull requests are welcome [on GitHub](https://github.com/titusfortner/webdrivers).
139
+ Bug reports and pull requests are welcome [on GitHub](https://github.com/titusfortner/webdrivers). Run `bundle exec rake` and squash the commits in your PRs.
95
140
 
96
141
 
97
142
  ## Copyright
data/Rakefile CHANGED
@@ -1,6 +1,9 @@
1
- require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RuboCop::RakeTask.new
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task default: %w[spec rubocop]
@@ -1,15 +1,13 @@
1
- require "webdrivers/selenium"
2
- require "webdrivers/logger"
3
- require "webdrivers/common"
4
- require "webdrivers/chromedriver"
5
- require "webdrivers/geckodriver"
6
- require "webdrivers/iedriver"
7
- require "webdrivers/mswebdriver"
1
+ require 'webdrivers/selenium'
2
+ require 'webdrivers/logger'
3
+ require 'webdrivers/common'
4
+ require 'webdrivers/chromedriver'
5
+ require 'webdrivers/geckodriver'
6
+ require 'webdrivers/iedriver'
7
+ require 'webdrivers/mswebdriver'
8
8
 
9
9
  module Webdrivers
10
-
11
10
  class << self
12
-
13
11
  attr_accessor :proxy_addr, :proxy_port, :proxy_user, :proxy_pass, :install_dir
14
12
 
15
13
  def logger
@@ -21,7 +19,7 @@ module Webdrivers
21
19
  end
22
20
 
23
21
  def net_http_ssl_fix
24
- require "net_http_ssl_fix"
22
+ require 'net_http_ssl_fix'
25
23
  end
26
24
  end
27
25
  end
@@ -1,9 +1,9 @@
1
1
  require 'nokogiri'
2
+ require 'shellwords'
2
3
 
3
4
  module Webdrivers
4
5
  class Chromedriver < Common
5
6
  class << self
6
-
7
7
  def current_version
8
8
  Webdrivers.logger.debug 'Checking current version'
9
9
  return nil unless downloaded?
@@ -31,7 +31,7 @@ module Webdrivers
31
31
  private
32
32
 
33
33
  def file_name
34
- platform == "win" ? "chromedriver.exe" : "chromedriver"
34
+ platform == 'win' ? 'chromedriver.exe' : 'chromedriver'
35
35
  end
36
36
 
37
37
  def base_url
@@ -43,10 +43,10 @@ module Webdrivers
43
43
 
44
44
  @downloads ||= begin
45
45
  doc = Nokogiri::XML.parse(get(base_url))
46
- items = doc.css("Contents Key").collect(&:text)
46
+ items = doc.css('Contents Key').collect(&:text)
47
47
  items.select! { |item| item.include?(platform) }
48
48
  ds = items.each_with_object({}) do |item, hash|
49
- key = normalize item[/^[^\/]+/]
49
+ key = normalize item[%r{^[^/]+}]
50
50
  hash[key] = "#{base_url}/#{item}"
51
51
  end
52
52
  Webdrivers.logger.debug "Versions now located on downloads site: #{ds.keys}"
@@ -65,28 +65,35 @@ module Webdrivers
65
65
  # Returns currently installed Chrome version
66
66
  def chrome_version
67
67
  ver = case platform
68
- when 'win'
69
- chrome_on_windows
70
- when /linux/
71
- chrome_on_linux
72
- when 'mac'
73
- chrome_on_mac
74
- else
75
- raise NotImplementedError, 'Your OS is not supported by webdrivers gem.'
68
+ when 'win'
69
+ chrome_on_windows
70
+ when /linux/
71
+ chrome_on_linux
72
+ when 'mac'
73
+ chrome_on_mac
74
+ else
75
+ raise NotImplementedError, 'Your OS is not supported by webdrivers gem.'
76
76
  end.chomp
77
77
 
78
- if ver.nil? || ver.empty?
79
- raise StandardError, 'Failed to find Chrome binary or its version.'
80
- end
78
+ raise StandardError, 'Failed to find Chrome binary or its version.' if ver.nil? || ver.empty?
81
79
 
82
80
  # Google Chrome 73.0.3683.75 -> 73.0.3683.75
83
- ver[/(\d|\.)+/]
81
+ ver[/\d+\.\d+\.\d+\.\d+/]
84
82
  end
85
83
 
86
84
  def chrome_on_windows
87
85
  if browser_binary
88
86
  Webdrivers.logger.debug "Browser executable: '#{browser_binary}'"
89
- return `powershell (Get-ItemProperty '#{browser_binary}').VersionInfo.ProductVersion`
87
+ return `powershell (Get-ItemProperty '#{browser_binary}').VersionInfo.ProductVersion`.strip
88
+ end
89
+
90
+ # Workaround for Google Chrome when using Jruby on Windows.
91
+ # @see https://github.com/titusfortner/webdrivers/issues/41
92
+ if RUBY_PLATFORM == 'java' && platform == 'win'
93
+ ver = 'powershell (Get-Item -Path ((Get-ItemProperty "HKLM:\\Software\\Microsoft' \
94
+ "\\Windows\\CurrentVersion\\App` Paths\\chrome.exe\").\\'(default)\\'))" \
95
+ '.VersionInfo.ProductVersion'
96
+ return `#{ver}`.strip
90
97
  end
91
98
 
92
99
  # Default to Google Chrome
@@ -100,7 +107,7 @@ module Webdrivers
100
107
  def chrome_on_linux
101
108
  if browser_binary
102
109
  Webdrivers.logger.debug "Browser executable: '#{browser_binary}'"
103
- return `#{browser_binary} --product-version`.strip
110
+ return `#{Shellwords.escape browser_binary} --product-version`.strip
104
111
  end
105
112
 
106
113
  # Default to Google Chrome
@@ -112,7 +119,7 @@ module Webdrivers
112
119
  def chrome_on_mac
113
120
  if browser_binary
114
121
  Webdrivers.logger.debug "Browser executable: '#{browser_binary}'"
115
- return `#{browser_binary} --version`.strip
122
+ return `#{Shellwords.escape browser_binary} --version`.strip
116
123
  end
117
124
 
118
125
  # Default to Google Chrome
@@ -4,7 +4,6 @@ require 'zip'
4
4
  module Webdrivers
5
5
  class Common
6
6
  class << self
7
-
8
7
  attr_accessor :version
9
8
 
10
9
  def update
@@ -13,7 +12,7 @@ module Webdrivers
13
12
  end
14
13
 
15
14
  # Newer not specified or latest not found, so use existing
16
- return binary if desired_version.nil? && File.exists?(binary)
15
+ return binary if desired_version.nil? && File.exist?(binary)
17
16
 
18
17
  # Can't find desired and no existing binary
19
18
  if desired_version.nil?
@@ -22,7 +21,7 @@ module Webdrivers
22
21
  end
23
22
 
24
23
  if correct_binary?
25
- Webdrivers.logger.debug "Expected webdriver version found"
24
+ Webdrivers.logger.debug 'Expected webdriver version found'
26
25
  return binary
27
26
  end
28
27
 
@@ -31,19 +30,19 @@ module Webdrivers
31
30
  end
32
31
 
33
32
  def desired_version
34
- if self.version.is_a?(Gem::Version)
33
+ if version.is_a?(Gem::Version)
35
34
  version
36
- elsif self.version.nil?
35
+ elsif version.nil?
37
36
  latest_version
38
37
  else
39
- Gem::Version.new(self.version.to_s)
38
+ Gem::Version.new(version.to_s)
40
39
  end
41
40
  end
42
41
 
43
42
  def latest_version
44
- raise StandardError, "Can not reach site" unless site_available?
43
+ raise StandardError, 'Can not reach site' unless site_available?
45
44
 
46
- downloads.keys.sort.last
45
+ downloads.keys.max
47
46
  end
48
47
 
49
48
  def remove
@@ -52,21 +51,22 @@ module Webdrivers
52
51
  end
53
52
 
54
53
  def download
55
- raise StandardError, "Can not reach site" unless site_available?
54
+ raise StandardError, 'Can not reach site' unless site_available?
56
55
 
57
56
  url = downloads[desired_version]
58
57
  filename = File.basename url
59
58
 
60
- FileUtils.mkdir_p(install_dir) unless File.exists?(install_dir)
59
+ FileUtils.mkdir_p(install_dir) unless File.exist?(install_dir)
61
60
  Dir.chdir install_dir do
62
61
  FileUtils.rm_f filename
63
- open(filename, "wb") do |file|
62
+ File.open(filename, 'wb') do |file|
64
63
  file.print get(url)
65
64
  end
66
- raise "Could not download #{url}" unless File.exists? filename
65
+ raise "Could not download #{url}" unless File.exist? filename
66
+
67
67
  Webdrivers.logger.debug "Successfully downloaded #{filename}"
68
68
  dcf = decompress_file(filename)
69
- Webdrivers.logger.debug "Decompression Complete"
69
+ Webdrivers.logger.debug 'Decompression Complete'
70
70
  if dcf
71
71
  Webdrivers.logger.debug "Deleting #{filename}"
72
72
  FileUtils.rm_f filename
@@ -76,14 +76,15 @@ module Webdrivers
76
76
  extract_file(dcf)
77
77
  end
78
78
  end
79
- raise "Could not decompress #{filename} to get #{binary}" unless File.exists?(binary)
80
- FileUtils.chmod "ugo+rx", binary
79
+ raise "Could not decompress #{filename} to get #{binary}" unless File.exist?(binary)
80
+
81
+ FileUtils.chmod 'ugo+rx', binary
81
82
  Webdrivers.logger.debug "Completed download and processing of #{binary}"
82
83
  binary
83
84
  end
84
85
 
85
86
  def install_dir
86
- Webdrivers.install_dir || File.expand_path(File.join(ENV['HOME'], ".webdrivers"))
87
+ Webdrivers.install_dir || File.expand_path(File.join(ENV['HOME'], '.webdrivers'))
87
88
  end
88
89
 
89
90
  def binary
@@ -93,7 +94,7 @@ module Webdrivers
93
94
  protected
94
95
 
95
96
  def get(url, limit = 10)
96
- raise StandardError, 'Too many HTTP redirects' if limit == 0
97
+ raise StandardError, 'Too many HTTP redirects' if limit.zero?
97
98
 
98
99
  response = http.get_response(URI(url))
99
100
  Webdrivers.logger.debug "Get response: #{response.inspect}"
@@ -113,7 +114,7 @@ module Webdrivers
113
114
  def http
114
115
  if using_proxy
115
116
  Net::HTTP.Proxy(Webdrivers.proxy_addr, Webdrivers.proxy_port,
116
- Webdrivers.proxy_user, Webdrivers.proxy_pass)
117
+ Webdrivers.proxy_user, Webdrivers.proxy_pass)
117
118
  else
118
119
  Net::HTTP
119
120
  end
@@ -153,26 +154,26 @@ module Webdrivers
153
154
 
154
155
  def decompress_file(filename)
155
156
  case filename
156
- when /tar\.gz$/
157
- Webdrivers.logger.debug "Decompressing tar"
158
- untargz_file(filename)
159
- when /tar\.bz2$/
160
- Webdrivers.logger.debug "Decompressing bz2"
161
- system "tar xjf #{filename}"
162
- filename.gsub('.tar.bz2', '')
163
- when /\.zip$/
164
- Webdrivers.logger.debug "Decompressing zip"
165
- unzip_file(filename)
166
- else
167
- Webdrivers.logger.debug "No Decompression needed"
168
- nil
157
+ when /tar\.gz$/
158
+ Webdrivers.logger.debug 'Decompressing tar'
159
+ untargz_file(filename)
160
+ when /tar\.bz2$/
161
+ Webdrivers.logger.debug 'Decompressing bz2'
162
+ system "tar xjf #{filename}"
163
+ filename.gsub('.tar.bz2', '')
164
+ when /\.zip$/
165
+ Webdrivers.logger.debug 'Decompressing zip'
166
+ unzip_file(filename)
167
+ else
168
+ Webdrivers.logger.debug 'No Decompression needed'
169
+ nil
169
170
  end
170
171
  end
171
172
 
172
173
  def untargz_file(filename)
173
174
  tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
174
175
 
175
- File.open(file_name, "w+b") do |ucf|
176
+ File.open(file_name, 'w+b') do |ucf|
176
177
  tar_extract.each { |entry| ucf << entry.read }
177
178
  File.basename ucf
178
179
  end
@@ -182,7 +183,7 @@ module Webdrivers
182
183
  Zip::File.open("#{Dir.pwd}/#{filename}") do |zip_file|
183
184
  zip_file.each do |f|
184
185
  @top_path ||= f.name
185
- f_path = File.join(Dir.pwd, f.name)
186
+ f_path = File.join(Dir.pwd, f.name)
186
187
  FileUtils.rm_rf(f_path) if File.exist?(f_path)
187
188
  FileUtils.mkdir_p(File.dirname(f_path)) unless File.exist?(File.dirname(f_path))
188
189
  zip_file.extract(f, f_path)
@@ -193,7 +194,7 @@ module Webdrivers
193
194
 
194
195
  # Already have latest version downloaded?
195
196
  def correct_binary?
196
- desired_version == current_version && File.exists?(binary)
197
+ desired_version == current_version && File.exist?(binary)
197
198
  end
198
199
 
199
200
  def normalize(string)
@@ -201,4 +202,4 @@ module Webdrivers
201
202
  end
202
203
  end
203
204
  end
204
- end
205
+ end