Module: Zipline
- Defined in:
- lib/zipline.rb,
lib/zipline/version.rb,
lib/zipline/zip_handler.rb
Overview
class MyController < ApplicationController
include Zipline
def index
users = User.all
files = users.map{ |user| [user.avatar, "#{user.username}.png", modification_time: 1.day.ago] }
zipline(files, 'avatars.zip')
end
end
Defined Under Namespace
Classes: ZipHandler
Constant Summary collapse
- VERSION =
"2.0.0"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(into_controller) ⇒ Object
15 16 17 18 |
# File 'lib/zipline.rb', line 15 def self.included(into_controller) into_controller.include(ZipKit::RailsStreaming) super end |
Instance Method Details
#zipline(files, zipname = 'zipline.zip', **kwargs_for_zip_kit_stream) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/zipline.rb', line 20 def zipline(files, zipname = 'zipline.zip', **kwargs_for_zip_kit_stream) zip_kit_stream(filename: zipname, **kwargs_for_zip_kit_stream) do |zip_kit_streamer| handler = Zipline::ZipHandler.new(zip_kit_streamer, logger) files.each do |file, name, = {}| handler.handle_file(file, name.to_s, ) end end end |