Module: Compressor
- Included in:
- AbstractIndexBuilder, Indexer
- Defined in:
- lib/raven/index_gem_repository.rb
Overview
Mixin that provides a compress method for compressing files on disk.
Instance Method Summary collapse
-
#compress(filename, ext = "rz") ⇒ Object
Compress the given file.
-
#unzip(string) ⇒ Object
Return an uncompressed version of a compressed string.
-
#zip(string) ⇒ Object
Return a compressed version of the given string.
Instance Method Details
#compress(filename, ext = "rz") ⇒ Object
Compress the given file.
33 34 35 36 37 |
# File 'lib/raven/index_gem_repository.rb', line 33 def compress(filename, ext="rz") File.open(filename + ".#{ext}", "w") do |file| file.write(zip(File.read(filename))) end end |
#unzip(string) ⇒ Object
Return an uncompressed version of a compressed string.
45 46 47 |
# File 'lib/raven/index_gem_repository.rb', line 45 def unzip(string) Zlib::Inflate.inflate(string) end |
#zip(string) ⇒ Object
Return a compressed version of the given string.
40 41 42 |
# File 'lib/raven/index_gem_repository.rb', line 40 def zip(string) Zlib::Deflate.deflate(string) end |