Class: TotalCompressor::TZip

Inherits:
BaseCompressor show all
Defined in:
lib/total_compressor.rb,
lib/total_compressor/compressors/t_zip.rb

Constant Summary

Constants inherited from BaseCompressor

BaseCompressor::FILE, BaseCompressor::HASH_TYPE, BaseCompressor::HOME, BaseCompressor::MSG, BaseCompressor::PROJECT, BaseCompressor::TEMP_FOLDER, BaseCompressor::TEST, BaseCompressor::TEST_FILE, BaseCompressor::TEST_FOLDER, BaseCompressor::TEST_FOLDER_UNCOMPRESSED, BaseCompressor::TEXT_FILE, BaseCompressor::TYPE

Instance Method Summary collapse

Methods inherited from BaseCompressor

#back_to_last_dir, #chdir, #get_file, #get_folder, #get_format, #prepare_test_files, #return_result, #save_current_dir, #skip_test?, #utilize_test_files

Instance Method Details

#compress(path) ⇒ Object



7
8
9
# File 'lib/total_compressor/compressors/t_zip.rb', line 7

def compress(path)
  super(path, get_format)
end

#decompress(path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/total_compressor/compressors/t_zip.rb', line 11

def decompress(path)
  save_current_dir
  result = {
    :success => false,
    :files => []
  }
  begin
    folder = get_folder(path)
    Zip::File.open(path) do |zip_file|
      dir = zip_file
      dir.entries.each do |file|
        zip_file.extract(file, "#{folder}/#{file}")
        result[:files] << "#{folder}/#{file}"
      end
    end
    result[:success] = true
  rescue
    result[:error] = 'exception'
  ensure
    back_to_last_dir
  end
  return_result(result)
end

#testObject



3
4
5
# File 'lib/total_compressor/compressors/t_zip.rb', line 3

def test
  super(get_format)
end