Class: Applitools::DebugScreenshotProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/applitools/core/debug_screenshot_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = { screenshot_dir: 'debug_screenshots' }) ⇒ DebugScreenshotProvider

Returns a new instance of DebugScreenshotProvider.



7
8
9
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 7

def initialize(options = { screenshot_dir: 'debug_screenshots' })
  @screenshot_dir = options[:screenshot_dir]
end

Instance Attribute Details

#debug_flag_getterObject (readonly)

Returns the value of attribute debug_flag_getter.



5
6
7
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 5

def debug_flag_getter
  @debug_flag_getter
end

#debug_tag_getterObject (readonly)

Returns the value of attribute debug_tag_getter.



5
6
7
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 5

def debug_tag_getter
  @debug_tag_getter
end

#screenshot_dirObject

Returns the value of attribute screenshot_dir.



6
7
8
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 6

def screenshot_dir
  @screenshot_dir
end

Instance Method Details

#debugObject



45
46
47
48
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 45

def debug
  return debug_flag_getter.call if debug_flag_getter.is_a? Proc
  false
end

#debug_flag_access(&b) ⇒ Object



40
41
42
43
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 40

def debug_flag_access(&b)
  @debug_flag_getter = b
  self
end

#save(image, suffix = '') ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 11

def save(image, suffix = '')
  return unless debug
  case image
  when ::ChunkyPNG::Image, Applitools::Screenshot
    image.save(file_name_to_save(suffix))
  when Applitools::EyesScreenshot
    image.image.save(file_name_to_save(suffix))
  when String
    ::ChunkyPNG::Image.from_string(image).save(file_name_to_save(suffix))
  else
    return
  end
end

#save_subscreenshot(image, region) ⇒ Object



25
26
27
28
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 25

def save_subscreenshot(image, region)
  suffix = region.to_s + '__cropped'
  save(image, suffix)
end

#tag_access(&b) ⇒ Object



30
31
32
33
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 30

def tag_access(&b)
  @debug_tag_getter = b
  self
end

#tag_for_debugObject



35
36
37
38
# File 'lib/applitools/core/debug_screenshot_provider.rb', line 35

def tag_for_debug
  return debug_tag_getter.call || '' if debug_tag_getter.is_a? Proc
  :''
end