webdrivers 3.3.3 → 3.4.0

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
  SHA1:
3
- metadata.gz: c25d5c4b45553a040f4dcbc33d70a23816dc9a7f
4
- data.tar.gz: 96891e1f94a57b105ae558cd2446d8844acf179a
3
+ metadata.gz: 6ed0fab7a9cc03600fc8fe15e15c34b7ca3ac206
4
+ data.tar.gz: 5aeb76b9a96babca62fee38da3ede1e113b72c7c
5
5
  SHA512:
6
- metadata.gz: 3ad52c20138460fdb87ebe70a249a4b3389f3e603e5e30de37442906d99c7ede0ae572c5a243177d3095811ea42bcd77ae989b850344f2a31a361f04a323d38c
7
- data.tar.gz: 38e11fb229f952fd08b248c1d69f1300ef40ebe67d8a27afc25e991a61cbf91915abeee4c4fdfcdde49f6d5885d3d41bb212f1de67f247745f859720e3e4fc42
6
+ metadata.gz: db7200151e7343fc6ec93b0654405a4f8b40a4bcc987c625b955b1c957d72d76f05a7774012601e8fda84ab98b01d2531dda6a64a8c186d350ee483b1b1a1e60
7
+ data.tar.gz: e66a2e52a69b65bf11db4f653c27123fb374bdfa7564e0779ce68e2059c959835e04061d83e5206ef86b92b032880b234cd422a9318068588860b2bfc3a8e5d0
@@ -1,3 +1,9 @@
1
+ ### 3.4.0 (2018-09-07)
2
+
3
+ * Allow public access to `#install_dir` and `#binary`
4
+ * Allow user to set the default download directory
5
+ * Improve version comparisons with use of `Gem::Version`
6
+
1
7
  ### 3.3.3 (2018-08-14)
2
8
 
3
9
  * Fix Geckodriver since Github changed its html again
@@ -10,7 +10,7 @@ module Webdrivers
10
10
 
11
11
  class << self
12
12
 
13
- attr_accessor :proxy_addr, :proxy_port, :proxy_user, :proxy_pass
13
+ attr_accessor :proxy_addr, :proxy_port, :proxy_user, :proxy_pass, :install_dir
14
14
 
15
15
  def logger
16
16
  @logger ||= Webdrivers::Logger.new
@@ -14,10 +14,6 @@ module Webdrivers
14
14
 
15
15
  private
16
16
 
17
- def normalize(string)
18
- string.size == 3 ? string.gsub('.', '.0').to_f : string.to_f
19
- end
20
-
21
17
  def file_name
22
18
  platform == "win" ? "chromedriver.exe" : "chromedriver"
23
19
  end
@@ -41,7 +41,7 @@ module Webdrivers
41
41
  url = download_url(version)
42
42
  filename = File.basename url
43
43
 
44
- Dir.mkdir(install_dir) unless File.exists?(install_dir)
44
+ FileUtils.mkdir_p(install_dir) unless File.exists?(install_dir)
45
45
  Dir.chdir install_dir do
46
46
  FileUtils.rm_f filename
47
47
  open(filename, "wb") do |file|
@@ -66,6 +66,14 @@ module Webdrivers
66
66
  binary
67
67
  end
68
68
 
69
+ def install_dir
70
+ Webdrivers.install_dir || File.expand_path(File.join(ENV['HOME'], ".webdrivers"))
71
+ end
72
+
73
+ def binary
74
+ File.join install_dir, file_name
75
+ end
76
+
69
77
  protected
70
78
 
71
79
  def get(url, limit = 10)
@@ -100,7 +108,14 @@ module Webdrivers
100
108
  end
101
109
 
102
110
  def download_url(version)
103
- downloads[version || latest]
111
+ key = if version.is_a?(Gem::Version)
112
+ version
113
+ elsif version.nil?
114
+ latest
115
+ else
116
+ Gem::Version.new(version.to_s)
117
+ end
118
+ downloads[key]
104
119
  end
105
120
 
106
121
  def downloaded?
@@ -109,10 +124,6 @@ module Webdrivers
109
124
  result
110
125
  end
111
126
 
112
- def binary
113
- File.join install_dir, file_name
114
- end
115
-
116
127
  def site_available?
117
128
  get(base_url)
118
129
  Webdrivers.logger.debug "Found Site: #{base_url}"
@@ -174,15 +185,14 @@ module Webdrivers
174
185
  @top_path
175
186
  end
176
187
 
177
- def install_dir
178
- File.expand_path(File.join(ENV['HOME'], ".webdrivers")).tap { |dir| FileUtils.mkdir_p dir }
179
- end
180
-
181
188
  # Already have latest version downloaded?
182
189
  def correct_binary?
183
190
  latest == current && File.exists?(binary)
184
191
  end
185
192
 
193
+ def normalize(string)
194
+ Gem::Version.new(string)
195
+ end
186
196
  end
187
197
  end
188
198
  end
@@ -14,10 +14,6 @@ module Webdrivers
14
14
 
15
15
  private
16
16
 
17
- def normalize(string)
18
- string.match(/(\d+)\.(\d+\.\d+)/).to_a.map {|v| v.tr('.', '')}[1..-1].join('.').to_f
19
- end
20
-
21
17
  def downloads
22
18
  raise StandardError, "Can not reach site" unless site_available?
