class CapybaraScreenshotDiff::SnapManager
Attributes
Public Class Methods
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 48 def self.cleanup! instance.cleanup! end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 72 def self.instance Capybara::Screenshot::Diff.manager.new(Capybara::Screenshot.screenshot_area_abs) end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 12 def initialize(root) @root = Pathname.new(root) end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 68 def self.root instance.root end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 64 def self.screenshots instance.screenshots end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 20 def self.snapshot(screenshot_full_name, screenshot_format = "png") instance.snapshot(screenshot_full_name, screenshot_format) end
Public Instance Methods
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 24 def abs_path_for(relative_path) @root / relative_path end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 28 def checkout_file(path, as_path) create_output_directory_for(as_path) unless as_path.exist? Capybara::Screenshot::Diff::Vcs.checkout_vcs(root, path, as_path) end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 44 def cleanup! FileUtils.rm_rf root, secure: true end
TODO: rename to delete!
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 52 def cleanup_attempts!(snapshot) FileUtils.rm_rf snapshot.find_attempts_paths, secure: true end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 39 def create_output_directory_for(path = nil) path ? path.dirname.mkpath : root.mkpath end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 56 def move(new_screenshot_path, screenshot_path) FileUtils.mv(new_screenshot_path, screenshot_path, force: true) end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 33 def provision_snap_with(snap, path, version: :actual) managed_path = snap.path_for(version) create_output_directory_for(managed_path) unless managed_path.exist? FileUtils.cp(path, managed_path) end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 60 def screenshots root.children.map { |f| f.basename.to_s } end
Source
# File lib/capybara_screenshot_diff/snap_manager.rb, line 16 def snapshot(screenshot_full_name, screenshot_format = "png") Snap.new(screenshot_full_name, screenshot_format, manager: self) end