# Archive::Tar uncompress question

**URL:** <https://www.ruby-forum.com/t/archive-tar-uncompress-question/57053>\
**Category:** Ruby\
**Created:** [April 6, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/archive-tar-uncompress-question/57053 "2006-04-06T21:07:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimitri\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e68b1a/32.png) [@Dimitri\_A](https://www.ruby-forum.com/u/Dimitri_A)\
**Post date:** [April 6, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/archive-tar-uncompress-question/57053/1 "2006-04-06T21:07:01Z")

</div>

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:

- unless @compressed\_archive\_name - raise CompressError, "no compressed file found" - end + unless @compressed\_archive\_name + @compressed\_archive\_name = @archive\_name + end

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

---

<div class="post-metadata">

**Author:** ![Dimitri\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e68b1a/32.png) [@Dimitri\_A](https://www.ruby-forum.com/u/Dimitri_A)\
**Post date:** [April 6, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/archive-tar-uncompress-question/57053/2 "2006-04-06T21:19:15Z")

</div>

On 4/6/06, Dimitri A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
