class CapybaraScreenshotDiff::Snap
Attributes
Public Class Methods
Source
# File lib/capybara_screenshot_diff/snap.rb, line 7 def initialize(full_name, format, manager: SnapManager.instance) @full_name = full_name @format = format @path = manager.abs_path_for(Pathname.new(@full_name).sub_ext(".#{@format}")) @base_path = @path.sub_ext(".base.#{@format}") @manager = manager @attempts_count = 0 end
Public Instance Methods
Source
# File lib/capybara_screenshot_diff/snap.rb, line 22 def checkout_base_screenshot @manager.checkout_file(path, base_path) end
Source
# File lib/capybara_screenshot_diff/snap.rb, line 46 def cleanup_attempts @manager.cleanup_attempts!(self) @attempts_count = 0 end
Source
# File lib/capybara_screenshot_diff/snap.rb, line 42 def commit_last_attempt @manager.move(attempt_path, path) end
Source
# File lib/capybara_screenshot_diff/snap.rb, line 16 def delete! path.delete if path.exist? base_path.delete if base_path.exist? cleanup_attempts end
Source
# File lib/capybara_screenshot_diff/snap.rb, line 51 def find_attempts_paths Dir[@manager.abs_path_for "**/#{full_name}.attempt_*.#{format}"] end
Source
# File lib/capybara_screenshot_diff/snap.rb, line 35 def next_attempt_path! @prev_attempt_path = @attempt_path @attempt_path = path.sub_ext(sprintf(".attempt_%02i.#{format}", @attempts_count)) ensure @attempts_count += 1 end
Source
# File lib/capybara_screenshot_diff/snap.rb, line 26 def path_for(version = :actual) case version when :base base_path else path end end