I needed to use Archive::Tar today, and was bit by what I guess was an
unforseen use. I need to simply unpack an archive, optionally
decompressing it first. So, I have code like this:
def expand t = Archive::Tar.new( @name ) case @name when /\.tar\.bz2/ t.expand when /\.bz2/ t.uncompress("bunzip2") when /\.t(ar\.)?gz/ t.expand when /\.gz/ t.uncompress("gunzip") when /\.zip/ t.uncompress("unzip") else raise UnknownArchiveError end end
which works fine for what I need if I redefine uncompress_archive like
It seems that @compressed_archive_name can only be set if one first
compresses an archive. I don’t need to do that here - I just need to
uncompress an already-existing archive.
Should I be redefining this method or should the package be changed to
the (my) expected behavior? Or have I just totally missed the usage
here? Has anyone else run up against this?