Project

zipping

0.0
No commit activity in last 3 years
No release in over 3 years
This gem is for compressing files as a zip and outputting to a stream (or a stream-like interface object). The output to a stream proceeds little by little, as files are compressed.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

>= 1.0.0
~> 0.2
 Project Readme

zipping

Gem Version

This gem is for compressing files as a zip and outputting to a stream (or a stream-like interface object). The output to a stream proceeds little by little, as files are compressed.

Getting Started

Add the following line to your Gemfile:

gem 'zipping'

Usage

simple:

require 'zipping'

Zipping.files_to_zip my_stream, '/path/to/file'

You can pass multiple files.

Zipping.files_to_zip my_stream2, ['/path/to/file', '/another/path']

If you pass a folder, zipping compresses all files in the folder.

Zipping.files_to_zip my_stream3, ['/path/to/folder', '/path/to/other/file']

For example, you have files below:

/text/foo.txt
/text/bar/baz.txt
/images/abc.png

and you run command:

file = File.open '/my.zip', 'wb'
Zipping.files_to_zip file, ['/text', '/images/abc.png']
file.close

Then, you get a zip file, and you find entries below in it.

text/
text/foo.txt
text/bar/
text/bar/baz.txt
abc.png

To get binary data of zip instead of saving as a file, prepare an 'ASCII-8bit'-encoded empty String object.

zip_data = ''.force_encoding('ASCII-8bit')
Zipping.files_to_zip zip_data, ['/text', '/images/abc.png']

Then, you get zip binary data in zip_data.


Copyright Nekojarashi Inc.