Forum: Ruby Archive::Tar uncompress question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
801b207647d808477fc4514568c9d723?d=identicon&s=25 Dimitri Aivaliotis (Guest)
on 2006-04-06 21:07
(Received via mailing list)
Hi,

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
so:

<pseudo-patch>
-         unless @compressed_archive_name
-            raise CompressError, "no compressed file found"
-         end
+       unless @compressed_archive_name
+         @compressed_archive_name = @archive_name
+       end
</pseudo-patch>

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?

- Dimitri
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-04-06 21:19
(Received via mailing list)
On 4/6/06, Dimitri Aivaliotis <aglarond@gmail.com> wrote:
> 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:

...

I'm not sure. I'm just surprised that tarsimple uses Archive::Tar as
its name, instead of Archive::Tar::Wrapper or something like that,
since it's just a wrapper, and not a tar implementation in Ruby.

-austin
This topic is locked and can not be replied to.