Module: Selenium::WebDriver::FileReaper Private

Defined in:
lib/selenium/webdriver/common/file_reaper.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.<<(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 44

def <<(file)
  tmp_files << file
end

.reap(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
51
52
53
54
55
56
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 48

def reap(file)
  return unless reap?

  unless tmp_files.include?(file)
    raise Error::WebDriverError, "file not added for reaping: #{file.inspect}"
  end

  FileUtils.rm_rf tmp_files.delete(file)
end

.reap!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



58
59
60
61
62
63
64
65
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 58

def reap!
  if reap?
    tmp_files.each { |file| FileUtils.rm_rf(file) }
    true
  else
    false
  end
end

.reap=(bool) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 30

def reap=(bool)
  @reap = bool
end

.reap?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 34

def reap?
  @reap = true unless defined?(@reap)
  !!@reap
end

.tmp_filesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
42
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 39

def tmp_files
  @tmp_files ||= Hash.new { |hash, pid| hash[pid] = [] }
  @tmp_files[Process.pid]
end