Module: Selenium::WebDriver::Zipper Private
Do not use. This module is for internal use only.
Relationships & Source Files | |
Defined in: | rb/lib/selenium/webdriver/common/zipper.rb |
Constant Summary
-
EXTENSIONS =
# File 'rb/lib/selenium/webdriver/common/zipper.rb', line 32%w[.zip .xpi].freeze
Class Method Summary
- .unzip(path) Internal use only
- .zip(path) Internal use only
- .zip_file(path) Internal use only
- .add_zip_entry(zip, file, entry_name) private Internal use only
- .with_tmp_zip(&blk) private Internal use only
Class Method Details
.add_zip_entry(zip, file, entry_name) (private)
[ GitHub ].unzip(path)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/zipper.rb', line 35
def unzip(path) destination = Dir.mktmpdir('webdriver-unzip') FileReaper << destination Zip::File.open(path) do |zip| zip.each do |entry| to = File.join(destination, entry.name) dirname = File.dirname(to) FileUtils.mkdir_p dirname zip.extract(entry, to) end end destination end
.with_tmp_zip(&blk) (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/zipper.rb', line 74
def with_tmp_zip(&blk) # Don't use Tempfile since it lacks rb_file_s_rename permission on Windows. Dir.mktmpdir do |tmp_dir| zip_path = File.join(tmp_dir, 'webdriver-zip') Zip::File.open(zip_path, Zip::File::CREATE, &blk) end end
.zip(path)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/zipper.rb', line 52
def zip(path) with_tmp_zip do |zip| ::Find.find(path) do |file| add_zip_entry zip, file, file.sub("#{path}/", '') unless File.directory?(file) end zip.commit File.open(zip.name, 'rb') { |io| Base64.strict_encode64 io.read } end end
.zip_file(path)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/zipper.rb', line 63
def zip_file(path) with_tmp_zip do |zip| add_zip_entry zip, path, File.basename(path) zip.commit File.open(zip.name, 'rb') { |io| Base64.strict_encode64 io.read } end end