gastly 0.2.0 → 0.2.1
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/lib/gastly/screenshot.rb +5 -1
- data/lib/gastly/script.js +24 -19
- data/lib/gastly/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c192b43a0068cbba91b24d1a7e5647d846b386d9
|
|
4
|
+
data.tar.gz: bf9af7de29d4482a18daafa105e84abd91a41767
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c0c5705e90950d8ab2e23e9ea4739b2110e6ab5f0ce6bc10d409c56bd2046085640a96513d7eebe130353517caed0e7f9d2af7befbdd08f59850cd1893a8653
|
|
7
|
+
data.tar.gz: 61c0cf280a979d41fe03c02ae77f9916bd2eff7383d991f3cc67a4fcc4b3cc13849331f4f4528eed6e9f4405c780d92352eab15a387f08ade40fc4317776c5b7
|
data/lib/gastly/screenshot.rb
CHANGED
|
@@ -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
|
-
|
|
44
|
-
|
|
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
|
-
}
|
|
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
|
});
|
data/lib/gastly/version.rb
CHANGED
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
|
+
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-
|
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|