phantomjs-helper 1.0.0 → 1.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad393013067a3062ce026e603e44c2abefc69a53
|
4
|
+
data.tar.gz: 7266f6a18f827bc8714283378234169fad9bd5ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aedd710628fa2f38ba3550c8b802ec97f7e5cc207e069969f1e07b327a1b45e67b81929408b384f78a77adfdd84cbb5aea3a245c232449cd5b89a2bd31d9c737
|
7
|
+
data.tar.gz: 2b5c7d23cda3c60e77eb5f8753e6d6608a073f94b5bd76ead3d3346ceafe5fedda5dbee824ff87e412a22b94a274e18a0b40b2077fb16cf6d885f837f903295e
|
data/lib/phantomjs/helper.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'phantomjs/helper/version'
|
2
2
|
require 'phantomjs/helper/bitbucket_download_parser'
|
3
|
+
require 'phantomjs/helper/extractor'
|
3
4
|
require 'fileutils'
|
4
5
|
require 'rbconfig'
|
5
6
|
require 'open-uri'
|
6
|
-
require '
|
7
|
-
require 'ffi-libarchive'
|
7
|
+
require 'openssl'
|
8
8
|
|
9
9
|
module Phantomjs
|
10
10
|
class Helper
|
@@ -27,12 +27,12 @@ module Phantomjs
|
|
27
27
|
Dir.chdir install_dir do
|
28
28
|
FileUtils.rm_f filename
|
29
29
|
File.open(filename, 'wb') do |saved_file|
|
30
|
-
URI.parse(url).open('rb') do |read_file|
|
30
|
+
URI.parse(url).open('rb',{:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE}) do |read_file|
|
31
31
|
saved_file.write(read_file.read)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
raise "Could not download #{url}" unless File.exists? filename
|
35
|
-
extract
|
35
|
+
Extractor.extract(filename, binary_path)
|
36
36
|
FileUtils.rm_f filename
|
37
37
|
end
|
38
38
|
raise "Could not unzip #{filename} to get #{binary_path}" unless File.exists? binary_path
|
@@ -53,30 +53,6 @@ module Phantomjs
|
|
53
53
|
|
54
54
|
private
|
55
55
|
|
56
|
-
def extract(filename)
|
57
|
-
case File.extname(filename)
|
58
|
-
when '.zip'
|
59
|
-
Zip::File.open(filename) do |zip_file|
|
60
|
-
entry = zip_file.glob('**/bin/phantomjs*').first
|
61
|
-
raise "Could not find phantomjs binary in zip archive #{filename}" unless entry
|
62
|
-
FileUtils.rm_f entry.name
|
63
|
-
entry.extract(File.basename(entry.name))
|
64
|
-
end
|
65
|
-
when '.bz2'
|
66
|
-
Archive.read_open_filename(filename) do |ar|
|
67
|
-
ar.each_entry do |e|
|
68
|
-
if e.pathname.include?('bin/phantomjs')
|
69
|
-
File.open(binary_path, 'wb') do |saved_file|
|
70
|
-
saved_file.write(ar.read_data)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
else
|
76
|
-
raise "Do not know how to extract binary from #{filename}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
56
|
def driver_name
|
81
57
|
/phantomjs-.*-#{platform}/
|
82
58
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'open-uri'
|
3
|
+
require 'openssl'
|
3
4
|
|
4
5
|
module Phantomjs
|
5
6
|
class Helper
|
@@ -10,7 +11,7 @@ module Phantomjs
|
|
10
11
|
def initialize(driver_name, url:, open_uri_provider: OpenURI)
|
11
12
|
@driver_name = driver_name
|
12
13
|
@url = url
|
13
|
-
@source = open_uri_provider.open_uri(url)
|
14
|
+
@source = open_uri_provider.open_uri(url, {:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE})
|
14
15
|
end
|
15
16
|
|
16
17
|
def downloads
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Phantomjs
|
4
|
+
class Extractor
|
5
|
+
class << self
|
6
|
+
def extract(archive_file, destination)
|
7
|
+
case File.extname(archive_file)
|
8
|
+
when '.zip'
|
9
|
+
extract_zip(archive_file, destination)
|
10
|
+
when '.bz2'
|
11
|
+
extract_bz2(archive_file, destination)
|
12
|
+
else
|
13
|
+
raise "Do not know how to extract binary from #{archive_file}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def extract_zip(archive_file, destination)
|
20
|
+
require 'zip'
|
21
|
+
Zip::File.open(archive_file) do |zip_file|
|
22
|
+
entry = zip_file.glob('**/bin/phantomjs*').first
|
23
|
+
raise "Could not find phantomjs binary in zip archive #{archive_file}" unless entry
|
24
|
+
FileUtils.rm_f destination
|
25
|
+
entry.extract(destination)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def extract_bz2(archive_file, destination)
|
30
|
+
require 'ffi-libarchive'
|
31
|
+
Archive.read_open_filename(archive_file) do |ar|
|
32
|
+
ar.each_entry do |e|
|
33
|
+
if e.pathname.include?('bin/phantomjs')
|
34
|
+
File.open(destination, 'wb') do |saved_file|
|
35
|
+
saved_file.write(ar.read_data)
|
36
|
+
end
|
37
|
+
return
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
raise "Could not find phantomjs binary in archive #{archive_file}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phantomjs-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rasmus Bergholdt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- bin/phantomjs-update
|
101
101
|
- lib/phantomjs/helper.rb
|
102
102
|
- lib/phantomjs/helper/bitbucket_download_parser.rb
|
103
|
+
- lib/phantomjs/helper/extractor.rb
|
103
104
|
- lib/phantomjs/helper/version.rb
|
104
105
|
- phantomjs-helper.gemspec
|
105
106
|
- spec/assets/bitbucket_downloads.html
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.5.1
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Easy installation and use of Phantomjs.
|