eyes_core 3.11.2 → 3.11.3

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: 0c31e4bb154d96ec0e95c99d06aee001aa38e9f8
4
- data.tar.gz: 119a3a2555f1b731939eb4b7e4dfa015288c222e
3
+ metadata.gz: 6a7f6907cd0187127b80c8bd66d16d2db2a9ccd3
4
+ data.tar.gz: 8459dc647e493bcbd98842d914542d7f08096bb9
5
5
  SHA512:
6
- metadata.gz: 49b505655c65f25b6601cb8dae90819e421d11392be91b5d8de76f621a2bca878c589c59d4cbbcb925079828cbc67d7bc0fd4fb5e0ed98fa8d0d642fd181a868
7
- data.tar.gz: 9f8a23713075f767289f5ed04b07aec9abfc9cf12aca5c854f2a0d10a5c4215897e38f7f704205b411188d8cc6086aada1a69d441dc02616a8d967db36bad1a4
6
+ metadata.gz: eb6a6c9d02180a40f0d40dfea4e74d19853d3dcc72e88ed11a8fa1d791e9ef6cbb1770491f4489cdc161bb3558626d5274373235a6bbd333da164ff3ba020019
7
+ data.tar.gz: 971577f4b1a7929c6e85194fb454cdaeeae7921005ac1a03470b52db676f0b3d61377d1617ae75aa3f30ef0a118211f8200870a71eb139c36ff4cef2a5b84fc0
@@ -0,0 +1,83 @@
1
+ require 'fileutils'
2
+
3
+ module Applitools
4
+ class DebugScreenshotProvider
5
+ attr_reader :debug_flag_getter, :debug_tag_getter
6
+ attr_accessor :screenshot_dir
7
+ def initialize(options = { screenshot_dir: 'debug_screenshots' })
8
+ @screenshot_dir = options[:screenshot_dir]
9
+ end
10
+
11
+ def save(image, suffix = '')
12
+ return unless debug
13
+ case image
14
+ when ::ChunkyPNG::Image, Applitools::Screenshot
15
+ image.save(file_name_to_save(suffix))
16
+ when Applitools::EyesScreenshot
17
+ image.image.save(file_name_to_save(suffix))
18
+ when String
19
+ ::ChunkyPNG::Image.from_string(image).save(file_name_to_save(suffix))
20
+ else
21
+ return
22
+ end
23
+ end
24
+
25
+ def save_subscreenshot(image, region)
26
+ suffix = region.to_s + '__cropped'
27
+ save(image, suffix)
28
+ end
29
+
30
+ def tag_access(&b)
31
+ @debug_tag_getter = b
32
+ self
33
+ end
34
+
35
+ def tag_for_debug
36
+ return debug_tag_getter.call || '' if debug_tag_getter.is_a? Proc
37
+ :''
38
+ end
39
+
40
+ def debug_flag_access(&b)
41
+ @debug_flag_getter = b
42
+ self
43
+ end
44
+
45
+ def debug
46
+ return debug_flag_getter.call if debug_flag_getter.is_a? Proc
47
+ false
48
+ end
49
+
50
+ private
51
+
52
+ def file_name_to_save(suffix)
53
+ File.join(
54
+ screenshots_path,
55
+ "#{prefix}__#{screenshot_names.next}#{suffix.empty? ? '' : '__' + suffix}.png"
56
+ ).gsub(/\s+/, '_')
57
+ end
58
+
59
+ def screenshot_names
60
+ @screenshot_name_enumerator ||= Enumerator.new do |y|
61
+ counter = 1
62
+ loop do
63
+ y << format(
64
+ '%s__%04d__%s',
65
+ Time.now.strftime('%Y_%m_%d_%H_%M'),
66
+ counter, tag_for_debug.empty? ? '' : tag_for_debug.gsub(/\s+/, '_')
67
+ )
68
+ counter += 1
69
+ end
70
+ end
71
+ end
72
+
73
+ def prefix
74
+ :screenshot
75
+ end
76
+
77
+ def screenshots_path
78
+ dir = File.join(Dir.pwd, screenshot_dir)
79
+ FileUtils.mkdir_p(dir)
80
+ dir
81
+ end
82
+ end
83
+ end
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '3.11.2'.freeze
2
+ VERSION = '3.11.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyes_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.2
4
+ version: 3.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Applitools Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-06 00:00:00.000000000 Z
11
+ date: 2017-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oily_png
@@ -213,6 +213,7 @@ files:
213
213
  - lib/applitools/core/app_output_with_screenshot.rb
214
214
  - lib/applitools/core/argument_guard.rb
215
215
  - lib/applitools/core/batch_info.rb
216
+ - lib/applitools/core/debug_screenshot_provider.rb
216
217
  - lib/applitools/core/eyes_base.rb
217
218
  - lib/applitools/core/eyes_screenshot.rb
218
219
  - lib/applitools/core/fixed_cut_provider.rb