Class: Compaa::GeneratedImage

Inherits:
Struct
  • Object
show all
Defined in:
lib/compaa/generated_image.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#file_manager=(value) ⇒ Object

Sets the attribute file_manager

Parameters:

  • value

    the value to set the attribute file_manager to.



5
6
7
# File 'lib/compaa/generated_image.rb', line 5

def file_manager=(value)
  @file_manager = value
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/compaa/generated_image.rb', line 4

def path
  @path
end

Class Method Details

.allObject



7
8
9
10
11
# File 'lib/compaa/generated_image.rb', line 7

def self.all
  Dir.glob(File.join %w[artifacts screenshots_generated_this_run ** *.png]).map { |path|
    new path
  }
end

Instance Method Details

#create_reference_imageObject



13
14
15
# File 'lib/compaa/generated_image.rb', line 13

def create_reference_image
  copy_and_create_directory reference_path
end

#deleteObject



31
32
33
# File 'lib/compaa/generated_image.rb', line 31

def delete
  file_manager.rm path
end

#delete_difference_imageObject



25
26
27
28
29
# File 'lib/compaa/generated_image.rb', line 25

def delete_difference_image
  difference_image_path = path.gsub 'screenshots_generated_this_run', 'differences_in_screenshots_this_run'
  difference_image_path << '_difference.gif'
  file_manager.rm difference_image_path, force: true
end

#has_reference_image?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/compaa/generated_image.rb', line 17

def has_reference_image?
  File.exists? reference_path
end

#reference_pathObject



21
22
23
# File 'lib/compaa/generated_image.rb', line 21

def reference_path
  path.gsub 'screenshots_generated_this_run', 'reference_screenshots'
end