23
19
  Webdrivers.logger.debug "Versions previously located on downloads site: #{@downloads.keys}" if @downloads
@@ -20,10 +20,6 @@ module Webdrivers
20
20
 
21
21
  private
22
22
 
23
- def normalize(string)
24
- Gem::Version.new(string)
25
- end
26
-
27
23
  def file_name
28
24
  "IEDriverServer.exe"
29
25
  end
@@ -28,10 +28,6 @@ module Webdrivers
28
28
 
29
29
  private
30
30
 
31
- def normalize(string)
32
- string.match(/(\d+)\.(\d+\.\d+)/).to_a.map { |v| v.tr('.', '') }[1 .. -1].join('.').to_f
33
- end
34
-
35
31
  def file_name
36
32
  "MicrosoftWebDriver.exe"
37
33
  end
@@ -5,12 +5,16 @@ describe Webdrivers::Chromedriver do
5
5
  let(:chromedriver) { Webdrivers::Chromedriver }
6
6
 
7
7
  it 'parses chromedriver versions before 2.10' do
8
- expect(chromedriver.send :normalize, '2.9').to eq 2.09
8
+ expect(chromedriver.send(:normalize, '2.9').version).to eq '2.9'
9
9
  end
10
10
 
11
11
  it 'finds latest version' do
12
- expect(chromedriver.latest).to be > 2.30
13
- expect(chromedriver.latest).to be < 2.9
12
+ old_version = Gem::Version.new("2.30")
13
+ future_version = Gem::Version.new("2.90")
14
+ latest_version = chromedriver.latest
15
+
16
+ expect(latest_version).to be > old_version
17
+ expect(latest_version).to be < future_version
14
18
  end
15
19
 
16
20
  it 'downloads latest version by default' do
@@ -19,10 +23,16 @@ describe Webdrivers::Chromedriver do
19
23
  expect(chromedriver.current).to eq chromedriver.latest
20
24
  end
21
25
 
22
- it 'downloads specified version' do
26
+ it 'downloads specified version by Float' do
23
27
  chromedriver.remove
24
28
  chromedriver.download(2.29)
25
- expect(chromedriver.current).to eq 2.29
29
+ expect(chromedriver.current.version).to eq '2.29'
30
+ end
31
+
32
+ it 'downloads specified version by String' do
33
+ chromedriver.remove
34
+ chromedriver.download('2.29')
35
+ expect(chromedriver.current.version).to eq '2.29'
26
36
  end
27
37
 
28
38
  it 'removes chromedriver' do
@@ -42,4 +52,18 @@ describe Webdrivers::Chromedriver do
42
52
  end
43
53
  end
44
54
 
55
+ it 'allows setting of install directory' do
56
+ begin
57
+ install_dir = File.expand_path(File.join(ENV['HOME'], ".webdrivers2"))
58
+ Webdrivers.install_dir = install_dir
59
+ expect(chromedriver.install_dir).to eq install_dir
60
+ ensure
61
+ Webdrivers.install_dir = nil
62
+ end
63
+ end
64
+
65
+ it 'returns full location of binary' do
66
+ install_dir = File.expand_path(File.join(ENV['HOME'], ".webdrivers"))
67
+ expect(chromedriver.binary).to match /#{install_dir}\/chromedriver/
68
+ end
45
69
  end
@@ -18,8 +18,12 @@ describe Webdrivers::Geckodriver do
18
18
  end
19
19
 
20
20
  it 'finds latest version' do
21
- expect(geckodriver.latest).to be > 0.17
22
- expect(geckodriver.latest).to be <= 0.30
21
+ old_version = Gem::Version.new('0.17')
22
+ future_version = Gem::Version.new('0.30')
23
+ latest_version = geckodriver.latest
24
+
25
+ expect(latest_version).to be > old_version
26
+ expect(latest_version).to be < future_version
23
27
  end
24
28
 
25
29
  it 'downloads latest version by default' do
@@ -29,8 +33,8 @@ describe Webdrivers::Geckodriver do
29
33
 
30
34
  it 'downloads specified version' do
31
35
  geckodriver.remove
32
- geckodriver.download(0.17)
33
- expect(geckodriver.current).to eq 0.17
36
+ geckodriver.download('0.17.0')
37
+ expect(geckodriver.current.version).to eq '0.17.0'
34
38
  end
35
39
 
36
40
  it 'removes geckodriver' do
@@ -5,7 +5,12 @@ describe Webdrivers::IEdriver do
5
5
  let(:iedriver) { Webdrivers::IEdriver }
6
6
 
7
7
  it 'finds latest version' do
8
- expect(iedriver.latest.segments).to eq [3, 12, 0]
8
+ old_version = Gem::Version.new("3.12.0")
9
+ future_version = Gem::Version.new("3.60.0")
10
+ latest_version = iedriver.latest
11
+
12
+ expect(latest_version).to be > old_version
13
+ expect(latest_version).to be < future_version
9
14
  end
10
15
 
11
16
  it 'downloads iedriver' do
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "webdrivers"
6
- s.version = "3.3.3"
6
+ s.version = "3.4.0"
7
7
  s.authors = ["Titus Fortner"]
8
8
  s.email = ["titusfortner@gmail.com"]
9
9
  s.homepage = "https://github.com/titusfortner/webdrivers"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webdrivers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-14 00:00:00.000000000 Z
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec