wraith 2.6.0 → 2.7.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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/{wraith-logo.png → assets/wraith-logo.png} +0 -0
  4. data/lib/wraith/cli.rb +2 -9
  5. data/lib/wraith/folder.rb +5 -1
  6. data/lib/wraith/gallery.rb +11 -1
  7. data/lib/wraith/gallery_template/gallery_template.erb +3 -0
  8. data/lib/wraith/version.rb +1 -1
  9. data/lib/wraith/wraith.rb +1 -1
  10. data/{configs → spec/configs}/test_config--casper.yaml +6 -1
  11. data/{configs/test_config.yaml → spec/configs/test_config--phantom.yaml} +6 -1
  12. data/spec/helpers.rb +6 -2
  13. data/spec/js/global.js +2 -2
  14. data/spec/js/path.js +2 -2
  15. data/spec/thumbnails/test/test_image-1.png +0 -0
  16. data/spec/thumbnails/test/test_image-2.png +0 -0
  17. data/spec/thumbnails/test/test_image-diff.png +0 -0
  18. data/spec/wraith_spec.rb +79 -7
  19. data/templates/README.md +5 -0
  20. data/templates/configs/component.yaml +58 -0
  21. data/templates/configs/multiple_domains.yaml +54 -0
  22. data/templates/configs/spider.yaml +54 -0
  23. data/templates/javascript/README.md +5 -0
  24. data/templates/javascript/_getDimensions.js +7 -0
  25. data/templates/javascript/_phantom__common.js +122 -0
  26. data/templates/javascript/beforeCapture--casper_example.js +5 -0
  27. data/templates/javascript/beforeCapture--phantom_example.js +9 -0
  28. data/templates/javascript/casper.js +59 -0
  29. data/templates/javascript/phantom--nojs.js +6 -0
  30. data/templates/javascript/phantom.js +6 -0
  31. metadata +26 -17
  32. data/configs/component.yaml +0 -47
  33. data/configs/config_nojs.yaml +0 -43
  34. data/configs/custom_height.yaml +0 -42
  35. data/configs/history.yaml +0 -52
  36. data/configs/templates/component.yaml +0 -51
  37. data/configs/templates/config.yaml +0 -43
  38. data/lib/wraith/javascript/beforeCapture.js +0 -5
  39. data/lib/wraith/javascript/casper.js +0 -48
  40. data/lib/wraith/javascript/customHeight.js +0 -99
  41. data/lib/wraith/javascript/nojs.js +0 -85
  42. data/lib/wraith/javascript/snap.js +0 -85
