wraith 1.3.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +42 -15
- data/configs/config.yaml +4 -12
- data/configs/config_nojs.yaml +4 -12
- data/configs/history.yaml +52 -0
- data/configs/test_config.yaml +3 -25
- data/lib/wraith/cli.rb +16 -3
- data/lib/wraith/folder.rb +13 -0
- data/lib/wraith/gallery.rb +53 -28
- data/lib/wraith/save_images.rb +17 -5
- data/lib/wraith/thumbnails.rb +1 -1
- data/lib/wraith/version.rb +1 -1
- data/lib/wraith/wraith.rb +6 -1
- data/spec/wraith_spec.rb +4 -4
- data/templates/configs/config.yaml +21 -12
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d01c988c9cf4c296a6ed667f355fc88bbed62b5
|
4
|
+
data.tar.gz: 1a6ecf623f3639c980148cc964d413bc15c66716
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 226e733d3f7c7ae0fd19c2292238aa9abedd89bbffb5721c0af1b4c0d970385a154bd0c68a1c65b9e85d65c4c9fb7bd8161fb7f12d6d89d348a745065b42149e
|
7
|
+
data.tar.gz: a7a2328d86e60ce253030698cddcc08c6ccce27007b377437a4878c59bb18759e82f3e9bc07425c3b393f0e4aac98b9a6f8c0f9a7ed0a9317d73359bc180d0d8
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -47,18 +47,29 @@ You can type `wraith` into terminal to bring up the list of commands, but the on
|
|
47
47
|
wraith capture config_name
|
48
48
|
```
|
49
49
|
|
50
|
-
This assumes that your snap.js and config.yaml are in the folders that were created on setup.
|
50
|
+
This assumes that your snap.js and config.yaml are in the folders that were created on setup. To run the setup, create a folder and inside run
|
51
51
|
|
52
52
|
```sh
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
wraith
|
53
|
+
wraith setup
|
54
|
+
```
|
55
|
+
|
56
|
+
### CLI
|
57
|
+
|
58
|
+
There are other commands also available, these all expect a config_name to be passed as an option. Wraith will look for the config file at `configs/[config_name].yaml`.
|
59
|
+
|
60
|
+
```sh
|
61
|
+
wraith capture [config_name] # A full Wraith job
|
62
|
+
wraith compare_images [config_name] # compares images to generate diffs
|
63
|
+
wraith crop_images [config_name] # crops images to the same height
|
64
|
+
wraith generate_gallery [config_name] # create page for viewing images
|
65
|
+
wraith generate_thumbnails [config_name] # create thumbnails for gallery
|
66
|
+
wraith history [config_name] # Setup a baseline set of shots
|
67
|
+
wraith latest [config_name] # Capture new shots to compare with baseline
|
68
|
+
wraith multi_capture [filelist] # A Batch of Wraith Jobs
|
69
|
+
wraith reset_shots [config_name] # removes all the files in the shots folder
|
70
|
+
wraith save_images [config_name] # captures screenshots
|
71
|
+
wraith setup # creates config folder and default config
|
72
|
+
wraith setup_folders [config_name] # create folders for images
|
62
73
|
```
|
63
74
|
|
64
75
|
## Output
|
@@ -69,6 +80,25 @@ After each screenshot is captured, the compare task will run, this will output a
|
|
69
80
|
|
70
81
|
A gallery is available to view each of the images and the respective diff images located in the shots folder once all the images have been compared.
|
71
82
|
|
83
|
+
## History usage
|
84
|
+
|
85
|
+
In Wraith 2.0 we introduced a new way for using Wraith in development and testing, historical shots. Rather than capture 2 domains, you capture 1 domain, probably your local copy of the latest code, then later on after development is in progress, run Wraith again to compare. This makes working against an isolated dev environment much easier as you wont need an internet connection.
|
86
|
+
|
87
|
+
The usage is different in that you need 1 domain in your config and you will need to set a historical shots folder. An example of this can be found on Github. The way this works is that shots are captured as normal with the history command below. This will create 2 folders with the labels you have specified in the config file, for example, shots and shots_history. The original shots will be copied into your 'history' folder, then copied back into the shots folder once you have run your latest job. This workflow will essentially mean your history folder is your baseline, being copied back into the shots folder every time you run the 'latest command'
|
88
|
+
|
89
|
+
```sh
|
90
|
+
wraith history history.yaml
|
91
|
+
```
|
92
|
+
After some development, run the latest command
|
93
|
+
```sh
|
94
|
+
wraith latest history.yaml
|
95
|
+
```
|
96
|
+
You will now be able to run the latest command over and over without having to do clear up.
|
97
|
+
|
98
|
+
## Changelog - updated 2014-09-25
|
99
|
+
Wraith 2.0 with new history support, this is a big change for the usage of Wraith, with less dependency on having an Internet connection and capturing two domains.
|
100
|
+
A large change in the way file names are made has been introduced into 2.0, with the label of the engine now being used instead of the engine string itself. This has been updated in all the included configs for reference, but will mean a change to the filenames and urls. We have also changed the way that folders are loaded from the config, dropping the use of arrays. This is backward compatible.
|
101
|
+
|
72
102
|
## Contributing
|
73
103
|
|
74
104
|
If you want to add functionality to this project, pull requests are welcome.
|
@@ -83,9 +113,6 @@ If you want to add functionality to this project, pull requests are welcome.
|
|
83
113
|
|
84
114
|
**Please raise any issues with this project as a GitHub issue.**
|
85
115
|
|
86
|
-
## Changelog - updated 2014-05-14
|
87
|
-
We have updated Wraith some bug fixes and more importantly, parallel support. This will now enable use of all your CPU cores for faster Wraith runs. There is error handling in place to ensure if an image fails to capture, it will try again 5 times, if that fails, it will put an holding image in place. This should solve all the issues with images not capturing and failing to crop/compare. Big thanks to [Matt Senior](https://github.com/mattsenior) for doing the work.
|
88
|
-
|
89
116
|
## License
|
90
117
|
|
91
118
|
Wraith is available to everyone under the terms of the Apache 2.0 open source license.
|
@@ -96,10 +123,10 @@ Take a look at the LICENSE file in the code.
|
|
96
123
|
* [Dave Blooman](http://twitter.com/dblooman)
|
97
124
|
* [John Cleveley](http://twitter.com/jcleveley)
|
98
125
|
* [Simon Thulbourn](http://twitter.com/sthulbourn)
|
99
|
-
|
126
|
+
|
100
127
|
## Selenium-Wraith
|
101
128
|
|
102
|
-
Anyone interested in integrating selenium capability with Wraith should check out
|
129
|
+
Anyone interested in integrating selenium capability with Wraith should check out
|
103
130
|
Selenium-Wraith by Andrew Tekle-Cadman of Future Visible.
|
104
131
|
|
105
132
|
Selenium-Wraith was forked from the BBC repo on 16/04/14 and adds the following capabilities to Wraith
|
data/configs/config.yaml
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
#Headless browser option
|
2
2
|
browser:
|
3
|
-
|
4
|
-
#
|
3
|
+
phantomjs: "phantomjs"
|
4
|
+
# slimerjs: "slimerjs"
|
5
5
|
|
6
6
|
#If you want to have multiple snapping files, set the file name here
|
7
7
|
snap_file: "lib/wraith/javascript/snap.js"
|
8
8
|
|
9
9
|
# Type the name of the directory that shots will be stored in
|
10
|
-
directory:
|
11
|
-
- 'shots'
|
10
|
+
directory: 'shots'
|
12
11
|
|
13
12
|
# Add only 2 domains, key will act as a label
|
14
13
|
domains:
|
@@ -28,13 +27,6 @@ paths:
|
|
28
27
|
home: /
|
29
28
|
uk_index: /uk
|
30
29
|
|
31
|
-
# If you don't want to name the paths explicitly you can use a yaml
|
32
|
-
# collection as follows, and names will be derived by replacing / with _
|
33
|
-
#
|
34
|
-
# paths:
|
35
|
-
# - /
|
36
|
-
# - /uk
|
37
|
-
|
38
30
|
#Amount of fuzz ImageMagick will use
|
39
31
|
fuzz: '20%'
|
40
32
|
|
@@ -45,7 +37,7 @@ fuzz: '20%'
|
|
45
37
|
spider_days:
|
46
38
|
- 10
|
47
39
|
|
48
|
-
#A list of URLs to skip when spidering. Ruby regular expressions can be
|
40
|
+
#A list of URLs to skip when spidering. Ruby regular expressions can be
|
49
41
|
#used, if prefixed with !ruby/regexp as defined in the YAML Cookbook
|
50
42
|
#http://www.yaml.org/YAML_for_ruby.html#regexps
|
51
43
|
#
|
data/configs/config_nojs.yaml
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
#Headless browser option
|
2
2
|
browser:
|
3
|
-
|
4
|
-
#
|
3
|
+
phantomjs: "phantomjs"
|
4
|
+
# slimerjs: "slimerjs"
|
5
5
|
|
6
6
|
#If you want to have multiple snapping files, set the file name here
|
7
7
|
snap_file: "lib/wraith/javascript/nojs.js"
|
8
8
|
|
9
9
|
# Type the name of the directory that shots will be stored in
|
10
|
-
directory:
|
11
|
-
- 'shots_nojs'
|
10
|
+
directory: 'shots_nojs'
|
12
11
|
|
13
12
|
# Add only 2 domains, key will act as a label
|
14
13
|
domains:
|
@@ -28,13 +27,6 @@ paths:
|
|
28
27
|
home: /
|
29
28
|
uk_index: /uk
|
30
29
|
|
31
|
-
# If you don't want to name the paths explicitly you can use a yaml
|
32
|
-
# collection as follows, and names will be derived by replacing / with _
|
33
|
-
#
|
34
|
-
# paths:
|
35
|
-
# - /imghp
|
36
|
-
# - /maps
|
37
|
-
|
38
30
|
#Amount of fuzz ImageMagick will use
|
39
31
|
fuzz: '20%'
|
40
32
|
|
@@ -42,7 +34,7 @@ fuzz: '20%'
|
|
42
34
|
spider_days:
|
43
35
|
- 10
|
44
36
|
|
45
|
-
#A list of URLs to skip when spidering. Ruby regular expressions can be
|
37
|
+
#A list of URLs to skip when spidering. Ruby regular expressions can be
|
46
38
|
#used, if prefixed with !ruby/regexp as defined in the YAML Cookbook
|
47
39
|
#http://www.yaml.org/YAML_for_ruby.html#regexps
|
48
40
|
#
|
@@ -0,0 +1,52 @@
|
|
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
|
+
news: "http://www.live.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
|
+
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
|
data/configs/test_config.yaml
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
#Headless browser option
|
2
2
|
browser:
|
3
|
-
|
4
|
-
#
|
3
|
+
phantomjs: "phantomjs"
|
4
|
+
# slimerjs: "slimerjs"
|
5
5
|
|
6
6
|
#If you want to have multiple snapping files, set the file name here
|
7
7
|
snap_file: "lib/wraith/javascript/snap.js"
|
8
8
|
|
9
9
|
# Type the name of the directory that shots will be stored in
|
10
|
-
directory:
|
11
|
-
- 'shots'
|
10
|
+
directory: 'shots'
|
12
11
|
|
13
12
|
# Add only 2 domains, key will act as a label
|
14
13
|
domains:
|
@@ -28,26 +27,5 @@ paths:
|
|
28
27
|
home: /
|
29
28
|
uk_index: /uk
|
30
29
|
|
31
|
-
# If you don't want to name the paths explicitly you can use a yaml
|
32
|
-
# collection as follows, and names will be derived by replacing / with _
|
33
|
-
#
|
34
|
-
# paths:
|
35
|
-
# - /imghp
|
36
|
-
# - /maps
|
37
|
-
|
38
30
|
#Amount of fuzz ImageMagick will use
|
39
31
|
fuzz: '20%'
|
40
|
-
|
41
|
-
#Set the filename of the spider file to use, if not specified it will fallback to spider.txt
|
42
|
-
# spider_file: bbc_co_uk_spider.txt
|
43
|
-
|
44
|
-
#Set the number of days to keep the site spider file
|
45
|
-
spider_days:
|
46
|
-
- 10
|
47
|
-
#A list of URLs to skip when spidering. Ruby regular expressions can be
|
48
|
-
#used, if prefixed with !ruby/regexp as defined in the YAML Cookbook
|
49
|
-
#http://www.yaml.org/YAML_for_ruby.html#regexps
|
50
|
-
#
|
51
|
-
# spider_skips:
|
52
|
-
# - /foo/bar.html # Matches /foo/bar.html explcitly
|
53
|
-
# - !ruby/regexp /^\/baz\// # Matches any URLs that start with /baz
|
data/lib/wraith/cli.rb
CHANGED
@@ -40,11 +40,21 @@ class Wraith::CLI < Thor
|
|
40
40
|
spider = Wraith::Spidering.new(config_name)
|
41
41
|
spider.check_for_paths
|
42
42
|
end
|
43
|
+
|
44
|
+
def copy_old_shots(config_name)
|
45
|
+
create = Wraith::FolderManager.new(config_name)
|
46
|
+
create.copy_old_shots
|
47
|
+
end
|
48
|
+
|
49
|
+
def restore_shots(config_name)
|
50
|
+
create = Wraith::FolderManager.new(config_name)
|
51
|
+
create.restore_shots
|
52
|
+
end
|
43
53
|
end
|
44
54
|
|
45
55
|
desc 'save_images [config_name]', 'captures screenshots'
|
46
|
-
def save_images(config_name)
|
47
|
-
save_images = Wraith::SaveImages.new(config_name)
|
56
|
+
def save_images(config_name, history = false)
|
57
|
+
save_images = Wraith::SaveImages.new(config_name, history)
|
48
58
|
save_images.save_images
|
49
59
|
end
|
50
60
|
|
@@ -98,11 +108,14 @@ class Wraith::CLI < Thor
|
|
98
108
|
reset_shots(config)
|
99
109
|
setup_folders(config)
|
100
110
|
save_images(config)
|
111
|
+
copy_old_shots(config)
|
101
112
|
end
|
102
113
|
|
103
114
|
desc 'latest [config_name]', 'Capture new shots to compare with baseline'
|
104
115
|
def latest(config)
|
105
|
-
|
116
|
+
reset_shots(config)
|
117
|
+
restore_shots(config)
|
118
|
+
save_images(config, true)
|
106
119
|
crop_images(config)
|
107
120
|
compare_images(config)
|
108
121
|
generate_thumbnails(config)
|
data/lib/wraith/folder.rb
CHANGED
@@ -11,6 +11,10 @@ class Wraith::FolderManager
|
|
11
11
|
wraith.directory
|
12
12
|
end
|
13
13
|
|
14
|
+
def history_dir
|
15
|
+
wraith.history_dir
|
16
|
+
end
|
17
|
+
|
14
18
|
def paths
|
15
19
|
wraith.paths
|
16
20
|
end
|
@@ -29,6 +33,15 @@ class Wraith::FolderManager
|
|
29
33
|
FileUtils.mkdir_p("#{dir}")
|
30
34
|
end
|
31
35
|
|
36
|
+
def copy_old_shots
|
37
|
+
FileUtils.cp_r(dir, history_dir)
|
38
|
+
end
|
39
|
+
|
40
|
+
def restore_shots
|
41
|
+
puts 'restoring'
|
42
|
+
FileUtils.cp_r(Dir.glob("#{history_dir}/*"), dir)
|
43
|
+
end
|
44
|
+
|
32
45
|
def create_folders
|
33
46
|
spider_paths.each do |folder_label, path|
|
34
47
|
unless path
|
data/lib/wraith/gallery.rb
CHANGED
@@ -37,43 +37,68 @@ class Wraith::GalleryGenerator
|
|
37
37
|
def match(categories, dirname)
|
38
38
|
categories.each do |category|
|
39
39
|
@dirs[category] = {}
|
40
|
+
|
40
41
|
Dir.foreach("#{dirname}/#{category}") do |filename|
|
41
42
|
match = MATCH_FILENAME.match(filename)
|
42
43
|
unless match.nil?
|
43
|
-
|
44
|
-
group = match[2]
|
45
|
-
filepath = category + '/' + filename
|
46
|
-
thumbnail = "thumbnails/#{category}/#{filename}"
|
47
|
-
|
48
|
-
if @dirs[category][size].nil?
|
49
|
-
@dirs[category][size] = { variants: [] }
|
50
|
-
end
|
51
|
-
size_dict = @dirs[category][size]
|
52
|
-
|
53
|
-
case group
|
54
|
-
when 'diff'
|
55
|
-
size_dict[:diff] = {
|
56
|
-
filename: filepath, thumb: thumbnail
|
57
|
-
}
|
58
|
-
when 'data'
|
59
|
-
size_dict[:data] = File.read("#{dirname}/#{filepath}").to_f
|
60
|
-
else
|
61
|
-
size_dict[:variants] << {
|
62
|
-
name: group,
|
63
|
-
filename: filepath,
|
64
|
-
thumb: thumbnail
|
65
|
-
}
|
66
|
-
|
67
|
-
end
|
68
|
-
size_dict[:variants].sort! { |a, b| a[:name] <=> b[:name] }
|
44
|
+
matcher(match, filename, dirname, category)
|
69
45
|
end
|
70
46
|
end
|
71
47
|
end
|
72
48
|
@folder_manager.tidy_shots_folder(@dirs)
|
49
|
+
sorting_dirs(@dirs)
|
50
|
+
end
|
51
|
+
|
52
|
+
def matcher(match, filename, dirname, category)
|
53
|
+
@size = match[1].to_i
|
54
|
+
@group = match[2]
|
55
|
+
@filepath = category + '/' + filename
|
56
|
+
@thumbnail = "thumbnails/#{category}/#{filename}"
|
57
|
+
|
58
|
+
if @dirs[category][@size].nil?
|
59
|
+
@dirs[category][@size] = { variants: [] }
|
60
|
+
end
|
61
|
+
|
62
|
+
size_dict = @dirs[category][@size]
|
63
|
+
|
64
|
+
data_group(@group, size_dict, dirname, @filepath)
|
65
|
+
end
|
66
|
+
|
67
|
+
def data_group(group, size_dict, dirname, filepath)
|
68
|
+
case group
|
69
|
+
when 'diff'
|
70
|
+
diff_check(size_dict, filepath)
|
71
|
+
when 'data'
|
72
|
+
data_check(size_dict, dirname, filepath)
|
73
|
+
else
|
74
|
+
variant_check(size_dict, group)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def variant_check(size_dict, group)
|
79
|
+
size_dict[:variants] << {
|
80
|
+
name: group,
|
81
|
+
filename: @filepath,
|
82
|
+
thumb: @thumbnail
|
83
|
+
}
|
84
|
+
size_dict[:variants].sort! { |a, b| a[:name] <=> b[:name] }
|
85
|
+
end
|
86
|
+
|
87
|
+
def diff_check(size_dict, filepath)
|
88
|
+
size_dict[:diff] = {
|
89
|
+
filename: filepath, thumb: @thumbnail
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
def data_check(size_dict, dirname, filepath)
|
94
|
+
size_dict[:data] = File.read("#{dirname}/#{filepath}").to_f
|
95
|
+
end
|
96
|
+
|
97
|
+
def sorting_dirs(dirs)
|
73
98
|
if %w(diffs_only diffs_first).include?(wraith.mode)
|
74
|
-
@sorted =
|
99
|
+
@sorted = dirs.sort_by { |_category, sizes| -1 * sizes.max_by { |_size, dict| dict[:data] }[1][:data] }
|
75
100
|
else
|
76
|
-
@sorted =
|
101
|
+
@sorted = dirs.sort_by { |category, _sizes| category }
|
77
102
|
end
|
78
103
|
# The sort has made this into an enumerable, convert it back to a Hash
|
79
104
|
Hash[@sorted]
|
data/lib/wraith/save_images.rb
CHANGED
@@ -2,10 +2,11 @@ require 'wraith'
|
|
2
2
|
require 'parallel'
|
3
3
|
|
4
4
|
class Wraith::SaveImages
|
5
|
-
attr_reader :wraith
|
5
|
+
attr_reader :wraith, :history
|
6
6
|
|
7
|
-
def initialize(config)
|
7
|
+
def initialize(config, history = false)
|
8
8
|
@wraith = Wraith::Wraith.new(config)
|
9
|
+
@history = history
|
9
10
|
end
|
10
11
|
|
11
12
|
def directory
|
@@ -21,10 +22,18 @@ class Wraith::SaveImages
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
25
|
+
def history_label
|
26
|
+
history ? '_latest' : ''
|
27
|
+
end
|
28
|
+
|
24
29
|
def engine
|
25
30
|
wraith.engine.each { |_label, browser| return browser }
|
26
31
|
end
|
27
32
|
|
33
|
+
def engine_label
|
34
|
+
wraith.engine.key(engine)
|
35
|
+
end
|
36
|
+
|
28
37
|
def base_urls(path)
|
29
38
|
wraith.base_domain + path unless wraith.base_domain.nil?
|
30
39
|
end
|
@@ -34,7 +43,7 @@ class Wraith::SaveImages
|
|
34
43
|
end
|
35
44
|
|
36
45
|
def file_names(width, label, domain_label)
|
37
|
-
"#{directory}/#{label}/#{width}_#{
|
46
|
+
"#{directory}/#{label}/#{width}_#{engine_label}_#{domain_label}.png"
|
38
47
|
end
|
39
48
|
|
40
49
|
def attempt_image_capture(width, url, filename, max_attempts)
|
@@ -61,14 +70,17 @@ class Wraith::SaveImages
|
|
61
70
|
compare_url = compare_urls(path)
|
62
71
|
|
63
72
|
wraith.widths.each do |width|
|
64
|
-
base_file_name = file_names(width, label, wraith.base_domain_label)
|
65
|
-
compare_file_name = file_names(width, label, wraith.comp_domain_label)
|
73
|
+
base_file_name = file_names(width, label, "#{wraith.base_domain_label}#{history_label}")
|
74
|
+
compare_file_name = file_names(width, label, "#{wraith.comp_domain_label}#{history_label}")
|
66
75
|
|
67
76
|
jobs << [label, path, width, base_url, base_file_name]
|
68
77
|
jobs << [label, path, width, compare_url, compare_file_name] unless compare_url.nil?
|
69
78
|
end
|
70
79
|
end
|
80
|
+
parallel_task(jobs)
|
81
|
+
end
|
71
82
|
|
83
|
+
def parallel_task(jobs)
|
72
84
|
Parallel.each(jobs, in_threads: 8) do |_label, _path, width, url, filename|
|
73
85
|
begin
|
74
86
|
attempt_image_capture(width, url, filename, 5)
|
data/lib/wraith/thumbnails.rb
CHANGED
@@ -22,7 +22,7 @@ class Wraith::Thumbnails
|
|
22
22
|
|
23
23
|
def thumbnail_image(png_path, output_path)
|
24
24
|
unless File.directory?(File.dirname(output_path))
|
25
|
-
|
25
|
+
FileUtils.mkdir_p(File.dirname(output_path))
|
26
26
|
end
|
27
27
|
|
28
28
|
`convert #{png_path} -thumbnail 200 -crop 200x200+0+0 #{output_path}`
|
data/lib/wraith/version.rb
CHANGED
data/lib/wraith/wraith.rb
CHANGED
@@ -15,7 +15,12 @@ class Wraith::Wraith
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def directory
|
18
|
-
|
18
|
+
# Legacy support for those using array configs
|
19
|
+
@config['directory'].is_a?(Array) ? @config['directory'].first : @config['directory']
|
20
|
+
end
|
21
|
+
|
22
|
+
def history_dir
|
23
|
+
@config['history_dir']
|
19
24
|
end
|
20
25
|
|
21
26
|
def snap_file
|
data/spec/wraith_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe Wraith do
|
|
19
19
|
|
20
20
|
context 'When creating a wraith worker' do
|
21
21
|
|
22
|
-
Then { wraith.config.keys.size ==
|
22
|
+
Then { wraith.config.keys.size == 7 }
|
23
23
|
Then { wraith.widths == [320, 600, 768, 1024, 1280] }
|
24
24
|
Then { wraith.base_domain == 'http://pal.live.bbc.com/news' }
|
25
25
|
Then { wraith.comp_domain == 'http://pal.live.bbc.co.uk/russian' }
|
@@ -60,8 +60,8 @@ describe Wraith do
|
|
60
60
|
end
|
61
61
|
Wraith::CropImages.new(config_name).crop_images
|
62
62
|
Wraith::CompareImages.new(config_name).compare_task(test_image1, test_image2, diff_image, data_txt)
|
63
|
-
Wraith::Thumbnails.new(config_name).generate_thumbnails
|
64
|
-
|
65
|
-
Then { File.
|
63
|
+
Wraith::Thumbnails.new(config_name).generate_thumbnails
|
64
|
+
end
|
65
|
+
Then { File.exist?('shots/thumbnails/test/test1.png') && File.exist?('shots/thumbnails/test/test2.png') && File.exist?('shots/thumbnails/test/test_diff.png') }
|
66
66
|
end
|
67
67
|
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
#Headless browser option
|
2
2
|
browser:
|
3
|
-
|
4
|
-
#
|
3
|
+
phantomjs: "phantomjs"
|
4
|
+
# slimerjs: "slimerjs"
|
5
5
|
|
6
6
|
#If you want to have multiple snapping files, set the file name here
|
7
|
-
snap_file: "javascript/snap.js"
|
7
|
+
snap_file: "lib/wraith/javascript/snap.js"
|
8
8
|
|
9
9
|
# Type the name of the directory that shots will be stored in
|
10
|
-
directory:
|
11
|
-
- 'shots'
|
10
|
+
directory: 'shots'
|
12
11
|
|
13
12
|
# Add only 2 domains, key will act as a label
|
14
13
|
domains:
|
@@ -28,16 +27,26 @@ paths:
|
|
28
27
|
home: /
|
29
28
|
uk_index: /uk
|
30
29
|
|
31
|
-
# If you don't want to name the paths explicitly you can use a yaml
|
32
|
-
# collection as follows, and names will be derived by replacing / with _
|
33
|
-
#
|
34
|
-
# paths:
|
35
|
-
# - /imghp
|
36
|
-
# - /maps
|
37
|
-
|
38
30
|
#Amount of fuzz ImageMagick will use
|
39
31
|
fuzz: '20%'
|
40
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
|
+
|
41
36
|
#Set the number of days to keep the site spider file
|
42
37
|
spider_days:
|
43
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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wraith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Blooman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- bin/wraith
|
174
174
|
- configs/config.yaml
|
175
175
|
- configs/config_nojs.yaml
|
176
|
+
- configs/history.yaml
|
176
177
|
- configs/test_config.yaml
|
177
178
|
- lib/wraith.rb
|
178
179
|
- lib/wraith/cli.rb
|