Module: Selenium::WebDriver::Zipper Private
- Defined in:
- lib/selenium/webdriver/common/zipper.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.
Constant Summary collapse
- EXTENSIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[.zip .xpi].freeze
Class Method Summary collapse
- .unzip(path) ⇒ Object private
- .zip(path) ⇒ Object private
- .zip_file(path) ⇒ Object private
Class Method Details
.unzip(path) ⇒ 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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File '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 |
.zip(path) ⇒ 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.
52 53 54 55 56 57 58 59 60 61 |
# File '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) ⇒ 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.
63 64 65 66 67 68 69 70 |
# File '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 |