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 Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.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.



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

def reap(file)
  return unless reap?

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

  FileUtils.rm_rf tmp_files.delete(file)
end

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.



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

def <<(file)
  tmp_files << 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.



51
52
53
54
55
56
57
58
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 51

def reap!
  if reap?
    tmp_files.each { |file| FileUtils.rm_rf(file) }
    true
  else
    false
  end
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)


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

def reap?
  @reap = defined?(@reap) ? @reap : true
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.



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

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