unpacker¶ ↑
DESCRIPTION¶ ↑
Small library for unpacking various archives, extracted from Beanstalk (beanstalkapp.com) (and rewritten, in fact).
FEATURES/PROBLEMS¶ ↑
None so far. Won’t run on Windows, haven’t tested.
SAMPLE USAGE¶ ↑
To test archives do:
Unpacker.valid? 'path/to/file.zip'
The method optionally accepts second argument, file name (if it is different than the file path). Handy if you test temp uploaded files.
To extract files do:
Unpacker.unpack('path/to/myfile.zip') do |directory_that_contains_extracted_files| end
To recognize archives do:
Unpacker.archive? 'path/to/archive.txt'
In case the archive is not supported (currently working with zip, bzip, gzip, tar and rar) you may get UnrecognizedArchiveError in both methods.
The gem takes care to remove any temporary extractings after the block is executed; (uses /tmp/ directory).
When working with .gz files (single archive), the extracted file is always called gz-contents.
REQUIREMENTS¶ ↑
Relies on system calls, so you should have
-
unzip
-
unrar
-
tar
-
gunzip
-
bunzip
In path.
INSTALL¶ ↑
sudo gem install unpacker
Note on Patches/Pull Requests¶ ↑
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright¶ ↑
Copyright © 2010 Petyo Ivanov. See LICENSE for details.