Sha256: 16042eb4dba0a68de52a81829544517c08ea9066f1bc5703925e08b87d6baeb4

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

module Selenium
  module WebDriver

    #
    # @api private
    #

    module FileReaper

      class << self
        def reap=(bool)
          @reap = bool
        end

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

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

        def <<(file)
          tmp_files << file
        end

        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

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

      # we *do* want child process reaping, so not using Platform.exit_hook here.
      at_exit { reap! }

    end # FileReaper
  end # WebDriver
end # Selenium

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
selenium-webdriver-2.45.0 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.45.0.dev3 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.45.0.dev2 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.45.0.dev lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.44.0 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.44.0.dev lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.43.0 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.42.0 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.41.0 lib/selenium/webdriver/common/file_reaper.rb
browserstack-webdriver-2.40.1 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.40.0 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.40.0.rc2 lib/selenium/webdriver/common/file_reaper.rb
selenium-webdriver-2.40.0.rc1 lib/selenium/webdriver/common/file_reaper.rb