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.



25
26
27
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 25

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.



29
30
31
32
33
34
35
36
37
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 29

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.



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

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.



11
12
13
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 11

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)


15
16
17
18
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 15

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.



20
21
22
23
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 20

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