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.



42
43
44
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 42

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.



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

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.



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

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.



28
29
30
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 28

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)


32
33
34
35
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 32

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.



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

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