Forum: Ruby RubyZip:

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.
872f7dae7836bf174692c79e21f7c5cc?d=identicon&s=25 Allen Fisher (blazinbsdagility)
on 2008-12-11 19:04
Hello, all. I'm setting up some code to pull a zipped up build of our
software from a server, unzip it, and place it in a directory to be
tested against. I'm having some issues using the RubyZip gem. Here's my
stripped-down code:

require 'rubygems'
require 'zip/zip'

Zip::Zipfile.open("/Users/afisher/Desktop/TestSet.zip") do |zipfile|
  dir = zipfile.dir
  dir.entries('.').each do |entry|
    zipfile.extract(entry,"/Users/afisher/Desktop")
  end
end

When I run this code, I get the following error message:
$ ruby /Users/afisher/Desktop/ZipTest.rb
$ /Users/afisher/Desktop/ZipTest.rb:6: uninitialized constant
Zip::Zipfile (NameError)

This code is very similar to several sources I looked at on the web as
well as sample code that came with RubyZip, so I have to be doing
something glaringly wrong, but I can't seem to put my finger on it. I
even tried adding require 'zip/zipfilesystem' and that didn't seem to
help.

Thanks for any pointers on where to look, either in code or docs.

Allen
872f7dae7836bf174692c79e21f7c5cc?d=identicon&s=25 Allen Fisher (blazinbsdagility)
on 2008-12-11 20:10
Allen Fisher wrote:
> Hello, all. I'm setting up some code to pull a zipped up build of our
> software from a server, unzip it, and place it in a directory to be
> tested against. I'm having some issues using the RubyZip gem. Here's my
> stripped-down code:
>
> require 'rubygems'
> require 'zip/zip'
>
> Zip::Zipfile.open("/Users/afisher/Desktop/TestSet.zip") do |zipfile|
>   dir = zipfile.dir
>   dir.entries('.').each do |entry|
>     zipfile.extract(entry,"/Users/afisher/Desktop")
>   end
> end
>
> When I run this code, I get the following error message:
> $ ruby /Users/afisher/Desktop/ZipTest.rb
> $ /Users/afisher/Desktop/ZipTest.rb:6: uninitialized constant
> Zip::Zipfile (NameError)
>
> This code is very similar to several sources I looked at on the web as
> well as sample code that came with RubyZip, so I have to be doing
> something glaringly wrong, but I can't seem to put my finger on it. I
> even tried adding require 'zip/zipfilesystem' and that didn't seem to
> help.
>
> Thanks for any pointers on where to look, either in code or docs.
>
> Allen

Excuse me while I crawl back in my hole. I just discovered the problem.
ZipFile instead of Zipfile.

Sorry for the waste of bandwidth
This topic is locked and can not be replied to.