webdrivers 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 46f1acf45fd7372da5ea9c5af77f903c4a9758bf
4
+ data.tar.gz: c6f35b74fba542c6eacdbccad28b1001edd6ecdb
5
+ SHA512:
6
+ metadata.gz: e1703697fe5b2f87077b2b24d92c7806b941f3444676c0a84a85437a206ecb30d82e20e7700bc11e27164212e54d61068c6a3802dbdffdb8d46d9710cd64ab1c
7
+ data.tar.gz: 607a53cd50642d97e888e068ee669cc04b4490d683375f00e9e312d14f930b43a11dcb14e7f306438a0cac2b6ac6e6990705786990dd28aa1e1a04f01e7c5035
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ chromedriver.log
6
+ /.idea/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,69 @@
1
+ Changelog
2
+ ==========
3
+
4
+ 2.1.0 - 2016-11-25
5
+ ----------
6
+
7
+ * Implemented geckodriver support
8
+
9
+
10
+ 2.0.0 - 2016-11-25
11
+ ----------
12
+
13
+ * Renamed fork from chromedriver-helper to webdrivers
14
+ * Re-implemented chromedriver usage
15
+
16
+
17
+ 1.0.0 - 2015-06-06
18
+ ----------
19
+
20
+ * Updated gemspec info. Happy 1.0!
21
+
22
+
23
+ 0.0.9 - 2015-06-06
24
+ ----------
25
+
26
+ * No longer require 'curl' or 'wget', or 'unzip' utilities to be installed. You know, for Windows. (Thanks, @elementc!)
27
+ * Support JRuby by removing dependency on native-C-extension gem. (Thanks, Marques Lee!)
28
+
29
+
30
+ 0.0.8 - 2015-01-23
31
+ ----------
32
+
33
+ * Guaranteeing that we get the *latest* version of chromedriver. (#15) (Thanks, @AlexRiedler!)
34
+
35
+
36
+ 0.0.7 - 26 Aug 2014
37
+ ----------
38
+
39
+ * Added support for windows binaries. (Thanks, @elementc!)
40
+
41
+
42
+ 0.0.6 - 26 Aug 2014
43
+ ----------
44
+
45
+ * Fixed to work with new Google download page. #7 (Thanks, @mars!)
46
+
47
+
48
+ 0.0.5 - 15 Aug 2012
49
+ ----------
50
+
51
+ * Fixed support for JRuby on non-Windows platforms. #4 (Thanks, Tim Olsen!)
52
+
53
+
54
+ 0.0.4 - 1 Aug 2012
55
+ ----------
56
+
57
+ * Including `chromedriver-update` to easily allow people to force-upgrade. #3
58
+
59
+
60
+ 0.0.3 - 20 Mar 2012
61
+ ----------
62
+
63
+ * Updated download URL. #2 (Thanks, Alistair Hutchison!)
64
+
65
+
66
+ 0.0.2 - 6 December 2011
67
+ ----------
68
+
69
+ * Birthday!
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in webdrivers.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2011,2012,2013,2014,2015: [Mike Dalessio](http://mike.daless.io)
4
+ Copyright (c) 2016: Titus Fortner
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Webdrivers
2
+
3
+ [![Build status](https://api.travis-ci.org/titusfortner/webdrivers.svg)](https://travis-ci.org/titusfortner/webdrivers)
4
+
5
+ Run Selenium tests more easily with install and updates for all supported webdrivers.
6
+
7
+ # Description
8
+
9
+ `webdrivers` installs driver executables, in your gem path.
10
+ `chromedriver` and `geckodriver` are currently supported.
11
+
12
+ Drivers are stored in `~/.webdrivers` directory and used within the context of your gem path
13
+
14
+
15
+ # Usage
16
+
17
+ `gem install webdrivers`
18
+
19
+ or in your Gemfile:
20
+
21
+ `gem "webdrivers", "~> 2.1"`
22
+
23
+
24
+ # License
25
+
26
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT),
27
+ see LICENSE.txt for full details and copyright.
28
+
29
+
30
+ # Contributing
31
+
32
+ Bug reports and pull requests are welcome [on GitHub](https://github.com/titusfortner/webdrivers).
33
+
34
+
35
+ # Credit
36
+
37
+ This is a fork of [chromedriver-helper](https://github.com/flavorjones/chromedriver-helper) gem
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/chromedriver ADDED
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require "webdrivers"
4
+
5
+ Webdrivers::Chromedriver.install *ARGV
data/bin/geckodriver ADDED
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require "webdrivers"
4
+
5
+ Webdrivers::Geckodriver.install *ARGV
@@ -0,0 +1,45 @@
1
+ require 'nokogiri'
2
+
3
+ module Webdrivers
4
+ class Chromedriver < Common
5
+
6
+ class << self
7
+ def file_name
8
+ platform == "win" ? "chromedriver.exe" : "chromedriver"
9
+ end
10
+
11
+ def current_version
12
+ return nil unless File.exists?(binary_path)
13
+ %x(#{binary_path} --version).match(/ChromeDriver (\d\.\d+)/)[1]
14
+ end
15
+
16
+ def newest_version
17
+ padded = downloads.keys.each_with_object({}) do |version, hash|
18
+ matched = version.match(/^(\d+)\.(\d+)$/)
19
+ minor = sprintf '%02d', matched[2]
20
+ hash["#{matched[1]}.#{minor}"] = version
21
+ end
22
+ padded.keys.sort.last
23
+ end
24
+
25
+ def downloads
26
+ doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url))
27
+ items = doc.css("Contents Key").collect(&:text)
28
+ items.select! { |item| item.include?(platform) }
29
+ items.each_with_object({}) do |item, hash|
30
+ hash[item[/^[^\/]+/]] = "#{base_url}/#{item}"
31
+ end
32
+ end
33
+
34
+ def decompress_file(filename)
35
+ Archive::Zip.extract(filename, '.', :overwrite => :all)
36
+ end
37
+
38
+ def base_url
39
+ 'http://chromedriver.storage.googleapis.com'
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,67 @@
1
+ require 'rubygems/package'
2
+
3
+ module Webdrivers
4
+ class Common
5
+
6
+ class << self
7
+ def install *args
8
+ download
9
+ exec binary_path, *args
10
+ end
11
+
12
+ def download
13
+ return if File.exists?(binary_path) && !internet_connection?
14
+ raise StandardError, "Unable to Reach #{base_url}" unless internet_connection?
15
+ return if newest_version == current_version
16
+
17
+ url = download_url
18
+ filename = File.basename url
19
+ Dir.chdir platform_install_dir do
20
+ FileUtils.rm_f filename
21
+ File.open(filename, "wb") do |saved_file|
22
+ URI.parse(url).open("rb") do |read_file|
23
+ saved_file.write(read_file.read)
24
+ end
25
+ end
26
+ raise "Could not download #{url}" unless File.exists? filename
27
+ decompress_file(filename)
28
+ end
29
+ raise "Could not unzip #{filename} to get #{binary_path}" unless File.exists? binary_path
30
+ FileUtils.chmod "ugo+rx", binary_path
31
+ end
32
+
33
+ def download_url(version = nil)
34
+ downloads[version || newest_version]
35
+ end
36
+
37
+ def binary_path
38
+ File.join platform_install_dir, file_name
39
+ end
40
+
41
+ def platform_install_dir
42
+ File.join(install_dir, platform).tap { |dir| FileUtils.mkdir_p dir }
43
+ end
44
+
45
+ def install_dir
46
+ File.expand_path(File.join(ENV['HOME'], ".webdrivers")).tap { |dir| FileUtils.mkdir_p dir}
47
+ end
48
+
49
+ def platform
50
+ cfg = RbConfig::CONFIG
51
+ case cfg['host_os']
52
+ when /linux/ then
53
+ cfg['host_cpu'] =~ /x86_64|amd64/ ? "linux64" : "linux32"
54
+ when /darwin/ then "mac"
55
+ else "win"
56
+ end
57
+ end
58
+
59
+ def internet_connection?
60
+ true if open(base_url)
61
+ rescue
62
+ false
63
+ end
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,51 @@
1
+ require 'nokogiri'
2
+
3
+ module Webdrivers
4
+ class Geckodriver < Common
5
+
6
+ class << self
7
+ def file_name
8
+ platform == "win" ? "geckodriver.exe" : "geckodriver"
9
+ end
10
+
11
+ def current_version
12
+ return nil unless File.exists?(binary_path)
13
+ %x(#{binary_path} --version).match(/geckodriver (\d\.\d+\.\d+)/)[1]
14
+ end
15
+
16
+ def newest_version
17
+ padded = downloads.keys.each_with_object({}) do |version, hash|
18
+ matched = version.match(/^(\d+)\.(\d+)\.(\d+)$/)
19
+ minor = sprintf '%02d', matched[2]
20
+ hash["#{matched[1]}.#{minor}.#{matched[3]}"] = version
21
+ end
22
+ padded.keys.sort.last
23
+ end
24
+
25
+ def downloads
26
+ doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url))
27
+ items = doc.css(".release-downloads a").collect {|item| item["href"]}
28
+ items.reject! {|item| item.include?('archive')}
29
+ items.select! {|item| item.include?(platform)}
30
+ items.each_with_object({}) do |item, hash|
31
+ hash[item[/v(\d+\.\d+\.\d+)/, 1]] = "https://github.com#{item}"
32
+ end
33
+ end
34
+
35
+ def decompress_file(filename)
36
+ tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
37
+ tar_extract.rewind
38
+
39
+ ucf = File.open(file_name, "w+")
40
+ tar_extract.each { |entry| ucf << entry.read }
41
+ ucf.close
42
+ end
43
+
44
+ def base_url
45
+ 'https://github.com/mozilla/geckodriver/releases'
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+ end
data/lib/webdrivers.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "webdrivers/common"
2
+ require "webdrivers/chromedriver"
3
+ require "webdrivers/geckodriver"
4
+ require 'fileutils'
5
+ require 'rbconfig'
6
+ require 'open-uri'
7
+ require 'archive/zip'
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ describe Webdrivers::Chromedriver do
4
+
5
+ let(:chromedriver) { Webdrivers::Chromedriver }
6
+
7
+ it { expect(chromedriver.newest_version.to_f).to be >= 2.25 }
8
+
9
+ it { expect(chromedriver.downloads.size).to be >= 26 }
10
+
11
+ context "on a linux platform" do
12
+ before { allow(chromedriver).to receive(:platform) { "linux32" } }
13
+
14
+ it { expect(chromedriver.file_name).to match(/chromedriver$/) }
15
+
16
+ it { expect(chromedriver.binary_path).to match '.webdrivers/linux32/chromedriver' }
17
+
18
+ it { expect(chromedriver.download_url('2.24')).to match("2.24/chromedriver_linux32.zip") }
19
+ end
20
+
21
+ context "on a windows platform" do
22
+ before { allow(chromedriver).to receive(:platform) { "win" } }
23
+
24
+ it { expect(chromedriver.file_name).to match(/chromedriver\.exe$/) }
25
+
26
+ it { expect(chromedriver.binary_path).to match '.webdrivers/win/chromedriver' }
27
+
28
+ it { expect(chromedriver.download_url('2.24')).to match("2.24/chromedriver_win32.zip") }
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ describe Webdrivers::Geckodriver do
4
+
5
+ let(:geckodriver) { Webdrivers::Geckodriver }
6
+
7
+ it { expect(geckodriver.newest_version.to_f).to be >= 0.11 }
8
+
9
+ it { expect(geckodriver.downloads.size).to be >= 4 }
10
+
11
+ context "on a linux platform" do
12
+ before { allow(geckodriver).to receive(:platform) { "linux32" } }
13
+
14
+ it { expect(geckodriver.file_name).to match(/geckodriver$/) }
15
+
16
+ it { expect(geckodriver.binary_path).to match '.webdrivers/linux32/geckodriver' }
17
+
18
+ it { expect(geckodriver.download_url('0.11.0')).to match("v0.11.0/geckodriver-v0.11.0-linux32.tar.gz") }
19
+ end
20
+
21
+ context "on a windows platform" do
22
+ before { allow(geckodriver).to receive(:platform) { "win" } }
23
+
24
+ it { expect(geckodriver.file_name).to match(/geckodriver\.exe$/) }
25
+
26
+ it { expect(geckodriver.binary_path).to match '.webdrivers/win/geckodriver' }
27
+
28
+ it { expect(geckodriver.download_url('0.9.0')).to match("v0.9.0/geckodriver-v0.9.0-win64.zip") }
29
+ end
30
+ end
@@ -0,0 +1,2 @@
1
+ require "rspec"
2
+ require "webdrivers"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "webdrivers"
6
+ s.version = "2.1.0"
7
+ s.authors = ["Titus Fortner"]
8
+ s.email = ["titusfortner@gmail.com"]
9
+ s.homepage = "https://github.com/titusfortner/webdrivers"
10
+ s.summary = "Easy installation and use of webdrivers."
11
+ s.description = "Run Selenium tests more easily with install and updates for all supported webdrivers."
12
+ s.licenses = ["MIT"]
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_development_dependency "rspec", "~> 3.0"
20
+ s.add_development_dependency "rake", "~> 10.0"
21
+
22
+ s.add_runtime_dependency "nokogiri", "~> 1.6"
23
+ s.add_runtime_dependency "archive-zip", "~> 0.7.0"
24
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webdrivers
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Titus Fortner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: archive-zip
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.7.0
69
+ description: Run Selenium tests more easily with install and updates for all supported
70
+ webdrivers.
71
+ email:
72
+ - titusfortner@gmail.com
73
+ executables:
74
+ - chromedriver
75
+ - geckodriver
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - ".travis.yml"
81
+ - CHANGELOG.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/chromedriver
87
+ - bin/geckodriver
88
+ - lib/webdrivers.rb
89
+ - lib/webdrivers/chromedriver.rb
90
+ - lib/webdrivers/common.rb
91
+ - lib/webdrivers/geckodriver.rb
92
+ - spec/chromedriver_spec.rb
93
+ - spec/geckodriver_spec.rb
94
+ - spec/spec_helper.rb
95
+ - webdrivers.gemspec
96
+ homepage: https://github.com/titusfortner/webdrivers
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.4.8
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Easy installation and use of webdrivers.
120
+ test_files:
121
+ - spec/chromedriver_spec.rb
122
+ - spec/geckodriver_spec.rb
123
+ - spec/spec_helper.rb