Module: Selenium::WebDriver::FileReaper

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

Class Method Summary collapse

Class Method Details

.<<(file) ⇒ Object



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

def <<(file)
  tmp_files << file
end

.reap(file) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 23

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



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

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

.reap=(bool) ⇒ Object



6
7
8
# File 'lib/selenium/webdriver/common/file_reaper.rb', line 6

def reap=(bool)
  @reap = bool
end

.reap?Boolean

Returns:

  • (Boolean)


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

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

.tmp_filesObject



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

def tmp_files
  @tmp_files ||= []
end