wraith 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 632e6875afc7f887a075632ef30887a31410ba79
4
+ data.tar.gz: 1936f1eec71795aac70ae0e14abbd1471b93f3ae
5
+ SHA512:
6
+ metadata.gz: 3a475a73580b5589cec9232c7588f7ccce6692897c63476f9773d2b5bbca65b52a8fe66aa79877e85a2f56565114a5542f02f097ecbb5fff3b2f213e305d93be
7
+ data.tar.gz: 1cfa109de3917ed0e1d78e9ce29b152de30ff94659472f26262d746adf9f47cd11e2f094152986e16b60add2958a0545fba7cd4819fd7c83a7829e171a88a683
data/.gemset ADDED
@@ -0,0 +1 @@
1
+ wraith
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .bundle/*
2
+ shots/
3
+ data.txt
4
+ .DS_Store
5
+ *.swp
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "2.0.0"
5
+
6
+ script: "./bin/wraith"
7
+
8
+ notifications:
9
+ email:
10
+ recipients:
11
+ - david.blooman@bbc.co.uk
12
+ on_failure: change
13
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ..gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
data/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # Wraith
2
+
3
+ [![Build Status](https://secure.travis-ci.org/BBC-News/wraith.png?branch=master)](http://travis-ci.org/BBC-News/wraith)
4
+ [![Code Climate](https://codeclimate.com/github/BBC-News/wraith.png)](https://codeclimate.com/github/BBC-News/wraith)
5
+
6
+ * Website: http://responsivenews.co.uk
7
+ * Source: http://github.com/bbc-news/wraith
8
+
9
+ Wraith is a screenshot comparison tool, created by developers at BBC News.
10
+
11
+
12
+ ## What is it?
13
+
14
+ Wraith uses either [PhantomJS](http://phantomjs.org) or
15
+ [SlimerJS](http://slimerjs.org) to create screen-shots of different environments
16
+ and then creates a diff of the two images, the affected areas are highlighted in
17
+ blue
18
+
19
+ ![Photo of BBC News with a
20
+ diff](http://bbc-news.github.io/wraith/images/320_diff.png)
21
+
22
+
23
+ ## Requirements
24
+
25
+ You'll need either PhantomJS or SlimerJS, ImageMagick & Ruby 1.9.3 or greater.
26
+ It's up to you to decide which browser engine you want to run it against.
27
+
28
+ ### OSX
29
+ On Mac OS X, the best way to install dependencies is if you have [homebrew](http://brew.sh). It is the quickest way to install PhantomJS & ImageMagick.
30
+
31
+ brew install imagemagick
32
+ brew install phantomjs or brew install slimerjs
33
+
34
+ ### Windows
35
+ On Windows it's important to install ImageMagick from the binary found [here](http://www.imagemagick.org/script/binary-releases.php#windows).
36
+ This will ensure that ImageMagick is listed first in your PATH.
37
+
38
+ To check your path after installing, open a command line window and type:
39
+
40
+ path
41
+
42
+ This will return a list of executables in you PATH separated by semi-colons ;
43
+
44
+ C:\Program Files\ImageMagick-6.8.7-Q16;C:\Windows\system32;C:\Windows...
45
+
46
+ If ImageMagick is in your path but not listed first you can edit your path by following the instructions [here](http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx)
47
+
48
+ If ImageMagick is not in your PATH at all but you have it installed you will need to add it in. Follow the instructions from the link above and add in the path to where you have ImageMagick installed. For example C:\Program Files\ImageMagick-6.8.7-Q16;
49
+ Make sure the version number and location are correct for your system.
50
+
51
+ ### Ubuntu
52
+ On Ubuntu 12.04, you will need to apt-get the following packages:
53
+
54
+ * libicu-dev
55
+ * imagemagick
56
+ * rake
57
+
58
+ And then download the PhantomJS binary package from
59
+ [http://phantomjs.org/](http://phantomjs.org/).
60
+
61
+ ## Installation
62
+
63
+ Open terminal and run
64
+
65
+ git clone https://github.com/BBC-News/wraith
66
+
67
+ You can then run the following inside the Wraith directory:
68
+
69
+ bundle install
70
+
71
+ If you don't have bundler installed, install it :
72
+
73
+ gem install bundler
74
+
75
+
76
+ Alternatively you can download the install script via curl, this will not create a git repo though.
77
+
78
+ curl -fsSL https://raw.github.com/bbc-news/wraith/go/install | bash
79
+ cd wraith
80
+ bundle install
81
+
82
+ ## Config
83
+
84
+ All config options will be placed in config.yaml. You can specify the snap file name, this could be used in a situation where you have a large amount of config files. You can set the headless browser, domains of the 2 sites you are comparing, URL paths, screen widths & HTTP headers. If you don't want to set paths, you can use the spidering option to check your entire website Remove/comment out the `path:` entries in `config.yaml`.
85
+
86
+ ```yaml
87
+
88
+ # Headless browser option
89
+ browser:
90
+ webkit: "phantomjs"
91
+ # gecko: "slimerjs"
92
+
93
+ # If you want to have multiple snapping files, set the file name here
94
+ snap_file: "snap.js"
95
+
96
+ # Type the name of the directory that shots will be stored in
97
+ directory:
98
+ - 'shots'
99
+
100
+ # Add only 2 domains, key will act as a label
101
+ domains:
102
+ english: "http://www.live.bbc.co.uk/news"
103
+ russian: "http://www.live.bbc.co.uk/russian"
104
+
105
+ #Type screen widths below, here are a couple of examples
106
+ screen_widths:
107
+ - 320
108
+ - 600
109
+ - 768
110
+ - 1024
111
+ - 1280
112
+
113
+ #Type page URL paths below, here are a couple of examples
114
+ paths:
115
+ home: /
116
+ uk_index: /uk
117
+
118
+ # If you don't want to name the paths explicitly you can use a yaml
119
+ # collection as follows, and names will be derived by replacing / with _
120
+ #
121
+ # paths:
122
+ # - /imghp
123
+ # - /maps
124
+
125
+ #Amount of fuzz ImageMagick will use
126
+ fuzz: '20%'
127
+
128
+ #Set the number of days to keep the site spider file
129
+ spider_days:
130
+ - 10
131
+
132
+ ```
133
+
134
+ You can also specify PhantomJS command line options in config.yaml.
135
+
136
+ For example to tell PhantomJS to ignore SSL errors:
137
+
138
+ ```yaml
139
+ phantomjs_options: "--ignore-ssl-errors=true"
140
+ ```
141
+
142
+ ## Using Wraith
143
+
144
+ If you are new to ruby, rake and PhantomJS, [here is a great screencast](http://www.youtube.com/watch?v=gE_19L0l2q0) about how to use Wraith by [Kevin Lamping](https://twitter.com/klamping)
145
+
146
+ There are two ways of using Wraith, the fastest is to simply type rake.
147
+
148
+ ```sh
149
+ rake
150
+ ```
151
+
152
+ You may want to deal with multiple config files so you can compare different pages, different sites or different viewports. In order to handle this, you can pass in a different config file by typing the following into terminal. The default is config.yaml, so even if you don't pass a file in, it will still run. If you have deleted config.yaml, make sure you are inside the `configs` directory before running the command.
153
+
154
+ ```sh
155
+ rake config[config_name]
156
+ ```
157
+
158
+ On Windows before running the rake command you will need to make a small edit to the wraith.rb file.
159
+ Locate lines 60 and 70 and switch the commenting as described.
160
+
161
+
162
+ ## Output
163
+
164
+ After each screenshot is captured, the compare task will run, this will output a diff.png and a data.txt. The data.txt for each file will show the number of pixels that have changed. There is a main data.txt which is in the root of the output folder that will combine all of these values to easier view all the pixel changes.
165
+
166
+ ## Gallery
167
+
168
+ 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.
169
+
170
+ ## Grabber
171
+
172
+ If you just want to see a single domains images and not compare them, perhaps for archiving, remove a domain and run the new rake task. For default config, use grab, or specify a config using grabber.
173
+
174
+ `rake grab` and `rake grabber[config]`
175
+
176
+ ## Contributing
177
+
178
+ If you want to add functionality to this project, pull requests are welcome.
179
+
180
+ * Create a branch based off master and do all of your changes with in it.
181
+ * If you have to pause to add a 'and' anywhere in the title, it should be two pull requests.
182
+ * Make commits of logical units and describe them properly
183
+ * Check for unnecessary whitespace with git diff --check before committing.
184
+ * If possible, submit tests to your patch / new feature so it can be tested easily.
185
+ * Assure nothing is broken by running all the test
186
+ * Please ensure that it complies with coding standards.
187
+
188
+ **Please raise any issues with this project as a GitHub issue.**
189
+
190
+ ## Changelog - updated 24/01/14
191
+ New features include some refactoring and the start of additional cli work. We have removed the webdriver features for the time being, this will return in a more capable and fully feature state.
192
+
193
+ ## License
194
+
195
+ Wraith is available to everyone under the terms of the Apache 2.0 open source license.
196
+ Take a look at the LICENSE file in the code.
197
+
198
+ ## Credits
199
+
200
+ * [Dave Blooman](http://twitter.com/dblooman)
201
+ * [John Cleveley](http://twitter.com/jcleveley)
202
+ * [Simon Thulbourn](http://twitter.com/sthulbourn)
203
+
data/Rakefile ADDED
@@ -0,0 +1,68 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'wraith/save_images'
5
+ require 'wraith/crop'
6
+ require 'wraith/spider'
7
+ require 'wraith/folder'
8
+ require 'wraith/thumbnails'
9
+ require 'wraith/compare_images'
10
+ require 'wraith/images'
11
+
12
+ @config = ('config')
13
+
14
+ task :grabber, [:yaml] do |t, custom|
15
+ custom.with_defaults(:yaml => "config")
16
+ @config = "#{custom[:yaml]}"
17
+ Rake::Task["grab"].invoke
18
+ end
19
+
20
+ task :default => [:reset_shots_folder, :check_for_paths, :setup_folders, :save_images, :generate_thumbnails, :generate_gallery] do
21
+ puts 'Done!';
22
+ end
23
+
24
+ task :reset_shots_folder do
25
+ reset = Wraith::FolderManager.new(@config)
26
+ reset.clear_shots_folder
27
+ end
28
+
29
+ task :setup_folders do
30
+ create = Wraith::FolderManager.new(@config)
31
+ create.create_folders
32
+ end
33
+
34
+ task :compare_images do
35
+ compare = Wraith::CompareImages.new(@config)
36
+ compare.compare_images
37
+ end
38
+
39
+ task :check_for_paths do
40
+ spider = Wraith::Spidering.new(@config)
41
+ spider.check_for_paths
42
+ end
43
+
44
+ task :save_images do
45
+ @save_images = Wraith::SaveImages.new(@config)
46
+ @save_images.save_images
47
+ end
48
+
49
+ task :crop_images do
50
+ crop = Wraith::CropImages.new(@save_images.directory)
51
+ crop.crop_images
52
+ end
53
+
54
+ task :check_images do
55
+ image = Wraith::Images.new(@save_images.directory)
56
+ image.files
57
+ end
58
+
59
+ task :generate_thumbnails do
60
+ thumbs = Wraith::Thumbnails.new(@config)
61
+ thumbs.generate_thumbnails
62
+ end
63
+
64
+ task :generate_gallery do
65
+ sh "ruby lib/wraith/gallery.rb #{@save_images.directory}"
66
+ end
67
+
68
+