class Capybara::Flow::GifRecorder

Attributes

gif_animator[R]
output_file[R]

Public Class Methods

new(output_name) click to toggle source
# File lib/capybara/flow/gif_recorder.rb, line 6
def initialize(output_name)
  @frame_dir = output_name
  @output_file = "#{output_name}.gif"
  make_path_unless_exists(output_file)
  make_path_unless_exists(@frame_dir)
  @gif_animator = GifAnimator.new(output_file, delay_in_ms: Capybara::Flow.configuration.delay_in_ms, iterations: Capybara::Flow.configuration.iterations)
end

Public Instance Methods

add(page) click to toggle source
# File lib/capybara/flow/gif_recorder.rb, line 14
def add(page)
  file_name = File.join(@frame_dir, "#{current_frame}.png")
  page.save_screenshot(file_name, width: 320, height: 480)
  gif_animator.add(file_name)
end
generate!() click to toggle source
# File lib/capybara/flow/gif_recorder.rb, line 20
def generate!
  gif_animator.generate!
end

Private Instance Methods

current_frame() click to toggle source
# File lib/capybara/flow/gif_recorder.rb, line 27
def current_frame
  gif_animator.frames.length
end
make_path_unless_exists(file) click to toggle source
# File lib/capybara/flow/gif_recorder.rb, line 31
def make_path_unless_exists(file)
  FileUtils.mkdir_p(File.dirname(file))
end