webdrivers 2.1.1 → 2.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/bin/phantomjs +5 -0
- data/lib/webdrivers.rb +1 -0
- data/lib/webdrivers/common.rb +4 -1
- data/lib/webdrivers/phantomjs.rb +40 -0
- data/spec/phantomjs_spec.rb +36 -0
- data/webdrivers.gemspec +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34401dfca4c7657382c5f0203e823f316e1d5a73
|
4
|
+
data.tar.gz: ab41f5bed5199f4ab2c23e2b53587781210cb103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fd791e52d68ca138804e819eb3b63d36d1224b4c75ca0248c038cba80ee9ceade86a0bbbf03ae092bcbcdc7aa5ac40e57e145716975df59d6984272dc3af461
|
7
|
+
data.tar.gz: cc25381adcdfaaff27b83cd719c4971a14008c531336c582b14443bc326743056f0cd0e8d4517c961c39cc728deb8ba08823fb4a81e942ba956cd3b85b80feb3
|
data/CHANGELOG.md
CHANGED
data/bin/phantomjs
ADDED
data/lib/webdrivers.rb
CHANGED
data/lib/webdrivers/common.rb
CHANGED
@@ -24,7 +24,8 @@ module Webdrivers
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
raise "Could not download #{url}" unless File.exists? filename
|
27
|
-
decompress_file(filename)
|
27
|
+
dcf = decompress_file(filename)
|
28
|
+
extract_file(dcf) if respond_to? :extract_file
|
28
29
|
end
|
29
30
|
raise "Could not unzip #{filename} to get #{binary_path}" unless File.exists? binary_path
|
30
31
|
FileUtils.chmod "ugo+rx", binary_path
|
@@ -46,10 +47,12 @@ module Webdrivers
|
|
46
47
|
ucf = File.open(file_name, "w+")
|
47
48
|
tar_extract.each { |entry| ucf << entry.read }
|
48
49
|
ucf.close
|
50
|
+
File.basename ucf
|
49
51
|
end
|
50
52
|
|
51
53
|
def unzip_file(filename)
|
52
54
|
Archive::Zip.extract(filename, '.', :overwrite => :all)
|
55
|
+
filename.gsub('.zip', '')
|
53
56
|
end
|
54
57
|
|
55
58
|
def download_url(version = nil)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Webdrivers
|
4
|
+
class PhantomJS < Common
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def file_name
|
8
|
+
platform == "win" ? "phantomjs.exe" : "phantomjs"
|
9
|
+
end
|
10
|
+
|
11
|
+
def current_version
|
12
|
+
return nil unless File.exists?(binary_path)
|
13
|
+
%x(#{binary_path} --version).match(/phantomjs (\d\.\d+\.\d+)/)[1]
|
14
|
+
end
|
15
|
+
|
16
|
+
def newest_version
|
17
|
+
downloads.keys.sort.last
|
18
|
+
end
|
19
|
+
|
20
|
+
def downloads
|
21
|
+
doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url))
|
22
|
+
items = doc.css(".execute").collect { |item| item["href"] }
|
23
|
+
format_platform = platform.dup.gsub('32', '-i686').gsub('64', 'x86_64')
|
24
|
+
items.select! { |item| item.include?(format_platform) }
|
25
|
+
items.each_with_object({}) do |item, hash|
|
26
|
+
hash[item[/-(\d+\.\d+\.\d+)-/, 1]] = "https://bitbucket.org#{item}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def base_url
|
31
|
+
'https://bitbucket.org/ariya/phantomjs/downloads'
|
32
|
+
end
|
33
|
+
|
34
|
+
def extract_file(filename)
|
35
|
+
FileUtils.mv("#{platform_install_dir}/#{filename}/bin/phantomjs", 'phantomjs')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Webdrivers::PhantomJS do
|
4
|
+
|
5
|
+
let(:phantomjs) { Webdrivers::PhantomJS }
|
6
|
+
|
7
|
+
it 'downloads' do
|
8
|
+
phantomjs.download
|
9
|
+
file = "#{ENV['GEM_HOME']}/bin/phantomjs"
|
10
|
+
expect(File.exist?(file)).to eq true
|
11
|
+
end
|
12
|
+
|
13
|
+
it { expect(phantomjs.newest_version.to_f).to be >= 0.11 }
|
14
|
+
|
15
|
+
it { expect(phantomjs.downloads.size).to be >= 5 }
|
16
|
+
|
17
|
+
context "on a linux platform" do
|
18
|
+
before { allow(phantomjs).to receive(:platform) { "linux32" } }
|
19
|
+
|
20
|
+
it { expect(phantomjs.file_name).to match(/phantomjs$/) }
|
21
|
+
|
22
|
+
it { expect(phantomjs.binary_path).to match '.webdrivers/linux32/phantomjs' }
|
23
|
+
|
24
|
+
it { expect(phantomjs.download_url('1.9.6')).to match("phantomjs-1.9.6-linux-") }
|
25
|
+
end
|
26
|
+
|
27
|
+
context "on a windows platform" do
|
28
|
+
before { allow(phantomjs).to receive(:platform) { "win" } }
|
29
|
+
|
30
|
+
it { expect(phantomjs.file_name).to match(/phantomjs\.exe$/) }
|
31
|
+
|
32
|
+
it { expect(phantomjs.binary_path).to match '.webdrivers/win/phantomjs' }
|
33
|
+
|
34
|
+
it { expect(phantomjs.download_url('1.9.7')).to match("phantomjs-1.9.7-windows.zip") }
|
35
|
+
end
|
36
|
+
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 = "2.
|
6
|
+
s.version = "2.2.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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdrivers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
@@ -73,6 +73,7 @@ email:
|
|
73
73
|
executables:
|
74
74
|
- chromedriver
|
75
75
|
- geckodriver
|
76
|
+
- phantomjs
|
76
77
|
extensions: []
|
77
78
|
extra_rdoc_files: []
|
78
79
|
files:
|
@@ -85,12 +86,15 @@ files:
|
|
85
86
|
- Rakefile
|
86
87
|
- bin/chromedriver
|
87
88
|
- bin/geckodriver
|
89
|
+
- bin/phantomjs
|
88
90
|
- lib/webdrivers.rb
|
89
91
|
- lib/webdrivers/chromedriver.rb
|
90
92
|
- lib/webdrivers/common.rb
|
91
93
|
- lib/webdrivers/geckodriver.rb
|
94
|
+
- lib/webdrivers/phantomjs.rb
|
92
95
|
- spec/chromedriver_spec.rb
|
93
96
|
- spec/geckodriver_spec.rb
|
97
|
+
- spec/phantomjs_spec.rb
|
94
98
|
- spec/spec_helper.rb
|
95
99
|
- webdrivers.gemspec
|
96
100
|
homepage: https://github.com/titusfortner/webdrivers
|
@@ -120,4 +124,5 @@ summary: Easy installation and use of webdrivers.
|
|
120
124
|
test_files:
|
121
125
|
- spec/chromedriver_spec.rb
|
122
126
|
- spec/geckodriver_spec.rb
|
127
|
+
- spec/phantomjs_spec.rb
|
123
128
|
- spec/spec_helper.rb
|