geckodriver-bin 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 53fee89993f08de5d62428639f16bc77ec96736d44ffbd7ed3fbe6958237f5fa
4
+ data.tar.gz: 60d9e70dae473b5e536d93bd4c5382931829de6cfb8cb09b926ab13bddee3189
5
+ SHA512:
6
+ metadata.gz: ace0b2b1896b3a6905ccce5238e34b1b3a4147736c79a70434b5653a1b17b698376a89697c072b233604383761b3180679e532b1b00aaf0db7e1b6adc12f7597
7
+ data.tar.gz: 128366fcfb2417b65e8ca09aef344c07baa9d49dd32acee62c630ada21efd0f58e134b51d7c713526c352156487c427f6890dfb4e4c2ef747e9b07ad994b0e34
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.4.0
@@ -0,0 +1,19 @@
1
+ Changelog
2
+ ==========
3
+
4
+ 0.0.4 - 09 October 2017
5
+ ----------
6
+
7
+ * Bug Fixing
8
+
9
+ 0.0.3 - 10 November 2016
10
+ ----------
11
+
12
+ * Adding raise exception when SSL certificate is out of date
13
+ * Removed faraday dependency
14
+
15
+
16
+ 0.0.1 - 9 November 2016
17
+ ----------
18
+
19
+ * Ready to Go!
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in geckodriver-bin.gemspec
6
+ gemspec
7
+
8
+ group :test do
9
+ gem "rspec"
10
+ end
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2016: [Devico Solutions LTD](http://devico.io)
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.
@@ -0,0 +1,58 @@
1
+ # geckodriver-bin
2
+
3
+ *Note: This is a maintained fork of the abandoned gem [geckodriver-helper](https://github.com/DevicoSolutions/geckodriver-helper)*
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/geckodriver-bin.svg)](https://badge.fury.io/rb/geckodriver-bin)
6
+
7
+ Easy installation and use of [geckodriver](https://github.com/mozilla/geckodriver), that provides the HTTP API
8
+ described by the WebDriver protocol to communicate with Gecko browsers, such as Firefox.
9
+
10
+ * [https://github.com/0rvar/geckodriver-bin](https://github.com/0rvar/geckodriver-bin)
11
+
12
+
13
+ # Description
14
+
15
+ `geckodriver-bin` installs an executable, `geckodriver`, in your
16
+ gem path.
17
+
18
+ This script will, if necessary, download the appropriate binary for
19
+ your platform and install it into `~/.geckodriver-bin`, then exec
20
+ it.
21
+
22
+ # Usage
23
+
24
+ If you're using Bundler and Capybara, it's as easy as:
25
+
26
+ # Gemfile
27
+ gem 'geckodriver-bin'
28
+
29
+ then, in your specs:
30
+
31
+ Capybara.register_driver :selenium do |app|
32
+ options = ::Selenium::WebDriver::Firefox::Options.new
33
+ # Uncomment line below to run firefox in headless mode
34
+ # options.args << '--headless'
35
+
36
+ Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
37
+ end
38
+
39
+
40
+
41
+ # Updating Geckodriver
42
+
43
+ If you'd like to force-upgrade to the latest version of geckodriver,
44
+ run the script `gecko_updater`
45
+
46
+
47
+ # License
48
+
49
+ MIT licensed, see LICENSE.txt for full details.
50
+
51
+
52
+ # Credit
53
+
54
+ This is a maintained fork of the gem [geckodriver-helper](https://github.com/DevicoSolutions/geckodriver-helper).
55
+
56
+ The idea and some features comes from [@flavorjones's](https://github.com/flavorjones) project
57
+ `chromedriver-helper`. That saves setup time and works pretty good from the box.
58
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'geckodriver/bin'
4
+
5
+ Geckodriver::Bin.new.update
6
+
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'geckodriver/bin'
4
+
5
+ Geckodriver::Bin.new.run *ARGV
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
4
+ $:.push File.expand_path("../lib", __FILE__)
5
+ require "geckodriver/bin/version"
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "geckodriver-bin"
9
+ s.version = Geckodriver::Bin::VERSION
10
+ s.authors = ["0rvar", "Devico Solutions"]
11
+ s.email = ["orvarsegerstrom@gmail.com"]
12
+ s.homepage = "https://github.com/0rvar/geckodriver-bin"
13
+ s.summary = "Easy installation and use of geckodriver."
14
+ s.description = "Easy installation and use of geckodriver, that provides the HTTP API
15
+ described by the WebDriver protocol to communicate with Gecko browsers, such as Firefox."
16
+ s.licenses = ["MIT"]
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_development_dependency "rspec", "~> 3.0"
24
+ s.add_development_dependency "rake", "~> 10.0"
25
+ s.add_development_dependency "http", "~> 3.0"
26
+
27
+ s.add_runtime_dependency "archive-zip", "~> 0.7"
28
+ end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'geckodriver/bin/version'
4
+ require 'fileutils'
5
+ require 'rbconfig'
6
+ require 'open-uri'
7
+ require 'archive/zip'
8
+ require 'zlib'
9
+ require 'rubygems/package'
10
+
11
+ module Geckodriver
12
+ class Bin
13
+ DRIVER_VERSION = "v0.28.0".freeze
14
+
15
+ def run *args
16
+ download
17
+ exec binary_path, *args
18
+ end
19
+
20
+ def download hit_network=false
21
+ return if File.exists?(binary_path) && !hit_network
22
+ url = download_url
23
+ filename = File.basename url
24
+ Dir.chdir platform_install_dir do
25
+ FileUtils.rm_f filename
26
+ File.open(filename, 'wb') do |saved_file|
27
+ URI.parse(url).open('rb') do |read_file|
28
+ saved_file.write(read_file.read)
29
+ end
30
+ end
31
+ raise "Could not download #{url}" unless File.exists? filename
32
+ unpack_archive(filename)
33
+ end
34
+
35
+ raise "Could not unarchive #{filename} to get #{binary_path}" unless File.exists? binary_path
36
+ FileUtils.chmod 'ugo+rx', binary_path
37
+ end
38
+
39
+ def unpack_archive(file)
40
+ case file
41
+ when /\.zip$/
42
+ unzip(file)
43
+ when /\.tar\.gz$/
44
+ io = ungzip(file)
45
+ untar(io)
46
+ else
47
+ raise "Don't know how to unpack #{file}"
48
+ end
49
+ end
50
+
51
+ def update
52
+ download true
53
+ end
54
+
55
+ def download_url
56
+ extension = platform.include?('win') ? 'zip' : 'tar.gz'
57
+ "https://github.com/mozilla/geckodriver/releases/download/#{DRIVER_VERSION}/geckodriver-#{DRIVER_VERSION}-#{platform}.#{extension}"
58
+ end
59
+
60
+ def binary_path
61
+ exe = if platform.include?('win')
62
+ 'geckodriver.exe'
63
+ else
64
+ 'geckodriver'
65
+ end
66
+
67
+ File.join platform_install_dir, exe
68
+ end
69
+
70
+ def platform_install_dir
71
+ dir = File.join install_dir, platform
72
+ FileUtils.mkdir_p dir
73
+ dir
74
+ end
75
+
76
+ def install_dir
77
+ dir = File.expand_path File.join(ENV['HOME'], '.geckodriver-bin')
78
+ FileUtils.mkdir_p dir
79
+ dir
80
+ end
81
+
82
+ def platform
83
+ @platform ||= begin
84
+ cfg = RbConfig::CONFIG
85
+ case cfg['host_os']
86
+ when /linux/
87
+ append_64_or_32('linux', cfg)
88
+ when /darwin/
89
+ 'macos'
90
+ else
91
+ append_64_or_32('win', cfg)
92
+ end
93
+ end
94
+ end
95
+
96
+ private
97
+
98
+ def append_64_or_32(platform, cfg)
99
+ cfg['host_cpu'] =~ /x86_64|amd64/ ? "#{platform}64" : "#{platform}32"
100
+ end
101
+
102
+ def unzip(zipfile)
103
+ Archive::Zip.extract(zipfile, '.', :overwrite => :all)
104
+ end
105
+
106
+ def ungzip(tarfile)
107
+ z = Zlib::GzipReader.open(tarfile)
108
+ unzipped = StringIO.new(z.read)
109
+ z.close
110
+ unzipped
111
+ end
112
+
113
+ def untar(io)
114
+ Gem::Package::TarReader.new io do |tar|
115
+ tar.each do |tarfile|
116
+ destination_file = tarfile.full_name
117
+ File.open destination_file, 'wb' do |f|
118
+ f.print tarfile.read
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Geckodriver
4
+ class Bin
5
+ VERSION = '0.28.0'
6
+ end
7
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'http'
3
+
4
+ describe Geckodriver::Bin do
5
+ let(:geckodriver_bin) { Geckodriver::Bin.new }
6
+
7
+ RSpec::Matchers.define :be_reachable do
8
+ match do |download_url|
9
+ response = HTTP.head download_url
10
+ location = response["Location"]
11
+ expect(response["Location"]).to include("github-production-release-asset")
12
+ expect(response["Location"]).to include("s3.amazonaws.com")
13
+ end
14
+ end
15
+
16
+ describe '#binary_path' do
17
+ context 'on a linux32 platform' do
18
+ before { allow(geckodriver_bin).to receive(:platform) { 'linux32' } }
19
+ it { expect(geckodriver_bin.download_url).to be_reachable }
20
+ it { expect(geckodriver_bin.binary_path).to match(/geckodriver$/) }
21
+ end
22
+
23
+ context 'on a linux64 platform' do
24
+ before { allow(geckodriver_bin).to receive(:platform) { 'linux64' } }
25
+ it { expect(geckodriver_bin.download_url).to be_reachable }
26
+ it { expect(geckodriver_bin.binary_path).to match(/geckodriver$/) }
27
+ end
28
+
29
+ context 'on a mac platform' do
30
+ before { allow(geckodriver_bin).to receive(:platform) { 'macos' } }
31
+ it { expect(geckodriver_bin.download_url).to be_reachable }
32
+ it { expect(geckodriver_bin.binary_path).to match(/geckodriver$/) }
33
+ end
34
+
35
+ context 'on a windows32 platform' do
36
+ before { allow(geckodriver_bin).to receive(:platform) { 'win32' } }
37
+ it { expect(geckodriver_bin.download_url).to be_reachable }
38
+ it { expect(geckodriver_bin.binary_path).to match(/geckodriver\.exe$/) }
39
+ end
40
+
41
+ context 'on a windows64 platform' do
42
+ before { allow(geckodriver_bin).to receive(:platform) { 'win64' } }
43
+ it { expect(geckodriver_bin.download_url).to be_reachable }
44
+ it { expect(geckodriver_bin.binary_path).to match(/geckodriver\.exe$/) }
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib/geckodriver/bin'))
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geckodriver-bin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.28.0
5
+ platform: ruby
6
+ authors:
7
+ - 0rvar
8
+ - Devico Solutions
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-12-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '3.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '3.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: http
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: archive-zip
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.7'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.7'
70
+ description: |-
71
+ Easy installation and use of geckodriver, that provides the HTTP API
72
+ described by the WebDriver protocol to communicate with Gecko browsers, such as Firefox.
73
+ email:
74
+ - orvarsegerstrom@gmail.com
75
+ executables:
76
+ - gecko_updater
77
+ - geckodriver
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - ".travis.yml"
83
+ - CHANGELOG.md
84
+ - Gemfile
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - bin/gecko_updater
89
+ - bin/geckodriver
90
+ - geckodriver-bin.gemspec
91
+ - lib/geckodriver/bin.rb
92
+ - lib/geckodriver/bin/version.rb
93
+ - spec/bin_spec.rb
94
+ - spec/spec_helper.rb
95
+ homepage: https://github.com/0rvar/geckodriver-bin
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubygems_version: 3.1.4
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Easy installation and use of geckodriver.
118
+ test_files:
119
+ - spec/bin_spec.rb
120
+ - spec/spec_helper.rb