wraith 3.1.7 → 3.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02fadcef6fa8e50ed88c7f72d09a784aba46fe5e
4
- data.tar.gz: 422b7af9bd80ca378cc1c38a22b2916513a7716f
3
+ metadata.gz: 7c261911df93063c9e970d32007208a9da2b4407
4
+ data.tar.gz: 7f73453a11e8e454df43ec650c2396f3839f528c
5
5
  SHA512:
6
- metadata.gz: e21ee89483e20176394a24e5db09a8c4166af6e02c07ac913a41dfd2033276ee4bc2e81a1d82fca262aa5e4f8f09ff3f546e10f08c24e3127942c0e5388de0a3
7
- data.tar.gz: 4ca116347fc048020ac2c1504355f2392627b3ed98d03c1b9daa5b0536af9f847eb737d2bfd79fa24e79bcfbeafe244e41fd95b1b5e5c6b84565b1406994c983
6
+ metadata.gz: 5158d454048a1c68a99ea76b12a3a34eb76795ba9afe6dd565579e52dc20d441d3c06a2d8fbbae827eba75d14f558ed800c5baeb302522f0afca598442bba3db
7
+ data.tar.gz: 1fba7ae45b26c443e2be6bf9c23aa1c0d181d72852b8df43f7bae10f4f89d24f6ca06ec562f9cc216b45dbf5127bb5204e8331501a4edaed92e71bf3cc5aa8ec
@@ -0,0 +1,21 @@
1
+ We're always happy to receive Pull Requests from the Wraith community.
2
+
3
+ Guidelines:
4
+
5
+ * Make sure your PR is documented (What does it do? Why is it needed?)
6
+ * New features and bug fixes should have tests written alongside them
7
+ * Appreciate that contributors maintain Wraith in their spare time, so a response may take several weeks
8
+
9
+ A PR is more likely to be merged if it fixes one of [Wraith's open issues](https://github.com/BBC-News/wraith/issues).
10
+
11
+ How to contribute:
12
+
13
+ * Fork a branch based off BBC-News/wraith:master and do all of your changes within it.
14
+ * Make commits of logical units and describe them properly.
15
+ * Check for unnecessary whitespace with git diff --check before committing.
16
+ * If possible, submit tests to your patch / new feature so it can be tested easily.
17
+ * Assure nothing is broken by running all the tests (`bundle exec rspec`).
18
+ * Please ensure that it complies with coding standards.
19
+ * When writing the title of your Pull Request, if you have to pause to add an 'and' anywhere in the title - it should be two pull requests.
20
+
21
+ **Please raise any issues with this project as a GitHub issue.**
@@ -0,0 +1,21 @@
1
+
2
+
3
+
4
+ ------
5
+ Reporting a problem? Please describe the issue above, and complete the following checklist so that we can help you more quickly.
6
+
7
+ #### Issue checklist:
8
+
9
+ - [ ] I have validated my config file against [YAML Validator](http://codebeautify.org/yaml-validator) to make sure it is valid YAML.
10
+
11
+ - [ ] I have run the command in verbose mode (by adding `verbose: true` to my config) and pasted the output below:
12
+
13
+ ```
14
+ paste results here
15
+ ```
16
+
17
+ - [ ] I have pasted the contents of my config file below:
18
+
19
+ ```
20
+ paste config here
21
+ ```
data/README.md CHANGED
@@ -56,17 +56,7 @@ Wraith also requires at least one of these headless browsers:
56
56
 
57
57
  ## Contributing
58
58
 
59
- If you want to add functionality to this project, pull requests are welcome.
60
-
61
- * Fork a branch based off BBC-News/wraith:master and do all of your changes within it.
62
- * Make commits of logical units and describe them properly.
63
- * Check for unnecessary whitespace with git diff --check before committing.
64
- * If possible, submit tests to your patch / new feature so it can be tested easily.
65
- * Assure nothing is broken by running all the tests (`bundle exec rspec`).
66
- * Please ensure that it complies with coding standards.
67
- * When writing the title of your Pull Request, if you have to pause to add an 'and' anywhere in the title - it should be two pull requests.
68
-
69
- **Please raise any issues with this project as a GitHub issue.**
59
+ Please read [how to contribute to Wraith](https://github.com/BBC-News/wraith/blob/master/.github/CONTRIBUTING.md).
70
60
 
71
61
  ## License
72
62
 
@@ -86,11 +86,8 @@ class Wraith::FolderManager
86
86
  dirs.each do |_folder_name, shot_info|
87
87
  shot_info.each do |_k, v|
88
88
  begin
89
- if !v.include?(:diff)
90
- return false
91
- elsif v[:data] > wraith.threshold
92
- return false
93
- end
89
+ return false unless v.include?(:diff)
90
+ return false if v[:data] > wraith.threshold
94
91
  rescue
95
92
  return true
96
93
  end
@@ -111,13 +111,32 @@ class Wraith::GalleryGenerator
111
111
 
112
112
  def sorting_dirs(dirs)
113
113
  if %w(diffs_only diffs_first).include?(wraith.mode)
114
- @sorted = dirs.sort_by { |_category, sizes| -1 * sizes.max_by { |_size, dict| dict[:data] }[1][:data] }
114
+ @sorted = sort_by_diffs dirs
115
115
  else
116
- @sorted = dirs.sort_by { |category, _sizes| category }
116
+ @sorted = sort_alphabetically dirs
117
117
  end
118
118
  Hash[@sorted]
119
119
  end
120
120
 
121
+ def sort_by_diffs(dirs)
122
+ dirs.sort_by do |_category, sizes|
123
+ size = select_size_with_biggest_diff sizes
124
+ -1 * size[1][:data]
125
+ end
126
+ end
127
+
128
+ def select_size_with_biggest_diff(sizes)
129
+ begin
130
+ sizes.max_by { |_size, dict| dict[:data] }
131
+ rescue
132
+ fail MissingImageError
133
+ end
134
+ end
135
+
136
+ def sort_alphabetically(dirs)
137
+ dirs.sort_by { |category, _sizes| category }
138
+ end
139
+
121
140
  def generate_gallery(with_path = "")
122
141
  dest = "#{@location}/gallery.html"
123
142
  directories = parse_directories(@location)
@@ -9,3 +9,11 @@ end
9
9
 
10
10
  class ConfigFileDoesNotExistError < CustomError
11
11
  end
12
+
13
+ class MissingImageError < CustomError
14
+ def initialize(msg = false)
15
+ default_msg = "Something went wrong! It looks like you're missing some images. Check your output directory and make sure that each path has four files for every screen size (data.txt, diff, base, latest). If in doubt, delete your output directory and run Wraith again."
16
+ msg = default_msg unless msg
17
+ super(msg)
18
+ end
19
+ end
@@ -68,12 +68,14 @@ class Wraith::Validate
68
68
 
69
69
  def list_debug_information
70
70
  wraith_version = Wraith::VERSION
71
+ command_run = ARGV.join ' '
71
72
  ruby_version = run_command_safely("ruby -v") || "Ruby not installed"
72
73
  phantomjs_version = run_command_safely("phantomjs --version") || "PhantomJS not installed"
73
74
  casperjs_version = run_command_safely("casperjs --version") || "CasperJS not installed"
74
75
  imagemagick_version = run_command_safely("convert -version") || "ImageMagick not installed"
75
76
 
76
77
  logger.debug "#################################################"
78
+ logger.debug " Command run: #{command_run}"
77
79
  logger.debug " Wraith version: #{wraith_version}"
78
80
  logger.debug " Ruby version: #{ruby_version}"
79
81
  logger.debug " ImageMagick: #{imagemagick_version}"
@@ -1,3 +1,3 @@
1
1
  module Wraith
2
- VERSION = "3.1.7"
2
+ VERSION = "3.1.8"
3
3
  end
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: 3.1.7
4
+ version: 3.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Blooman
@@ -178,6 +178,8 @@ extensions: []
178
178
  extra_rdoc_files: []
179
179
  files:
180
180
  - .gemset
181
+ - .github/CONTRIBUTING.md
182
+ - .github/ISSUE_TEMPLATE.md
181
183
  - .gitignore
182
184
  - .rubocop.yml
183
185
  - .ruby-version