data/configs/history.yaml DELETED
@@ -1,52 +0,0 @@
1
- #Headless browser option
2
- browser:
3
- phantomjs: "phantomjs"
4
- # slimerjs: "slimerjs"
5
-
6
- #If you want to have multiple snapping files, set the file name here
7
- snap_file: "lib/wraith/javascript/snap.js"
8
-
9
- # Type the name of the directory that shots will be stored in
10
- directory: 'shots'
11
- history_dir: 'shots_history'
12
-
13
- # Add only 2 domains, key will act as a label
14
- domains:
15
- arabic: "http://www.bbc.com/arabic"
16
-
17
- #Type screen widths below, here are a couple of examples
18
- screen_widths:
19
- - 320
20
- - 600
21
- - 768
22
- - 1024
23
- - 1280
24
-
25
- #Type page URL paths below, here are a couple of examples
26
- paths:
27
- home: /
28
- uk_index: /uk
29
-
30
- #Amount of fuzz ImageMagick will use
31
- fuzz: '20%'
32
-
33
- #Set the filename of the spider file to use, if not specified it will fallback to spider.txt
34
- # spider_file: bbc_co_uk_spider.txt
35
-
36
- #Set the number of days to keep the site spider file
37
- spider_days:
38
- - 10
39
-
40
- #A list of URLs to skip when spidering. Ruby regular expressions can be
41
- #used, if prefixed with !ruby/regexp as defined in the YAML Cookbook
42
- #http://www.yaml.org/YAML_for_ruby.html#regexps
43
- #
44
- # spider_skips:
45
- # - /foo/bar.html # Matches /foo/bar.html explcitly
46
- # - !ruby/regexp /^\/baz\// # Matches any URLs that start with /baz
47
-
48
- #Choose how results are displayed, by default alphanumeric. Different screen widths are always grouped.
49
- #alphanumeric - all paths (with, and without, a difference) are shown, sorted by path
50
- #diffs_first - all paths (with, and without, a difference) are shown, sorted by difference size (largest first)
51
- #diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
52
- #mode: diffs_first
@@ -1,51 +0,0 @@
1
- #Headless browser option
2
- browser:
3
- phantomjs: "casperjs"
4
- # slimerjs: "slimerjs"
5
-
6
- #If you want to have multiple snapping files, set the file name here
7
- snap_file: "javascript/casper.js"
8
-
9
- # Type the name of the directory that shots will be stored in
10
- directory: 'shots'
11
- history_dir: 'shots_base'
12
-
13
- # Add as many domains as necessary. Key will act as a label
14
- domains:
15
- english: "http://www.bbc.co.uk/news"
16
-
17
- #Type screen widths below, here are a couple of examples
18
- screen_widths:
19
- - 320
20
- - 600
21
- - 768
22
- - 1024
23
- - 1280
24
-
25
- #Type page URL paths below, here are a couple of examples
26
- paths:
27
- clickable_guide:
28
- path: /entertainment-arts-27221191
29
- selector: '.idt__news'
30
- clickable_guide__after_click:
31
- path: /entertainment-arts-27221191
32
- selector: '.idt__news'
33
- before_capture: 'javascript/beforeCapture.js'
34
-
35
- #Amount of fuzz ImageMagick will use
36
- fuzz: '20%'
37
-
38
- #Set the filename of the spider file to use, if not specified it will fallback to spider.txt
39
- # spider_file: bbc_co_uk_spider.txt
40
-
41
- #Set the number of days to keep the site spider file
42
- spider_days:
43
- - 10
44
-
45
- #Choose how results are displayed, by default alphanumeric. Different screen widths are always grouped.
46
- #alphanumeric - all paths (with, and without, a difference) are shown, sorted by path
47
- #diffs_first - all paths (with, and without, a difference) are shown, sorted by difference size (largest first)
48
- #diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
49
- mode: diffs_first
50
-
51
- threshold: 5
@@ -1,43 +0,0 @@
1
- #Headless browser option
2
- browser:
3
- phantomjs: "phantomjs"
4
- # slimerjs: "slimerjs"
5
-
6
- #If you want to have multiple snapping files, set the file name here
7
- snap_file: "javascript/snap.js"
8
-
9
- # Type the name of the directory that shots will be stored in
10
- directory: 'shots'
11
-
12
- # Add only 2 domains, key will act as a label
13
- domains:
14
- arabic: "http://www.live.bbc.co.uk/arabic"
15
- russian: "http://www.live.bbc.co.uk/russian"
16
-
17
- #Type screen widths below, here are a couple of examples
18
- screen_widths:
19
- - 320
20
- - 600
21
- - 768
22
- - 1024
23
- - 1280
24
-
25
- #Type page URL paths below, here are a couple of examples
26
- paths:
27
- home: /
28
- uk_index: /topics/video
29
-
30
- #Amount of fuzz ImageMagick will use
31
- fuzz: '20%'
32
-
33
- #Set the number of days to keep the site spider file
34
- spider_days:
35
- - 10
36
-
37
- #Choose how results are displayed, by default alphanumeric. Different screen widths are always grouped.
38
- #alphanumeric - all paths (with, and without, a difference) are shown, sorted by path
39
- #diffs_first - all paths (with, and without, a difference) are shown, sorted by difference size (largest first)
40
- #diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
41
- mode: diffs_first
42
-
43
- threshold: 5
@@ -1,5 +0,0 @@
1
- module.exports = function (casper) {
2
- casper.wait(2000, function() {
3
- casper.click('.ns-panel__hotspot--2');
4
- });
5
- }
@@ -1,48 +0,0 @@
1
- var system = require('system');
2
- var page = require('webpage').create();
3
- var fs = require('fs');
4
- var casper = require("casper").create();
5
-
6
- var url = casper.cli.get(0);
7
- var view_port_width = casper.cli.get(1);
8
- var image_name = casper.cli.get(2);
9
- var selector = casper.cli.get(3);
10
- var globalBeforeCaptureJS = casper.cli.get(4);
11
- var pathBeforeCaptureJS = casper.cli.get(5);
12
-
13
- function snap() {
14
- if (selector == undefined) {
15
- this.capture(image_name);
16
- }
17
- else {
18
- this.captureSelector(image_name, selector);
19
- }
20
- console.log('Snapping ' + url + ' at width ' + view_port_width);
21
- }
22
-
23
- casper.start();
24
- casper.open(url);
25
- casper.viewport(view_port_width, 1500);
26
- casper.then(function() {
27
- if (globalBeforeCaptureJS) {
28
- require('./' + globalBeforeCaptureJS)(this);
29
- }
30
- });
31
- casper.then(function() {
32
- if (pathBeforeCaptureJS) {
33
- require('./' + pathBeforeCaptureJS)(this);
34
- }
35
- });
36
- // waits for all images to download before taking screenshots
37
- // (broken images are a big cause of Wraith failures!)
38
- // Credit: http://reff.it/8m3HYP
39
- casper.waitFor(function() {
40
- return this.evaluate(function() {
41
- var images = document.getElementsByTagName('img');
42
- return Array.prototype.every.call(images, function(i) { return i.complete; });
43
- });
44
- }, function then () {
45
- snap.bind(this)();
46
- });
47
-
48
- casper.run();
@@ -1,99 +0,0 @@
1
- var system = require('system');
2
- var page = require('webpage').create();
3
- var fs = require('fs');
4
-
5
- if (system.args.length === 3) {
6
- console.log('Usage: snap.js <some URL> <view port width> <target image name>');
7
- phantom.exit();
8
- }
9
-
10
- var url = system.args[1];
11
- var image_name = system.args[3];
12
- var dimensions = /(\d*)x?((\d*))?/i.exec(system.args[2]);
13
- var view_port_width = dimensions[1];
14
- var view_port_height = dimensions[2] || 1500;
15
- var current_requests = 0;
16
- var last_request_timeout;
17
- var final_timeout;
18
-
19
-
20
- page.viewportSize = { width: view_port_width, height: view_port_height};
21
- page.settings = { loadImages: true, javascriptEnabled: true };
22
-
23
- // If you want to use additional phantomjs commands, place them here
24
- page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.17';
25
-
26
- // You can place custom headers here, example below.
27
- // page.customHeaders = {
28
-
29
- // 'X-Candy-OVERRIDE': 'https://api.live.bbc.co.uk/'
30
-
31
- // };
32
-
33
- // If you want to set a cookie, just add your details below in the following way.
34
-
35
- // phantom.addCookie({
36
- // 'name': 'ckns_policy',
37
- // 'value': '111',
38
- // 'domain': '.bbc.co.uk'
39
- // });
40
- // phantom.addCookie({
41
- // 'name': 'locserv',
42
- // 'value': '1#l1#i=6691484:n=Oxford+Circus:h=e@w1#i=8:p=London@d1#1=l:2=e:3=e:4=2@n1#r=40',
43
- // 'domain': '.bbc.co.uk'
44
- // });
45
-
46
- page.onResourceRequested = function(req) {
47
- current_requests += 1;
48
- };
49
-
50
- page.onResourceReceived = function(res) {
51
- if (res.stage === 'end') {
52
- current_requests -= 1;
53
- debounced_render();
54
- }
55
- };
56
-
57
- page.open(url, function(status) {
58
- if (status !== 'success') {
59
- console.log('Error with page ' + url);
60
- phantom.exit();
61
- }
62
- });
63
-
64
-
65
- function debounced_render() {
66
- clearTimeout(last_request_timeout);
67
- clearTimeout(final_timeout);
68
-
69
- // If there's no more ongoing resource requests, wait for 1 second before
70
- // rendering, just in case the page kicks off another request
71
- if (current_requests < 1) {
72
- clearTimeout(final_timeout);
73
- last_request_timeout = setTimeout(function() {
74
- console.log('Snapping ' + url + ' at width ' + view_port_width);
75
- page.clipRect = {
76
- top: 0,
77
- left: 0,
78
- height: view_port_height,
79
- width: view_port_width
80
- };
81
- page.render(image_name);
82
- phantom.exit();
83
- }, 1000);
84
- }
85
-
86
- // Sometimes, straggling requests never make it back, in which
87
- // case, timeout after 5 seconds and render the page anyway
88
- final_timeout = setTimeout(function() {
89
- console.log('Snapping ' + url + ' at width ' + view_port_width);
90
- page.clipRect = {
91
- top: 0,
92
- left: 0,
93
- height: view_port_height,
94
- width: view_port_width
95
- };
96
- page.render(image_name);
97
- phantom.exit();
98
- }, 5000);
99
- }
@@ -1,85 +0,0 @@
1
- var system = require('system');
2
- var page = require('webpage').create();
3
- var fs = require('fs');
4
-
5
- if (system.args.length === 3) {
6
- console.log('Usage: snap.js <some URL> <view port width> <target image name>');
7
- phantom.exit();
8
- }
9
-
10
- var url = system.args[1];
11
- var image_name = system.args[3];
12
- var view_port_width = system.args[2];
13
- var current_requests = 0;
14
- var last_request_timeout;
15
- var final_timeout;
16
-
17
-
18
- page.viewportSize = { width: view_port_width, height: 1500};
19
- page.settings = { loadImages: true, javascriptEnabled: false };
20
-
21
- // If you want to use additional phantomjs commands, place them here
22
- page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.17';
23
-
24
- // You can place custom headers here, example below.
25
- // page.customHeaders = {
26
-
27
- // 'X-Candy-OVERRIDE': 'https://api.live.bbc.co.uk/'
28
-
29
- // };
30
-
31
- // If you want to set a cookie, just add your details below in the following way.
32
-
33
- // phantom.addCookie({
34
- // 'name': 'ckns_policy',
35
- // 'value': '111',
36
- // 'domain': '.bbc.co.uk'
37
- // });
38
- // phantom.addCookie({
39
- // 'name': 'locserv',
40
- // 'value': '1#l1#i=6691484:n=Oxford+Circus:h=e@w1#i=8:p=London@d1#1=l:2=e:3=e:4=2@n1#r=40',
41
- // 'domain': '.bbc.co.uk'
42
- // });
43
-
44
- page.onResourceRequested = function(req) {
45
- current_requests += 1;
46
- };
47
-
48
- page.onResourceReceived = function(res) {
49
- if (res.stage === 'end') {
50
- current_requests -= 1;
51
- debounced_render();
52
- }
53
- };
54
-
55
- page.open(url, function(status) {
56
- if (status !== 'success') {
57
- console.log('Error with page ' + url);
58
- phantom.exit();
59
- }
60
- });
61
-
62
-
63
- function debounced_render() {
64
- clearTimeout(last_request_timeout);
65
- clearTimeout(final_timeout);
66
-
67
- // If there's no more ongoing resource requests, wait for 1 second before
68
- // rendering, just in case the page kicks off another request
69
- if (current_requests < 1) {
70
- clearTimeout(final_timeout);
71
- last_request_timeout = setTimeout(function() {
72
- console.log('Snapping ' + url + ' at width ' + view_port_width);
73
- page.render(image_name);
74
- phantom.exit();
75
- }, 1000);
76
- }
77
-
78
- // Sometimes, straggling requests never make it back, in which
79
- // case, timeout after 5 seconds and render the page anyway
80
- final_timeout = setTimeout(function() {
81
- console.log('Snapping ' + url + ' at width ' + view_port_width);
82
- page.render(image_name);
83
- phantom.exit();
84
- }, 5000);
85
- }
@@ -1,85 +0,0 @@
1
- var system = require('system');
2
- var page = require('webpage').create();
3
- var fs = require('fs');
4
-
5
- if (system.args.length === 3) {
6
- console.log('Usage: snap.js <some URL> <view port width> <target image name>');
7
- phantom.exit();
8
- }
9
-
10
- var url = system.args[1];
11
- var image_name = system.args[3];
12
- var view_port_width = system.args[2];
13
- var current_requests = 0;
14
- var last_request_timeout;
15
- var final_timeout;
16
-
17
-
18
- page.viewportSize = { width: view_port_width, height: 1500};
19
- page.settings = { loadImages: true, javascriptEnabled: true };
20
-
21
- // If you want to use additional phantomjs commands, place them here
22
- page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.17';
23
-
24
- // You can place custom headers here, example below.
25
- // page.customHeaders = {
26
-
27
- // 'X-Candy-OVERRIDE': 'https://api.live.bbc.co.uk/'
28
-
29
- // };
30
-
31
- // If you want to set a cookie, just add your details below in the following way.
32
-
33
- // phantom.addCookie({
34
- // 'name': 'ckns_policy',
35
- // 'value': '111',
36
- // 'domain': '.bbc.co.uk'
37
- // });
38
- // phantom.addCookie({
39
- // 'name': 'locserv',
40
- // 'value': '1#l1#i=6691484:n=Oxford+Circus:h=e@w1#i=8:p=London@d1#1=l:2=e:3=e:4=2@n1#r=40',
41
- // 'domain': '.bbc.co.uk'
42
- // });
43
-
44
- page.onResourceRequested = function(req) {
45
- current_requests += 1;
46
- };
47
-
48
- page.onResourceReceived = function(res) {
49
- if (res.stage === 'end') {
50
- current_requests -= 1;
51
- debounced_render();
52
- }
53
- };
54
-
55
- page.open(url, function(status) {
56
- if (status !== 'success') {
57
- console.log('Error with page ' + url);
58
- phantom.exit();
59
- }
60
- });
61
-
62
-
63
- function debounced_render() {
64
- clearTimeout(last_request_timeout);
65
- clearTimeout(final_timeout);
66
-
67
- // If there's no more ongoing resource requests, wait for 1 second before
68
- // rendering, just in case the page kicks off another request
69
- if (current_requests < 1) {
70
- clearTimeout(final_timeout);
71
- last_request_timeout = setTimeout(function() {
72
- console.log('Snapping ' + url + ' at width ' + view_port_width);
73
- page.render(image_name);
74
- phantom.exit();
75
- }, 1000);
76
- }
77
-
78
- // Sometimes, straggling requests never make it back, in which
79
- // case, timeout after 5 seconds and render the page anyway
80
- final_timeout = setTimeout(function() {
81
- console.log('Snapping ' + url + ' at width ' + view_port_width);
82
- page.render(image_name);
83
- phantom.exit();
84
- }, 5000);
85
- }