capybara-screenshot-diff 0.11.0 → 0.11.1

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: adbbae0be849e373116e41ba3d82e65008a6e281
4
- data.tar.gz: efa2d3acc0df00651c6134ef0817a3d21be4282d
3
+ metadata.gz: 0de52a07b767a8c00bc3fbb4932c5dc50c3473ad
4
+ data.tar.gz: 379c7f08576254f37a3a19fd91b51cb3bac25ee5
5
5
  SHA512:
6
- metadata.gz: 42af6279377d9119d99eac1eb7516e51ac2caee5122dc8f7ced3db225460ba91b07aea3a489d823fee98acc9b3e06fc503510aa25711a98272a18077e9c68dbc
7
- data.tar.gz: 0d2729428c8a46a39ed949fb1a9bdbeefc4165cc7dd51ce66cabefa68185cd74d2ee7cde9870d46dea7c3036670be55a6229b29dbc0bf6c66d7a9c611ac5992f
6
+ metadata.gz: b9ee0511feed3f3bbcde5f6a26ac818ff162ee46867edef1179ea3aa5b63a654a189f3835f545511d6129b82d238a671ce7d369bd4dede4f47741e5d894a924b
7
+ data.tar.gz: 8d8aead2eae4a347867728293518f8945872f8fbb0b6e56457232c2b83af648918c7ca23cb866222bf4993a4f4bd5e652468d363e3204eda0773501805150ad8
@@ -37,24 +37,23 @@ module Capybara
37
37
  def quick_equal?
38
38
  return nil unless old_file_exists?
39
39
  return true if new_file_size == old_file_size
40
- old_file, new_file = load_image_files(@old_file_name, @new_file_name)
41
- return true if old_file == new_file
42
- images = load_images(old_file, new_file)
40
+ old_bytes, new_bytes = load_image_files(@old_file_name, @new_file_name)
41
+ return true if old_bytes == new_bytes
42
+ images = load_images(old_bytes, new_bytes)
43
+ old_bytes = new_bytes = nil
43
44
  crop_images(images, @dimensions) if @dimensions
44
45
 
45
- old_img = images.first
46
- new_img = images.last
47
-
48
- return false if sizes_changed?(old_img, new_img)
46
+ return false if sizes_changed?(*images)
47
+ return true if images.first.pixels == images.last.pixels
49
48
 
50
- return true if old_img.pixels == new_img.pixels
49
+ return false unless @color_distance_limit || @shift_distance_limit
51
50
 
52
- @left, @top, @right, @bottom = find_top(old_img, new_img)
51
+ @left, @top, @right, @bottom = find_top(*images)
53
52
 
54
53
  return true if @top.nil?
55
54
 
56
55
  if @area_size_limit
57
- @left, @top, @right, @bottom = find_diff_rectangle(old_img, new_img)
56
+ @left, @top, @right, @bottom = find_diff_rectangle(*images)
58
57
  return true if size <= @area_size_limit
59
58
  end
60
59
 
@@ -261,7 +260,7 @@ module Capybara
261
260
  if !@max_color_distance || color_distance > @max_color_distance
262
261
  @max_color_distance = color_distance
263
262
  end
264
- if !@max_shift_distance || shift_distance > @max_shift_distance
263
+ if shift_distance.to_i > @max_shift_distance.to_i
265
264
  @max_shift_distance = shift_distance
266
265
  end
267
266
  (color_distance == 0 || (@color_distance_limit && @color_distance_limit > 0 &&
@@ -295,12 +294,15 @@ module Capybara
295
294
  org_color = old_img[x, y]
296
295
  shift_distance = 0
297
296
  loop do
297
+ bounds_breached = 0
298
298
  if (y - shift_distance) >= 0 # top
299
299
  ([0, x - shift_distance].max..[x + shift_distance, new_img.width - 1].min).each do |dx|
300
300
  if color_matches(new_img, org_color, dx, y - shift_distance, color_distance_limit)
301
301
  return shift_distance
302
302
  end
303
303
  end
304
+ else
305
+ bounds_breached += 1
304
306
  end
305
307
  if shift_distance > 0
306
308
  if (x - shift_distance) >= 0 # left
@@ -310,6 +312,8 @@ module Capybara
310
312
  return shift_distance
311
313
  end
312
314
  end
315
+ else
316
+ bounds_breached += 1
313
317
  end
314
318
  if (y + shift_distance) < new_img.height # bottom
315
319
  ([0, x - shift_distance].max..[x + shift_distance, new_img.width - 1].min).each do |dx|
@@ -317,6 +321,8 @@ module Capybara
317
321
  return shift_distance
318
322
  end
319
323
  end
324
+ else
325
+ bounds_breached += 1
320
326
  end
321
327
  if (x + shift_distance) < new_img.width # right
322
328
  ([0, y - shift_distance + 1].max..[y + shift_distance, new_img.height - 2].min)
@@ -325,12 +331,15 @@ module Capybara
325
331
  return shift_distance
326
332
  end
327
333
  end
334
+ else
335
+ bounds_breached += 1
328
336
  end
329
337
  end
338
+ break if bounds_breached == 4
330
339
  shift_distance += 1
331
340
  # puts "Bumped shift_distance to #{shift_distance}"
332
341
  end
333
- shift_distance
342
+ nil
334
343
  end
335
344
 
336
345
  def color_matches(new_img, org_color, dx, dy, color_distance_limit)
@@ -3,7 +3,7 @@
3
3
  module Capybara
4
4
  module Screenshot
5
5
  module Diff
6
- VERSION = '0.11.0'.freeze
6
+ VERSION = '0.11.1'.freeze
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-screenshot-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uwe Kubosch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-06 00:00:00.000000000 Z
11
+ date: 2018-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -153,7 +153,6 @@ files:
153
153
  - ".rubocop.yml"
154
154
  - ".rubocop_todo.yml"
155
155
  - ".travis.yml"
156
- - CODE_OF_CONDUCT.md
157
156
  - CONTRIBUTING.md
158
157
  - Gemfile
159
158
  - LICENSE.txt
data/CODE_OF_CONDUCT.md DELETED
@@ -1,46 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- ## Our Standards
8
-
9
- Examples of behavior that contributes to creating a positive environment include:
10
-
11
- * Using welcoming and inclusive language
12
- * Being respectful of differing viewpoints and experiences
13
- * Gracefully accepting constructive criticism
14
- * Focusing on what is best for the community
15
- * Showing empathy towards other community members
16
-
17
- Examples of unacceptable behavior by participants include:
18
-
19
- * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
- * Trolling, insulting/derogatory comments, and personal or political attacks
21
- * Public or private harassment
22
- * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
- * Other conduct which could reasonably be considered inappropriate in a professional setting
24
-
25
- ## Our Responsibilities
26
-
27
- Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
-
29
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
-
31
- ## Scope
32
-
33
- This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
-
35
- ## Enforcement
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at uwe@kubosch.no. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
-
39
- Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
-
41
- ## Attribution
42
-
43
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
-
45
- [homepage]: http://contributor-covenant.org
46
- [version]: http://contributor-covenant.org/version/1/4/