phantomjs.rb 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +11 -0
- data/MIT-LICENSE +21 -0
- data/lib/phantomjs.rb +4 -2
- data/lib/phantomjs/version.rb +1 -1
- data/phantomjs.rb.gemspec +5 -1
- metadata +20 -186
- data/vendor/phantomjs-1.4.1_OSX/ChangeLog +0 -145
- data/vendor/phantomjs-1.4.1_OSX/LICENSE.BSD +0 -22
- data/vendor/phantomjs-1.4.1_OSX/README.md +0 -33
- data/vendor/phantomjs-1.4.1_OSX/bin/Info.plist +0 -12
- data/vendor/phantomjs-1.4.1_OSX/bin/phantomjs +0 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/arguments.coffee +0 -6
- data/vendor/phantomjs-1.4.1_OSX/examples/arguments.js +0 -8
- data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.coffee +0 -46
- data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.js +0 -51
- data/vendor/phantomjs-1.4.1_OSX/examples/countdown.coffee +0 -8
- data/vendor/phantomjs-1.4.1_OSX/examples/countdown.js +0 -9
- data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.coffee +0 -40
- data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.js +0 -57
- data/vendor/phantomjs-1.4.1_OSX/examples/direction.coffee +0 -29
- data/vendor/phantomjs-1.4.1_OSX/examples/direction.js +0 -34
- data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.coffee +0 -19
- data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.js +0 -22
- data/vendor/phantomjs-1.4.1_OSX/examples/features.js +0 -30
- data/vendor/phantomjs-1.4.1_OSX/examples/fibo.coffee +0 -8
- data/vendor/phantomjs-1.4.1_OSX/examples/fibo.js +0 -9
- data/vendor/phantomjs-1.4.1_OSX/examples/follow.coffee +0 -54
- data/vendor/phantomjs-1.4.1_OSX/examples/follow.js +0 -59
- data/vendor/phantomjs-1.4.1_OSX/examples/hello.coffee +0 -2
- data/vendor/phantomjs-1.4.1_OSX/examples/hello.js +0 -2
- data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.coffee +0 -19
- data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.js +0 -22
- data/vendor/phantomjs-1.4.1_OSX/examples/injectme.coffee +0 -23
- data/vendor/phantomjs-1.4.1_OSX/examples/injectme.js +0 -25
- data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.coffee +0 -13
- data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.js +0 -14
- data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.js +0 -22
- data/vendor/phantomjs-1.4.1_OSX/examples/modernizr.js +0 -1116
- data/vendor/phantomjs-1.4.1_OSX/examples/movies.coffee +0 -13
- data/vendor/phantomjs-1.4.1_OSX/examples/movies.js +0 -14
- data/vendor/phantomjs-1.4.1_OSX/examples/netlog.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/netlog.js +0 -23
- data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.coffee +0 -109
- data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.js +0 -131
- data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.coffee +0 -12
- data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.js +0 -16
- data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.coffee +0 -13
- data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.js +0 -19
- data/vendor/phantomjs-1.4.1_OSX/examples/pizza.coffee +0 -18
- data/vendor/phantomjs-1.4.1_OSX/examples/pizza.js +0 -20
- data/vendor/phantomjs-1.4.1_OSX/examples/post.coffee +0 -12
- data/vendor/phantomjs-1.4.1_OSX/examples/post.js +0 -14
- data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.coffee +0 -22
- data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.js +0 -27
- data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.coffee +0 -48
- data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.js +0 -60
- data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.coffee +0 -59
- data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.js +0 -77
- data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.coffee +0 -62
- data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.js +0 -74
- data/vendor/phantomjs-1.4.1_OSX/examples/scandir.coffee +0 -15
- data/vendor/phantomjs-1.4.1_OSX/examples/scandir.js +0 -21
- data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.js +0 -19
- data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.coffee +0 -35
- data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.js +0 -40
- data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.js +0 -24
- data/vendor/phantomjs-1.4.1_OSX/examples/technews.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/technews.js +0 -16
- data/vendor/phantomjs-1.4.1_OSX/examples/tweets.coffee +0 -30
- data/vendor/phantomjs-1.4.1_OSX/examples/tweets.js +0 -36
- data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.coffee +0 -18
- data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.js +0 -24
- data/vendor/phantomjs-1.4.1_OSX/examples/useragent.coffee +0 -11
- data/vendor/phantomjs-1.4.1_OSX/examples/useragent.js +0 -14
- data/vendor/phantomjs-1.4.1_OSX/examples/version.coffee +0 -5
- data/vendor/phantomjs-1.4.1_OSX/examples/version.js +0 -5
- data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.coffee +0 -48
- data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.js +0 -57
- data/vendor/phantomjs-1.4.1_OSX/examples/weather.coffee +0 -48
- data/vendor/phantomjs-1.4.1_OSX/examples/weather.js +0 -57
- data/vendor/phantomjs-1.4.1_OSX/lib/jquery.js +0 -8374
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/ChangeLog +0 -177
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/LICENSE.BSD +0 -22
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/README.md +0 -33
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/Info.plist +0 -12
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/phantomjs +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.coffee +0 -7
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.js +0 -9
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.coffee +0 -46
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.js +0 -51
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.coffee +0 -8
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.js +0 -9
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.coffee +0 -41
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.js +0 -58
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.coffee +0 -30
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.js +0 -35
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.coffee +0 -20
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.js +0 -24
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/features.js +0 -30
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.coffee +0 -8
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.js +0 -9
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.coffee +0 -29
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.js +0 -34
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.coffee +0 -2
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.js +0 -2
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.coffee +0 -20
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.js +0 -23
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.coffee +0 -23
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.js +0 -25
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.coffee +0 -13
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.js +0 -14
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.coffee +0 -18
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.js +0 -23
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/modernizr.js +0 -1116
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.coffee +0 -13
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.js +0 -14
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.coffee +0 -18
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.js +0 -25
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.coffee +0 -110
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.js +0 -132
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.coffee +0 -12
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.js +0 -16
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.coffee +0 -13
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.js +0 -19
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.coffee +0 -18
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.js +0 -20
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.coffee +0 -12
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.js +0 -14
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/postserver.js +0 -34
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printenv.js +0 -10
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printmargins.js +0 -35
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.coffee +0 -23
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.js +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.coffee +0 -50
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.js +0 -62
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.coffee +0 -61
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.js +0 -79
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.coffee +0 -64
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.js +0 -76
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.coffee +0 -16
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.js +0 -22
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.coffee +0 -17
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.js +0 -19
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/server.js +0 -43
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/serverkeepalive.js +0 -34
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.coffee +0 -38
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.js +0 -42
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.coffee +0 -20
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.js +0 -25
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.coffee +0 -17
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.js +0 -16
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.coffee +0 -31
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.js +0 -37
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.coffee +0 -18
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.js +0 -24
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.coffee +0 -11
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.js +0 -14
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.coffee +0 -5
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.js +0 -5
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.coffee +0 -48
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.js +0 -57
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.coffee +0 -49
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.js +0 -58
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.la +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.prl +0 -7
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.la +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.prl +0 -7
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.la +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.prl +0 -7
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.la +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.prl +0 -6
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9.0 +0 -0
@@ -1,22 +0,0 @@
|
|
1
|
-
page = require('webpage').create()
|
2
|
-
|
3
|
-
if phantom.args.length < 2 or phantom.args.length > 3
|
4
|
-
console.log 'Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat]'
|
5
|
-
console.log ' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"'
|
6
|
-
phantom.exit()
|
7
|
-
else
|
8
|
-
address = phantom.args[0]
|
9
|
-
output = phantom.args[1]
|
10
|
-
page.viewportSize = { width: 600, height: 600 }
|
11
|
-
if phantom.args.length is 3 and phantom.args[1].substr(-4) is ".pdf"
|
12
|
-
size = phantom.args[2].split '*'
|
13
|
-
if size.length is 2
|
14
|
-
page.paperSize = { width: size[0], height: size[1], border: '0px' }
|
15
|
-
else
|
16
|
-
page.paperSize = { format: phantom.args[2], orientation: 'portrait', border: '1cm' }
|
17
|
-
page.open address, (status) ->
|
18
|
-
if status isnt 'success'
|
19
|
-
console.log 'Unable to load the address!'
|
20
|
-
phantom.exit()
|
21
|
-
else
|
22
|
-
window.setTimeout (-> page.render output; phantom.exit()), 200
|
@@ -1,27 +0,0 @@
|
|
1
|
-
var page = require('webpage').create(),
|
2
|
-
address, output, size;
|
3
|
-
|
4
|
-
if (phantom.args.length < 2 || phantom.args.length > 3) {
|
5
|
-
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat]');
|
6
|
-
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
|
7
|
-
phantom.exit();
|
8
|
-
} else {
|
9
|
-
address = phantom.args[0];
|
10
|
-
output = phantom.args[1];
|
11
|
-
page.viewportSize = { width: 600, height: 600 };
|
12
|
-
if (phantom.args.length === 3 && phantom.args[1].substr(-4) === ".pdf") {
|
13
|
-
size = phantom.args[2].split('*');
|
14
|
-
page.paperSize = size.length === 2 ? { width: size[0], height: size[1], border: '0px' }
|
15
|
-
: { format: phantom.args[2], orientation: 'portrait', border: '1cm' };
|
16
|
-
}
|
17
|
-
page.open(address, function (status) {
|
18
|
-
if (status !== 'success') {
|
19
|
-
console.log('Unable to load the address!');
|
20
|
-
} else {
|
21
|
-
window.setTimeout(function () {
|
22
|
-
page.render(output);
|
23
|
-
phantom.exit();
|
24
|
-
}, 200);
|
25
|
-
}
|
26
|
-
});
|
27
|
-
}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# Render Multiple URLs to file
|
2
|
-
# FIXME: For now it is fine with pure domain names: don't think it would work with paths and stuff like that
|
3
|
-
|
4
|
-
# Extend the Array Prototype with a 'foreach'
|
5
|
-
Array.prototype.forEach = (action) ->
|
6
|
-
for i, j in this
|
7
|
-
action j, i, _len
|
8
|
-
|
9
|
-
# Render a given url to a given file
|
10
|
-
# @param url URL to render
|
11
|
-
# @param file File to render to
|
12
|
-
# @param callback Callback function
|
13
|
-
renderUrlToFile = (url, file, callback) ->
|
14
|
-
page = require('webpage').create()
|
15
|
-
page.viewportSize = { width: 800, height : 600 }
|
16
|
-
page.settings.userAgent = 'Phantom.js bot'
|
17
|
-
|
18
|
-
page.open url, (status) ->
|
19
|
-
if status isnt 'success'
|
20
|
-
console.log "Unable to render '#{url}'"
|
21
|
-
else
|
22
|
-
page.render file
|
23
|
-
|
24
|
-
delete page
|
25
|
-
callback url, file
|
26
|
-
|
27
|
-
# Read the passed args
|
28
|
-
if phantom.args.length > 0
|
29
|
-
arrayOfUrls = phantom.args
|
30
|
-
else
|
31
|
-
# Default (no args passed)
|
32
|
-
console.log 'Usage: phantomjs render_multi_url.coffee [domain.name1, domain.name2, ...]'
|
33
|
-
arrayOfUrls = [
|
34
|
-
'www.google.com',
|
35
|
-
'www.bbc.co.uk',
|
36
|
-
'www.phantomjs.org'
|
37
|
-
]
|
38
|
-
|
39
|
-
# For each URL
|
40
|
-
arrayOfUrls.forEach (pos, url, total) ->
|
41
|
-
file_name = "./#{url}.png"
|
42
|
-
|
43
|
-
# Render to a file
|
44
|
-
renderUrlToFile "http://#{url}", file_name, (url, file) ->
|
45
|
-
console.log "Rendered '#{url}' at '#{file}'"
|
46
|
-
if pos is total - 1
|
47
|
-
# Close Phantom if it's the last URL
|
48
|
-
phantom.exit()
|
@@ -1,60 +0,0 @@
|
|
1
|
-
// Render Multiple URLs to file
|
2
|
-
// FIXME: For now it is fine with pure domain names: don't think it would work with paths and stuff like that
|
3
|
-
|
4
|
-
// Extend the Array Prototype with a 'foreach'
|
5
|
-
Array.prototype.forEach = function (action) {
|
6
|
-
var i, len;
|
7
|
-
for ( i = 0, len = this.length; i < len; ++i ) {
|
8
|
-
action(i, this[i], len);
|
9
|
-
}
|
10
|
-
};
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Render a given url to a given file
|
14
|
-
* @param url URL to render
|
15
|
-
* @param file File to render to
|
16
|
-
* @param callback Callback function
|
17
|
-
*/
|
18
|
-
function renderUrlToFile(url, file, callback) {
|
19
|
-
var page = require('webpage').create();
|
20
|
-
page.viewportSize = { width: 800, height : 600 };
|
21
|
-
page.settings.userAgent = "Phantom.js bot";
|
22
|
-
|
23
|
-
page.open(url, function(status){
|
24
|
-
if ( status !== "success") {
|
25
|
-
console.log("Unable to render '"+url+"'");
|
26
|
-
} else {
|
27
|
-
page.render(file);
|
28
|
-
}
|
29
|
-
delete page;
|
30
|
-
callback(url, file);
|
31
|
-
});
|
32
|
-
}
|
33
|
-
|
34
|
-
// Read the passed args
|
35
|
-
var arrayOfUrls;
|
36
|
-
if ( phantom.args.length > 0 ) {
|
37
|
-
arrayOfUrls = phantom.args;
|
38
|
-
} else {
|
39
|
-
// Default (no args passed)
|
40
|
-
console.log("Usage: phantomjs render_multi_url.js [domain.name1, domain.name2, ...]");
|
41
|
-
arrayOfUrls = [
|
42
|
-
'www.google.com',
|
43
|
-
'www.bbc.co.uk',
|
44
|
-
'www.phantomjs.org'
|
45
|
-
];
|
46
|
-
}
|
47
|
-
|
48
|
-
// For each URL
|
49
|
-
arrayOfUrls.forEach(function(pos, url, total){
|
50
|
-
var file_name = "./" + url + ".png";
|
51
|
-
|
52
|
-
// Render to a file
|
53
|
-
renderUrlToFile("http://"+url, file_name, function(url, file){
|
54
|
-
console.log("Rendered '"+url+"' at '"+file+"'");
|
55
|
-
if ( pos === total-1 ) {
|
56
|
-
// Close Phantom if it's the last URL
|
57
|
-
phantom.exit();
|
58
|
-
}
|
59
|
-
});
|
60
|
-
});
|
@@ -1,59 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Wait until the test condition is true or a timeout occurs. Useful for waiting
|
3
|
-
# on a server response or for a ui change (fadeIn, etc.) to occur.
|
4
|
-
#
|
5
|
-
# @param testFx javascript condition that evaluates to a boolean,
|
6
|
-
# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
7
|
-
# as a callback function.
|
8
|
-
# @param onReady what to do when testFx condition is fulfilled,
|
9
|
-
# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
10
|
-
# as a callback function.
|
11
|
-
# @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
|
12
|
-
##
|
13
|
-
waitFor = (testFx, onReady, timeOutMillis=3000) ->
|
14
|
-
start = new Date().getTime()
|
15
|
-
condition = false
|
16
|
-
f = ->
|
17
|
-
if (new Date().getTime() - start < timeOutMillis) and not condition
|
18
|
-
# If not time-out yet and condition not yet fulfilled
|
19
|
-
condition = (if typeof testFx is 'string' then eval testFx else testFx()) #< defensive code
|
20
|
-
else
|
21
|
-
if not condition
|
22
|
-
# If condition still not fulfilled (timeout but condition is 'false')
|
23
|
-
console.log "'waitFor()' timeout"
|
24
|
-
phantom.exit(1)
|
25
|
-
else
|
26
|
-
# Condition fulfilled (timeout and/or condition is 'true')
|
27
|
-
console.log "'waitFor()' finished in #{new Date().getTime() - start}ms."
|
28
|
-
if typeof onReady is 'string' then eval onReady else onReady() #< Do what it's supposed to do once the condition is fulfilled
|
29
|
-
clearInterval interval #< Stop this interval
|
30
|
-
interval = setInterval f, 100 #< repeat check every 100ms
|
31
|
-
|
32
|
-
if phantom.args.length isnt 1
|
33
|
-
console.log 'Usage: run-jasmine.coffee URL'
|
34
|
-
phantom.exit()
|
35
|
-
|
36
|
-
page = require('webpage').create()
|
37
|
-
|
38
|
-
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
|
39
|
-
page.onConsoleMessage = (msg) ->
|
40
|
-
console.log msg
|
41
|
-
|
42
|
-
page.open phantom.args[0], (status) ->
|
43
|
-
if status isnt 'success'
|
44
|
-
console.log 'Unable to access network'
|
45
|
-
phantom.exit()
|
46
|
-
else
|
47
|
-
waitFor ->
|
48
|
-
page.evaluate ->
|
49
|
-
if document.body.querySelector '.finished-at'
|
50
|
-
return true
|
51
|
-
return false
|
52
|
-
, ->
|
53
|
-
page.evaluate ->
|
54
|
-
console.log document.body.querySelector('.description').innerText
|
55
|
-
list = document.body.querySelectorAll('.failed > .description, .failed > .messages > .resultMessage')
|
56
|
-
for el in list
|
57
|
-
console.log el.innerText
|
58
|
-
|
59
|
-
phantom.exit()
|
@@ -1,77 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Wait until the test condition is true or a timeout occurs. Useful for waiting
|
3
|
-
* on a server response or for a ui change (fadeIn, etc.) to occur.
|
4
|
-
*
|
5
|
-
* @param testFx javascript condition that evaluates to a boolean,
|
6
|
-
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
7
|
-
* as a callback function.
|
8
|
-
* @param onReady what to do when testFx condition is fulfilled,
|
9
|
-
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
10
|
-
* as a callback function.
|
11
|
-
* @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
|
12
|
-
*/
|
13
|
-
function waitFor(testFx, onReady, timeOutMillis) {
|
14
|
-
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3001, //< Default Max Timeout is 3s
|
15
|
-
start = new Date().getTime(),
|
16
|
-
condition = false,
|
17
|
-
interval = setInterval(function() {
|
18
|
-
if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
|
19
|
-
// If not time-out yet and condition not yet fulfilled
|
20
|
-
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
|
21
|
-
} else {
|
22
|
-
if(!condition) {
|
23
|
-
// If condition still not fulfilled (timeout but condition is 'false')
|
24
|
-
console.log("'waitFor()' timeout");
|
25
|
-
phantom.exit(1);
|
26
|
-
} else {
|
27
|
-
// Condition fulfilled (timeout and/or condition is 'true')
|
28
|
-
console.log("'waitFor()' finished in " + (new Date().getTime() - start) + "ms.");
|
29
|
-
typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
|
30
|
-
clearInterval(interval); //< Stop this interval
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}, 100); //< repeat check every 100ms
|
34
|
-
};
|
35
|
-
|
36
|
-
|
37
|
-
if (phantom.args.length === 0 || phantom.args.length > 2) {
|
38
|
-
console.log('Usage: run-jasmine.js URL');
|
39
|
-
phantom.exit();
|
40
|
-
}
|
41
|
-
|
42
|
-
var page = require('webpage').create();
|
43
|
-
|
44
|
-
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
|
45
|
-
page.onConsoleMessage = function(msg) {
|
46
|
-
console.log(msg);
|
47
|
-
};
|
48
|
-
|
49
|
-
page.open(phantom.args[0], function(status){
|
50
|
-
if (status !== "success") {
|
51
|
-
console.log("Unable to access network");
|
52
|
-
phantom.exit();
|
53
|
-
} else {
|
54
|
-
waitFor(function(){
|
55
|
-
return page.evaluate(function(){
|
56
|
-
if (document.body.querySelector('.finished-at')) {
|
57
|
-
return true;
|
58
|
-
}
|
59
|
-
return false;
|
60
|
-
});
|
61
|
-
}, function(){
|
62
|
-
page.evaluate(function(){
|
63
|
-
console.log(document.body.querySelector('.description').innerText);
|
64
|
-
list = document.body.querySelectorAll('div.jasmine_reporter > div.suite.failed');
|
65
|
-
for (i = 0; i < list.length; ++i) {
|
66
|
-
el = list[i];
|
67
|
-
desc = el.querySelectorAll('.description');
|
68
|
-
console.log('');
|
69
|
-
for (j = 0; j < desc.length; ++j) {
|
70
|
-
console.log(desc[j].innerText);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
});
|
74
|
-
phantom.exit();
|
75
|
-
});
|
76
|
-
}
|
77
|
-
});
|
@@ -1,62 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Wait until the test condition is true or a timeout occurs. Useful for waiting
|
3
|
-
# on a server response or for a ui change (fadeIn, etc.) to occur.
|
4
|
-
#
|
5
|
-
# @param testFx javascript condition that evaluates to a boolean,
|
6
|
-
# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
7
|
-
# as a callback function.
|
8
|
-
# @param onReady what to do when testFx condition is fulfilled,
|
9
|
-
# it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
10
|
-
# as a callback function.
|
11
|
-
# @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
|
12
|
-
##
|
13
|
-
waitFor = (testFx, onReady, timeOutMillis=3000) ->
|
14
|
-
start = new Date().getTime()
|
15
|
-
condition = false
|
16
|
-
f = ->
|
17
|
-
if (new Date().getTime() - start < timeOutMillis) and not condition
|
18
|
-
# If not time-out yet and condition not yet fulfilled
|
19
|
-
condition = (if typeof testFx is 'string' then eval testFx else testFx()) #< defensive code
|
20
|
-
else
|
21
|
-
if not condition
|
22
|
-
# If condition still not fulfilled (timeout but condition is 'false')
|
23
|
-
console.log "'waitFor()' timeout"
|
24
|
-
phantom.exit(1)
|
25
|
-
else
|
26
|
-
# Condition fulfilled (timeout and/or condition is 'true')
|
27
|
-
console.log "'waitFor()' finished in #{new Date().getTime() - start}ms."
|
28
|
-
if typeof onReady is 'string' then eval onReady else onReady() #< Do what it's supposed to do once the condition is fulfilled
|
29
|
-
clearInterval interval #< Stop this interval
|
30
|
-
interval = setInterval f, 100 #< repeat check every 100ms
|
31
|
-
|
32
|
-
if phantom.args.length isnt 1
|
33
|
-
console.log 'Usage: run-qunit.coffee URL'
|
34
|
-
phantom.exit(1)
|
35
|
-
|
36
|
-
page = require('webpage').create()
|
37
|
-
|
38
|
-
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
|
39
|
-
page.onConsoleMessage = (msg) ->
|
40
|
-
console.log msg
|
41
|
-
|
42
|
-
page.open phantom.args[0], (status) ->
|
43
|
-
if status isnt 'success'
|
44
|
-
console.log 'Unable to access network'
|
45
|
-
phantom.exit(1)
|
46
|
-
else
|
47
|
-
waitFor ->
|
48
|
-
page.evaluate ->
|
49
|
-
el = document.getElementById 'qunit-testresult'
|
50
|
-
if el and el.innerText.match 'completed'
|
51
|
-
return true
|
52
|
-
return false
|
53
|
-
, ->
|
54
|
-
failedNum = page.evaluate ->
|
55
|
-
el = document.getElementById 'qunit-testresult'
|
56
|
-
console.log el.innerText
|
57
|
-
try
|
58
|
-
return el.getElementsByClassName('failed')[0].innerHTML
|
59
|
-
catch e
|
60
|
-
return 10000
|
61
|
-
|
62
|
-
phantom.exit if parseInt(failedNum, 10) > 0 then 1 else 0
|
@@ -1,74 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Wait until the test condition is true or a timeout occurs. Useful for waiting
|
3
|
-
* on a server response or for a ui change (fadeIn, etc.) to occur.
|
4
|
-
*
|
5
|
-
* @param testFx javascript condition that evaluates to a boolean,
|
6
|
-
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
7
|
-
* as a callback function.
|
8
|
-
* @param onReady what to do when testFx condition is fulfilled,
|
9
|
-
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
|
10
|
-
* as a callback function.
|
11
|
-
* @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
|
12
|
-
*/
|
13
|
-
function waitFor(testFx, onReady, timeOutMillis) {
|
14
|
-
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3001, //< Default Max Timout is 3s
|
15
|
-
start = new Date().getTime(),
|
16
|
-
condition = false,
|
17
|
-
interval = setInterval(function() {
|
18
|
-
if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
|
19
|
-
// If not time-out yet and condition not yet fulfilled
|
20
|
-
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
|
21
|
-
} else {
|
22
|
-
if(!condition) {
|
23
|
-
// If condition still not fulfilled (timeout but condition is 'false')
|
24
|
-
console.log("'waitFor()' timeout");
|
25
|
-
phantom.exit(1);
|
26
|
-
} else {
|
27
|
-
// Condition fulfilled (timeout and/or condition is 'true')
|
28
|
-
console.log("'waitFor()' finished in " + (new Date().getTime() - start) + "ms.");
|
29
|
-
typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
|
30
|
-
clearInterval(interval); //< Stop this interval
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}, 100); //< repeat check every 250ms
|
34
|
-
};
|
35
|
-
|
36
|
-
|
37
|
-
if (phantom.args.length === 0 || phantom.args.length > 2) {
|
38
|
-
console.log('Usage: run-qunit.js URL');
|
39
|
-
phantom.exit(1);
|
40
|
-
}
|
41
|
-
|
42
|
-
var page = require('webpage').create();
|
43
|
-
|
44
|
-
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
|
45
|
-
page.onConsoleMessage = function(msg) {
|
46
|
-
console.log(msg);
|
47
|
-
};
|
48
|
-
|
49
|
-
page.open(phantom.args[0], function(status){
|
50
|
-
if (status !== "success") {
|
51
|
-
console.log("Unable to access network");
|
52
|
-
phantom.exit(1);
|
53
|
-
} else {
|
54
|
-
waitFor(function(){
|
55
|
-
return page.evaluate(function(){
|
56
|
-
var el = document.getElementById('qunit-testresult');
|
57
|
-
if (el && el.innerText.match('completed')) {
|
58
|
-
return true;
|
59
|
-
}
|
60
|
-
return false;
|
61
|
-
});
|
62
|
-
}, function(){
|
63
|
-
var failedNum = page.evaluate(function(){
|
64
|
-
var el = document.getElementById('qunit-testresult');
|
65
|
-
console.log(el.innerText);
|
66
|
-
try {
|
67
|
-
return el.getElementsByClassName('failed')[0].innerHTML;
|
68
|
-
} catch (e) { }
|
69
|
-
return 10000;
|
70
|
-
});
|
71
|
-
phantom.exit((parseInt(failedNum, 10) > 0) ? 1 : 0);
|
72
|
-
});
|
73
|
-
}
|
74
|
-
});
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# List all the files in a Tree of Directories
|
2
|
-
|
3
|
-
if phantom.args.length != 1
|
4
|
-
console.log "Usage: phantomjs scandir.js DIRECTORY_TO_SCAN"
|
5
|
-
phantom.exit()
|
6
|
-
scanDirectory = (path) ->
|
7
|
-
fs = require 'fs'
|
8
|
-
if fs.exists(path) and fs.isFile(path)
|
9
|
-
console.log path
|
10
|
-
else if fs.isDirectory(path)
|
11
|
-
fs.list(path).forEach (e) ->
|
12
|
-
scanDirectory path + "/" + e if e != "." and e != ".."
|
13
|
-
|
14
|
-
scanDirectory phantom.args[0]
|
15
|
-
phantom.exit()
|