Module: Zipline

Defined in:
lib/zipline.rb,
lib/zipline/version.rb,
lib/zipline/zip_generator.rb

Overview

this class acts as a streaming body for rails initialize it with an array of the files you want to zip

Defined Under Namespace

Classes: ZipGenerator

Constant Summary collapse

VERSION =
"1.0.2"

Instance Method Summary collapse

Instance Method Details

#zipline(files, zipname = 'zipline.zip') ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/zipline.rb', line 15

def zipline(files, zipname = 'zipline.zip')
  zip_generator = ZipGenerator.new(files)
  headers['Content-Disposition'] = "attachment; filename=\"#{zipname.gsub '"', '\"'}\""
  headers['Content-Type'] = Mime::Type.lookup_by_extension('zip').to_s
  response.sending_file = true
  response.cache_control[:public] ||= false
  self.response_body = zip_generator
  self.response.headers['Last-Modified'] = Time.now.httpdate
end