webdrivers 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +13 -1
- data/lib/webdrivers.rb +12 -2
- data/lib/webdrivers/chromedriver.rb +1 -1
- data/lib/webdrivers/common.rb +50 -34
- data/lib/webdrivers/geckodriver.rb +1 -1
- data/lib/webdrivers/iedriver.rb +1 -1
- data/spec/proxy_support_spec.rb +45 -0
- data/webdrivers.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d9e5fa3b0bb58f58355559ad96a2915d089aeea
|
4
|
+
data.tar.gz: 9bed1f9723c15044589a1e514db681fa28190f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22d871b657056542a63a7f8a336b2d2877a5426ea291ca23bb3c2d1fa01a9992015da95a49860276f7d563e079eb960ee7ead2f423df591bd646c92ab67c8086
|
7
|
+
data.tar.gz: ac8b1ba73a0c7e037419d13ddb3d18d77179265584d907001a1e14736544863b3dab6b1a72626c1399f1a961696c2c60a27943138f0a93fd83653c37a74946bc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,19 @@ in your Gemfile:
|
|
24
24
|
|
25
25
|
in your project:
|
26
26
|
|
27
|
-
`require 'webdrivers'
|
27
|
+
`require 'webdrivers'
|
28
|
+
|
29
|
+
If there is a proxy between you and the Internet then you will need to configure
|
30
|
+
the gem to use the proxy. You can do this by calling the `configure` method.
|
31
|
+
|
32
|
+
````ruby
|
33
|
+
Webdrivers.configure do |config|
|
34
|
+
config.proxy_addr = 'myproxy_address.com'
|
35
|
+
config.proxy_port = '8080'
|
36
|
+
config.proxy_user = 'username'
|
37
|
+
config.proxy_pass = 'password'
|
38
|
+
end
|
39
|
+
````
|
28
40
|
|
29
41
|
# License
|
30
42
|
|
data/lib/webdrivers.rb
CHANGED
@@ -7,7 +7,17 @@ require "webdrivers/iedriver"
|
|
7
7
|
require "webdrivers/mswebdriver"
|
8
8
|
|
9
9
|
module Webdrivers
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
attr_accessor :proxy_addr, :proxy_port, :proxy_user, :proxy_pass
|
14
|
+
|
15
|
+
def logger
|
16
|
+
@logger ||= Webdrivers::Logger.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure
|
20
|
+
yield self
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
@@ -31,7 +31,7 @@ module Webdrivers
|
|
31
31
|
Webdrivers.logger.debug "Versions previously located on downloads site: #{@downloads.keys}" if @downloads
|
32
32
|
|
33
33
|
@downloads ||= begin
|
34
|
-
doc = Nokogiri::XML.parse(
|
34
|
+
doc = Nokogiri::XML.parse(get(base_url))
|
35
35
|
items = doc.css("Contents Key").collect(&:text)
|
36
36
|
items.select! {|item| item.include?(platform)}
|
37
37
|
ds = items.each_with_object({}) do |item, hash|
|
data/lib/webdrivers/common.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'rubygems/package'
|
2
|
-
require 'open-uri'
|
3
2
|
require 'zip'
|
4
3
|
|
5
4
|
module Webdrivers
|
@@ -31,7 +30,7 @@ module Webdrivers
|
|
31
30
|
Dir.chdir install_dir do
|
32
31
|
FileUtils.rm_f filename
|
33
32
|
open(filename, "wb") do |file|
|
34
|
-
file.print
|
33
|
+
file.print get(url)
|
35
34
|
end
|
36
35
|
raise "Could not download #{url}" unless File.exists? filename
|
37
36
|
Webdrivers.logger.debug "Successfully downloaded #{filename}"
|
@@ -52,20 +51,37 @@ module Webdrivers
|
|
52
51
|
binary
|
53
52
|
end
|
54
53
|
|
55
|
-
|
54
|
+
protected
|
55
|
+
|
56
|
+
def get(url, limit = 10)
|
57
|
+
raise StandardError, 'Too many HTTP redirects' if limit == 0
|
58
|
+
|
59
|
+
response = http.get_response(URI(url))
|
60
|
+
|
61
|
+
case response
|
62
|
+
when Net::HTTPSuccess then
|
63
|
+
response.body
|
64
|
+
when Net::HTTPRedirection
|
65
|
+
location = response['location']
|
66
|
+
Webdrivers.logger.debug "Redirected to #{location}"
|
67
|
+
get(location, limit - 1)
|
68
|
+
else
|
69
|
+
response.value
|
70
|
+
end
|
71
|
+
end
|
56
72
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
if proxy_uri && proxy_user
|
63
|
-
{proxy_http_basic_authentication: [proxy_uri, proxy_user, proxy_pass]}
|
64
|
-
elsif proxy_uri
|
65
|
-
{proxy: proxy_uri}
|
66
|
-
else
|
67
|
-
{}
|
73
|
+
def http
|
74
|
+
if using_proxy
|
75
|
+
return Net::HTTP.Proxy(Webdrivers.proxy_addr, Webdrivers.proxy_port,
|
76
|
+
Webdrivers.proxy_user, Webdrivers.proxy_pass)
|
68
77
|
end
|
78
|
+
return Net::HTTP
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def using_proxy
|
84
|
+
Webdrivers.proxy_addr && Webdrivers.proxy_port
|
69
85
|
end
|
70
86
|
|
71
87
|
def download_url(version)
|
@@ -84,7 +100,7 @@ module Webdrivers
|
|
84
100
|
|
85
101
|
# TODO - specify what gets rescued
|
86
102
|
def site_available?
|
87
|
-
|
103
|
+
get(base_url)
|
88
104
|
Webdrivers.logger.debug "Found Site: #{base_url}"
|
89
105
|
true
|
90
106
|
rescue
|
@@ -95,30 +111,30 @@ module Webdrivers
|
|
95
111
|
def platform
|
96
112
|
cfg = RbConfig::CONFIG
|
97
113
|
case cfg['host_os']
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
114
|
+
when /linux/
|
115
|
+
cfg['host_cpu'] =~ /x86_64|amd64/ ? "linux64" : "linux32"
|
116
|
+
when /darwin/
|
117
|
+
"mac"
|
118
|
+
else
|
119
|
+
"win"
|
104
120
|
end
|
105
121
|
end
|
106
122
|
|
107
123
|
def decompress_file(filename)
|
108
124
|
case filename
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
125
|
+
when /tar\.gz$/
|
126
|
+
Webdrivers.logger.debug "Decompressing tar"
|
127
|
+
untargz_file(filename)
|
128
|
+
when /tar\.bz2$/
|
129
|
+
Webdrivers.logger.debug "Decompressing bz2"
|
130
|
+
system "tar xjf #{filename}"
|
131
|
+
filename.gsub('.tar.bz2', '')
|
132
|
+
when /\.zip$/
|
133
|
+
Webdrivers.logger.debug "Decompressing zip"
|
134
|
+
unzip_file(filename)
|
135
|
+
else
|
136
|
+
Webdrivers.logger.debug "No Decompression needed"
|
137
|
+
nil
|
122
138
|
end
|
123
139
|
end
|
124
140
|
|
@@ -23,7 +23,7 @@ module Webdrivers
|
|
23
23
|
Webdrivers.logger.debug "Versions previously located on downloads site: #{@downloads.keys}" if @downloads
|
24
24
|
|
25
25
|
@downloads ||= begin
|
26
|
-
doc = Nokogiri::XML.parse(
|
26
|
+
doc = Nokogiri::XML.parse(get(base_url))
|
27
27
|
items = doc.css(".release-downloads a").collect {|item| item["href"]}
|
28
28
|
items.reject! {|item| item.include?('archive')}
|
29
29
|
items.select! {|item| item.include?(platform)}
|
data/lib/webdrivers/iedriver.rb
CHANGED
@@ -31,7 +31,7 @@ module Webdrivers
|
|
31
31
|
Webdrivers.logger.debug "Versions previously located on downloads site: #{@downloads.keys}" if @downloads
|
32
32
|
|
33
33
|
@downloads ||= begin
|
34
|
-
doc = Nokogiri::XML.parse(
|
34
|
+
doc = Nokogiri::XML.parse(get(base_url))
|
35
35
|
items = doc.css("Key").collect(&:text)
|
36
36
|
items.select! { |item| item.include?('IEDriverServer_Win32') }
|
37
37
|
ds = items.each_with_object({}) do |item, hash|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class FakeDriver < Webdrivers::Common
|
4
|
+
def self.http_object
|
5
|
+
self.http
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Support for proxies" do
|
10
|
+
let(:http_object) { FakeDriver.http_object }
|
11
|
+
|
12
|
+
before do
|
13
|
+
Webdrivers.proxy_addr = nil
|
14
|
+
Webdrivers.proxy_port = nil
|
15
|
+
Webdrivers.proxy_user = nil
|
16
|
+
Webdrivers.proxy_pass = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should allow the proxy values to be set via configuration' do
|
20
|
+
Webdrivers.configure do |config|
|
21
|
+
config.proxy_addr = 'proxy_addr'
|
22
|
+
config.proxy_port = '8888'
|
23
|
+
config.proxy_user = 'proxy_user'
|
24
|
+
config.proxy_pass = 'proxy_pass'
|
25
|
+
end
|
26
|
+
|
27
|
+
expect(Webdrivers.proxy_addr).to eql 'proxy_addr'
|
28
|
+
expect(Webdrivers.proxy_port).to eql '8888'
|
29
|
+
expect(Webdrivers.proxy_user).to eql 'proxy_user'
|
30
|
+
expect(Webdrivers.proxy_pass).to eql 'proxy_pass'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should use the Proxy when the proxy_addr is set' do
|
34
|
+
Webdrivers.configure do |config|
|
35
|
+
config.proxy_addr = 'proxy_addr'
|
36
|
+
config.proxy_port = '8080'
|
37
|
+
end
|
38
|
+
|
39
|
+
expect(http_object.instance_variable_get('@is_proxy_class')).to be true
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should not use the Proxy when proxy is not configured' do
|
43
|
+
expect(http_object.instance_variable_get('@is_proxy_class')).to be false
|
44
|
+
end
|
45
|
+
end
|
data/webdrivers.gemspec
CHANGED
@@ -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.2.
|
6
|
+
s.version = "3.2.1"
|
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.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- spec/geckodriver_spec.rb
|
108
108
|
- spec/iedriver_spec.rb
|
109
109
|
- spec/mswebdriver_spec.rb
|
110
|
+
- spec/proxy_support_spec.rb
|
110
111
|
- spec/spec_helper.rb
|
111
112
|
- webdrivers.gemspec
|
112
113
|
homepage: https://github.com/titusfortner/webdrivers
|
@@ -138,4 +139,5 @@ test_files:
|
|
138
139
|
- spec/geckodriver_spec.rb
|
139
140
|
- spec/iedriver_spec.rb
|
140
141
|
- spec/mswebdriver_spec.rb
|
142
|
+
- spec/proxy_support_spec.rb
|
141
143
|
- spec/spec_helper.rb
|