gastly 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72868583159f8e35a055086dbba4130ad364589e
4
- data.tar.gz: 7f86570ddc94846083a66fddc3e20234ae7ecef6
3
+ metadata.gz: 61481db693dd21bbbe481bc40e94cda224eeb786
4
+ data.tar.gz: 406d4be2fa87cb64536a8e687a1935b965e3227a
5
5
  SHA512:
6
- metadata.gz: 3fe604a0a919d5d76a6be7358074e1348da096919c4db9217361d23fca30efc4d39a55d5e491772a692a87f521060a003be5c9a5820570bb9191a10b4a8bfa14
7
- data.tar.gz: da9a98e0fe76658bb2a779623205e0628124c5138e0dd564c2bfe09b014e4ecf227913c7b4918f99b10991ba908d495735eef9741eadbdb313979a9feb6c4951
6
+ metadata.gz: 6350109f7427759e9ea898cd7caa9965efb869ce2bfd2f3c4b7dfbf02b58a9a49aaf9d94d35fc7ec387f5db9b51693d1d6ef91eb8dc7f953430b388057c153a1
7
+ data.tar.gz: adac8e9e13cd50ccd1b8a3bc4c1ae44a20c39057e18c7ed078116dc24bc3a3cf9fc80e2bc65cf25fcc16444d1b64ab5350bc788450ff4894d32afd691ed5c56d
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.2.4
@@ -1,11 +1,5 @@
1
- dist: trusty
2
1
  language: ruby
3
2
  rvm:
4
3
  - 2.1.7
5
- - 2.2.3
4
+ - 2.2.4
6
5
  - 2.3.0
7
- before_install:
8
- - mkdir travis-phantomjs
9
- - wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
10
- - tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs
11
- - export PATH=$PWD/travis-phantomjs:$PATH
@@ -1,3 +1,9 @@
1
+ ## 0.3.0 (29/01/2016)
2
+
3
+ ### Enhancements
4
+
5
+ * Update PhantomJS version to 2.1.1
6
+
1
7
  ## 0.2.4 (24/01/2016)
2
8
 
3
9
  ### Enhancements
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'rubocop'
24
24
  spec.add_development_dependency 'rspec', '~> 3.4.0'
25
25
 
26
- spec.add_dependency 'phantomjs2', '~> 2.0'
26
+ spec.add_dependency 'phantomjs', '~> 2.1.1'
27
27
  spec.add_dependency 'mini_magick', '~> 4.2'
28
28
  spec.add_dependency 'activesupport', '>= 3.1'
29
29
  end
@@ -3,6 +3,7 @@ require 'mini_magick'
3
3
  require 'active_support/core_ext/hash/keys'
4
4
  require 'active_support/core_ext/object/blank'
5
5
 
6
+ require_relative 'gastly/phantomjs_patch'
6
7
  require_relative 'gastly/image'
7
8
  require_relative 'gastly/screenshot'
8
9
  require_relative 'gastly/exceptions'
@@ -0,0 +1,79 @@
1
+ module Phantomjs
2
+ class << self
3
+ attr_accessor :proxy_host, :proxy_port
4
+ end
5
+
6
+ class Platform
7
+ class << self
8
+ def install!
9
+ STDERR.puts "Phantomjs does not appear to be installed in #{phantomjs_path}, installing!"
10
+ FileUtils.mkdir_p Phantomjs.base_dir
11
+
12
+ # Purge temporary directory if it is still hanging around from previous installs,
13
+ # then re-create it.
14
+ temp_dir = File.join(temp_path, 'phantomjs_install')
15
+ FileUtils.rm_rf temp_dir
16
+ FileUtils.mkdir_p temp_dir
17
+
18
+ Dir.chdir temp_dir do
19
+ unless download_via_curl or download_via_wget
20
+ raise "\n\nFailed to load phantomjs! :(\nYou need to have cURL or wget installed on your system.\nIf you have, the source of phantomjs might be unavailable: #{package_url}\n\n"
21
+ end
22
+
23
+ case package_url.split('.').last
24
+ when 'bz2'
25
+ system "bunzip2 #{File.basename(package_url)}"
26
+ system "tar xf #{File.basename(package_url).sub(/\.bz2$/, '')}"
27
+ when 'zip'
28
+ system "unzip #{File.basename(package_url)}"
29
+ else
30
+ raise "Unknown compression format for #{File.basename(package_url)}"
31
+ end
32
+
33
+ # Find the phantomjs build we just extracted
34
+ extracted_dir = Dir['phantomjs*'].find { |path| File.directory?(path) }
35
+
36
+ if extracted_dir.nil?
37
+ # Move the executable file
38
+ FileUtils.mkdir_p File.join(Phantomjs.base_dir, platform, 'bin')
39
+ if FileUtils.mv 'phantomjs', File.join(Phantomjs.base_dir, platform, 'bin')
40
+ STDOUT.puts "\nSuccessfully installed phantomjs. Yay!"
41
+ end
42
+ else
43
+ # Move the extracted phantomjs build to $HOME/.phantomjs/version/platform
44
+ if FileUtils.mv extracted_dir, File.join(Phantomjs.base_dir, platform)
45
+ STDOUT.puts "\nSuccessfully installed phantomjs. Yay!"
46
+ end
47
+ end
48
+
49
+ # Clean up remaining files in tmp
50
+ if FileUtils.rm_rf temp_dir
51
+ STDOUT.puts 'Removed temporarily downloaded files.'
52
+ end
53
+ end
54
+
55
+ raise 'Failed to install phantomjs. Sorry :(' unless File.exist?(phantomjs_path)
56
+ end
57
+
58
+ private
59
+
60
+ def download_via_curl
61
+ system "curl -L -O #{package_url} #{curl_proxy_options}"
62
+ end
63
+
64
+ def download_via_wget
65
+ system "wget #{package_url} #{wget_proxy_options}"
66
+ end
67
+
68
+ def curl_proxy_options
69
+ return '' if Phantomjs.proxy_host.nil? && Phantomjs.proxy_port.nil?
70
+ "-x #{Phantomjs.proxy_host}:#{Phantomjs.proxy_port}"
71
+ end
72
+
73
+ def wget_proxy_options
74
+ return '' if Phantomjs.proxy_host.nil? && Phantomjs.proxy_port.nil?
75
+ "-e use_proxy=yes -e http_proxy=#{Phantomjs.proxy_host}:#{Phantomjs.proxy_port}"
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,3 +1,3 @@
1
1
  module Gastly
2
- VERSION = '0.2.4'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gastly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Grachev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-24 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.4.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: phantomjs2
70
+ name: phantomjs
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: 2.1.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: 2.1.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mini_magick
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +132,7 @@ files:
132
132
  - lib/gastly.rb
133
133
  - lib/gastly/exceptions.rb
134
134
  - lib/gastly/image.rb
135
+ - lib/gastly/phantomjs_patch.rb
135
136
  - lib/gastly/screenshot.rb
136
137
  - lib/gastly/script.js
137
138
  - lib/gastly/version.rb