module TotalCompressor

Constants

VERSION

Public Class Methods

cmdline() click to toggle source
# File lib/total_compressor.rb, line 13
def cmdline
  case ARGV.size
    when 1
      decompress(ARGV[0])
    when 2
      compress(ARGV[1], BaseCompressor::HASH_TYPE[ARGV[0]]) if BaseCompressor::HASH_TYPE[ARGV[0]]
    else
      raise
  end
rescue
  show_help
end
compress(path, format) click to toggle source
# File lib/total_compressor.rb, line 26
def compress(path, format)
  if BaseCompressor::TYPE[format]
    eval("TotalCompressor::T#{format.capitalize}.new.compress(\'#{path}\')")
  else
    ap BaseCompressor::MSG[:unsupported]
  end
end
decompress(path) click to toggle source
# File lib/total_compressor.rb, line 34
def decompress(path)
  format = path.split('.')[-1]
  if BaseCompressor::TYPE[format]
    eval("TotalCompressor::T#{format.capitalize}.new.decompress(\'#{path}\')")
  else
    ap BaseCompressor::MSG[:unsupported]
  end
end
show_help() click to toggle source
# File lib/total_compressor.rb, line 53
def show_help
  puts %Q{
  Total Compressor, v#{TotalCompressor::VERSION}, 2013, MIT License, https://github.com/phlowerteam
  Tool (wrapper) for compression and handling multiple type of archives (Zip, GZip, RAR, 7z).

  Usage: tcomp [<key>] full_path
    <key> - determines supported type of compression:
      z - use Zip
      g - use GZip (can't compress folder, only file)
      r - use RAR
      7 - use 7z

  Examples:
    tcomp z '/home/alex/The Lord of the Rings.txt'  # creates '/home/alex/The Lord of the Rings.txt.zip'
    tcomp /home/alex/Hobbit.txt.7z                  # creates /home/alex/Hobbit.txt
  }
end
test() click to toggle source
# File lib/total_compressor.rb, line 43
def test
  result = []
  compressors = constants
  compressors -= [:BaseCompressor, :VERSION]
  compressors.each do |compressor|
    result << eval("TotalCompressor::#{compressor.to_s}.new.test")
  end
  result
end