43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/monkey-patches/webdriver-patches.rb', line 43
def self.zip(path)
tmp_dir = Dir.mktmpdir
begin
zip_path = File.join(tmp_dir, "webdriver-zip")
Zip::ZipFile.open(zip_path, Zip::ZipFile::CREATE) { |zip|
::Find.find(path) do |file|
next if File.directory?(file)
entry = file.sub("#{path}/", '')
entry = Zip::ZipEntry.new(zip_path, entry)
entry.follow_symlinks = true
zip.add entry, file
end
}
File.open(zip_path, "rb") { |io| Base64.strict_encode64 io.read }
ensure
FileUtils.rm_rf tmp_dir
end
end
|