chromedriver_update 0.1.9 → 0.2.1

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: bf5f436a17335dc1b8cf38d067e07d1b855ccd7c059c53b2c2186dee5c2d1e0c
4
- data.tar.gz: f8047afe2976791fd8c5d30660195ebb1d8a4ea1e2c69036f6ac6d86df42a657
3
+ metadata.gz: d4b59db9e7b39a75b4926a21e023dd615747bc3583ed1fdec4c42e123953801e
4
+ data.tar.gz: 5aea95d538c13ca01c3c21ad9405c6665e83a51756593c3f04440744796f192d
5
5
  SHA512:
6
- metadata.gz: c5439717a74dfd5cac39ecc0479241ae9c7c8965c83398271ba7d5a2ee0d1865e5a982fe88e49694ffce669032f5cfc817bf49580e1a3469551d51e16ceeab9b
7
- data.tar.gz: 4f1b9b5c7af90029805d083eab26134f03a1fef4412dc3ec180cb0bb3b1d56af9bfccc6216839fac28b846b0ebc7eacc22c7922622ccd4f5461565a49c3477f4
6
+ metadata.gz: fb6007bf3257d32d59c12094a68f21bc4636ab9bdf88bf750e2f7cc963d2dda408f96d91960a2f0c068cbf2626b53ad4e579b952aad953c9f22b124c01cbd999
7
+ data.tar.gz: a7e66a2b962aeebe9598c7d878d3e529c0b48b6ed6dabd355883a2ad6deeb1ecf48ca4c557ea0879a4ffb227ccf60c96e313768a628fd3267da1d013b4090285
@@ -6,17 +6,19 @@ arg = ARGV[0]
6
6
 
7
7
  if %w[version -v --version].include?(arg)
8
8
  puts "#{ChromedriverUpdate::VERSION}"
9
- elsif arg.nil? || arg == ''
10
- ChromedriverUpdate.auto_update_chromedriver
9
+ elsif arg.nil? || arg == '' || %w[force -f --force].include?(arg)
10
+ force = %w[force -f --force].include?(arg)
11
+ ChromedriverUpdate.auto_update_chromedriver force: force
11
12
  else
12
13
  puts <<-TEXT
13
14
 
14
15
  chromedriver_update #{ChromedriverUpdate::VERSION}
15
16
  https://github.com/magynhard/chromedriver_update
16
17
 
18
+ chromedriver_update # automatically update the current chromedriver version fitting to the currently installed chrome
19
+ chromedriver_update -f --force # force automatic update, even if the latest version is already installed
17
20
  chromedriver_update -h --help # show this info
18
21
  chromedriver_update -v --version # show the libraries current version
19
- chromedriver_update # automatically update the current chromedriver version fitting to the currently installed chrome
20
22
 
21
23
  TEXT
22
24
  end
@@ -1,3 +1,3 @@
1
1
  class ChromedriverUpdate
2
- VERSION = '0.1.9'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
@@ -16,9 +16,12 @@ class ChromedriverUpdate
16
16
  #
17
17
  # Update the installed version of chromedriver automatically fitting to the currently installed version of chrome
18
18
  #
19
+ # @param [Boolean] force=false force the update, even if the version is already installed
20
+ #
19
21
  def self.auto_update_chromedriver(force: false)
20
22
  if installed_chrome_version.split(".").first != installed_chromedriver_version.split(".").first || force
21
23
  original_chromedriver_version = installed_chromedriver_version
24
+ original_chromedriver_path = chromedriver_path
22
25
  chromedriver_zip = HTTParty.get(chromedriver_link_for_version(installed_chrome_version))
23
26
  if chromedriver_zip.code == 404 # fallback to latest lower version
24
27
  chromedriver_zip = HTTParty.get(chromedriver_closest_link_for_version(installed_chrome_version))
@@ -32,13 +35,18 @@ class ChromedriverUpdate
32
35
  FileUtils.rm_f(download_path)
33
36
  entry.extract(download_path)
34
37
  FileUtils.mv(download_path, chromedriver_path, force: true)
35
- begin
36
- FileUtils.chmod("+x", chromedriver_path)
37
- rescue
38
- unless OS.windows?
38
+ unless OS.windows?
39
+ begin
40
+ FileUtils.chmod("+x", original_chromedriver_path)
41
+ `chmod +x "#{original_chromedriver_path}"`
42
+ rescue
39
43
  begin
40
- `sudo chmod +x "#{chromedriver_path}"`
44
+ `chmod +x "#{original_chromedriver_path}"`
41
45
  rescue
46
+ begin
47
+ `sudo chmod +x "#{original_chromedriver_path}"`
48
+ rescue
49
+ end
42
50
  end
43
51
  end
44
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chromedriver_update
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthäus Beyrle