Sha256: 83a0b4727c8be09262b751789c4e497981627eecb0376ff0ad0dad8fc787a1bc
Contents?: true
Size: 789 Bytes
Versions: 1
Compression:
Stored size: 789 Bytes
Contents
# frozen_string_literal: true require "zip" module Decidim # This class performs a simple task: Zipping a single file. Originally # meant for mailers to attach files, but other usage can be found. class FileZipper # Public: Initializes the zipper with a filename and the data to # be zipped. # # filename - The file name of the file *inside* the zip. # data - A string with the data to be zipped. def initialize(filename, data) @data = data @filename = filename end # Public: Zips the file. # # Returns a String with the zipped version of the file. def zip @zip ||= Zip::OutputStream.write_buffer do |zipfile| zipfile.put_next_entry(@filename) zipfile.write @data end.string end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-core-0.1.0 | lib/decidim/file_zipper.rb |