Module: Selenium::WebDriver::ZipHelper

Defined in:
lib/selenium/webdriver/zip_helper.rb

Class Method Summary collapse

Class Method Details

.unzip(path) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/selenium/webdriver/zip_helper.rb', line 7

def self.unzip(path)
  destination = Dir.mktmpdir("unzip")
  FileReaper << destination

  Zip::ZipFile.open(path) do |zip|
    zip.each do |entry|
      to      = File.join(destination, entry.name)
      dirname = File.dirname(to)

      FileUtils.mkdir_p dirname unless File.exist? dirname
      zip.extract(entry, to)
    end
  end

  destination
end