gastly 0.2.0 → 0.2.1

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: 65033a39c65ae48403a64c73e28fc8a1de4a7981
4
- data.tar.gz: 0bbcc84f2da4bb4ce06524e5952a8b00f1cdb7cf
3
+ metadata.gz: c192b43a0068cbba91b24d1a7e5647d846b386d9
4
+ data.tar.gz: bf9af7de29d4482a18daafa105e84abd91a41767
5
5
  SHA512:
6
- metadata.gz: 7f0105743886cedeca9176dcff78df8cc9880b3798a509512db316deb78f047b8700c5f49d976f4aeff645b1bf6dbde6bfab809e08f640525275fc0e497775bd
7
- data.tar.gz: 332b85808e033c3c2ebbd6a03d51ec7fdfc00de17d0775333ed7d13a979e3ca323ae7f47dbd8923c49ce8381c13b1e6853e32e307df680b16db3c9700b23a191
6
+ metadata.gz: 4c0c5705e90950d8ab2e23e9ea4739b2110e6ab5f0ce6bc10d409c56bd2046085640a96513d7eebe130353517caed0e7f9d2af7befbdd08f59850cd1893a8653
7
+ data.tar.gz: 61c0cf280a979d41fe03c02ae77f9916bd2eff7383d991f3cc67a4fcc4b3cc13849331f4f4528eed6e9f4405c780d92352eab15a387f08ade40fc4317776c5b7
@@ -5,6 +5,8 @@ require 'active_support/core_ext/object/blank'
5
5
  module Gastly
6
6
  class Screenshot
7
7
 
8
+ FetchError = Class.new(StandardError)
9
+
8
10
  SCRIPT_PATH = File.expand_path('../script.js', __FILE__)
9
11
  DEFAULT_TIMEOUT = 0
10
12
  DEFAULT_BROWSER_WIDTH = 1440
@@ -53,7 +55,9 @@ module Gastly
53
55
 
54
56
  Phantomjs.proxy_host = proxy_host if proxy_host
55
57
  Phantomjs.proxy_port = proxy_port if proxy_port
56
- Phantomjs.run(proxy_options, SCRIPT_PATH.to_s, *prepared_params)
58
+ output = Phantomjs.run(proxy_options, SCRIPT_PATH.to_s, *prepared_params)
59
+
60
+ raise FetchError, output if output.present?
57
61
 
58
62
  Gastly::Image.new(tempfile)
59
63
  end
data/lib/gastly/script.js CHANGED
@@ -39,24 +39,29 @@ if (args.cookies !== undefined){
39
39
  }
40
40
  }
41
41
 
42
- page.open(args.url, function(){
43
- window.setTimeout(function(){
44
- page.viewportSize = { width: args.width, height: args.height };
45
-
46
- if (args.selector !== undefined){
47
- var clipRect = page.evaluate(function(s){
48
- return document.querySelector(s).getBoundingClientRect();
49
- }, args.selector);
50
-
51
- page.clipRect = {
52
- top: clipRect.top,
53
- left: clipRect.left,
54
- width: clipRect.width,
55
- height: clipRect.height
56
- };
57
- }
58
-
59
- page.render(args.output);
42
+ page.open(args.url, function(status){
43
+ if(status !== 'success') {
44
+ console.log('Unable to load: ' + args.url);
60
45
  phantom.exit();
61
- }, args.timeout);
46
+ } else {
47
+ window.setTimeout(function(){
48
+ page.viewportSize = { width: args.width, height: args.height };
49
+
50
+ if (args.selector !== undefined){
51
+ var clipRect = page.evaluate(function(s){
52
+ return document.querySelector(s).getBoundingClientRect();
53
+ }, args.selector);
54
+
55
+ page.clipRect = {
56
+ top: clipRect.top,
57
+ left: clipRect.left,
58
+ width: clipRect.width,
59
+ height: clipRect.height
60
+ };
61
+ }
62
+
63
+ page.render(args.output);
64
+ phantom.exit();
65
+ }, args.timeout);
66
+ }
62
67
  });
@@ -1,3 +1,3 @@
1
1
  module Gastly
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Grachev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler