How to include zip in a program

Hello all,

Yay! I’m now subscribed to this list. =)

As I mentioned earlier, I’m working on a program to gather data from
OpenOffice.org files. It’s comming along well. It is sort of a grep-like
program. One difference is that it can not only match text content, but
it can match styles.

I think this is very neat. You can take advantage of the logical
structure of OpenOffice.org documents. Say you have a document full of
poems, and you create a style called “PoemAuthor”. With this program you
can extract all the authors from the document.

Now, I am fiding one significant stumbling block: Zip.

OOo files are zip archives. Ruby doesn’t come with zip functionality by
default, and I don’t want to ask people to compile anything to get this
program to run. Most of them won’t have a compiler.

Also, I haven’t been able to compile the ruby-zlib pacakge from RAA, so
I’m not sure I want to rely on it.

Can anyone suggest a good way of solving this? All I need is to extract
one file from a zip archive. Currently, the program runs the external
program, unzip. Perhaps I should ship unzip along with the program? I
think I’m leaning towards this direction.

Does this sound like a good approach?

I am on a Solaris system, so I would need some help gathering command-line
zip programs for the three main platforms: Linux, Mac OS X and Windows.

Any thoughts, comments and ideas would be much appreciated.

Cheers,

···


Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | “To understand recursion, you must first
UMD, College Park | understand recursion”.

Hello,

I have found a problem with character classes definition in unicoded
regular expressions. It seems \s isn’t defined properly.

See the following simple program which ought to change space symbols
into “line feed”:
cat test.utf8 | ruby-1.8.0 -Ku -ne ‘$.gsub(/[\s]+/u,"\n"); puts $;’

test.utf8 contains the following in hex:
C2 A0 32 33 20 31 0A C2 A0 32 34 20 31 0A

which is UTF8 code for:
00A0 NS no-break space
0032 2 digit two
0033 3 digit three
0020 SP space
0031 1 digit one
000A LF line feed (lf)
00A0 NS no-break space
0032 2 digit two
0034 4 digit four
0020 SP space
0031 1 digit one
000A LF line feed (lf)

But Ruby does not make any changes (does not change "no-break space"
into “line feed”)!
Is that a bug?

Best wishes,
Sergei

Daniel,

OOo files are zip archives.

Have you taken a look on the OO source code, to see how OO deals with it ?

Perhaps I should ship unzip along with the program? I
think I’m leaning towards this direction.

Does this sound like a good approach?

Sounds good …
or you can also just point this dependence and raise an error along
with the
download url depending on each platform in case unzip is not found on
the system.
I hate to have duplicated files on my system.

I suspect mostly Linux-Distro come with zip/unzip

I am on a Solaris system, so I would need some help gathering command-line
zip programs for the three main platforms: Linux, Mac OS X and Windows.

I can help you with the linux box.

-r.

Recent ruby distributions come with ruby/zlib?
I am running 1.8.0 and I don't have ruby/zlib. I checked the Ruby website
and it looks like 1.8.0 is the newest.

There is an RAA project called ruby-zlib but I can't get it to compile.
(and even if I could, I'd still have the problem that I can't expect the
recpients of this program to have a compiler).

Cheers,

···

On Mon, Oct 27, 2003 at 01:16:18PM -0500, walter@mwsewall.com wrote:

have you tried using rubyzip at
rubyzip download | SourceForge.net
it uses the ruby/zlib that is included in most recent ruby
distributions. It is easy to use and works pretty well.

--
Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | "To understand recursion, you must first
UMD, College Park | understand recursion".

>

> have you tried using rubyzip at

> http://sourceforge.net/projects/rubyzip

> it uses the ruby/zlib that is included in most recent ruby

> distributions. It is easy to use and works pretty well.

···

On Tue, 28 Oct 2003, Daniel Carrera wrote:

On Mon, Oct 27, 2003 at 01:16:18PM -0500, walter@mwsewall.com wrote:

Recent ruby distributions come with ruby/zlib?

I am running 1.8.0 and I don’t have ruby/zlib. I checked the Ruby website

and it looks like 1.8.0 is the newest.

There is an RAA project called ruby-zlib but I can’t get it to compile.

(and even if I could, I’d still have the problem that I can’t expect the

recpients of this program to have a compiler).

http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/ext/zlib/

I think that my Ruby is broken. I did compile it from source, but I'm
missing the zlib module.

$ ruby -v
ruby 1.8.0 (2002-12-24) [sparc-solaris2.8]
$
$ ruby -e " require 'zlib' "
-e:1:in `require': No such file to load -- zlib (LoadError)
$
$ ls -R lib/ruby/ | grep zlib
$

I've tried compiling the ruby-zlib module from RAA but without success
(see my earlier post).

Can anyone see anything I'm doing wrong? I don't recall any particular
errors when I compiled ruby 1.8.0.

If I can't find anything I'll try compiling ruby again.

Cheers,
Daniel.

···

On Mon, Oct 27, 2003 at 02:57:06PM -0600, Lyle Johnson wrote:

Daniel Carrera wrote:

>Recent ruby distributions come with ruby/zlib?

The "zlib" extension module is one of the standard extensions shipped
with ruby 1.8.0. If you built ruby 1.8.0 from source, you should find
the code for it in the ruby-1.8.0/ext/zlib directory of the source tree.
If you've already built and installed ruby 1.8.0, you should be able to do:

  require 'zlib'

to load that extension.

Hope this helps,

Lyle

--
Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | "To understand recursion, you must first
UMD, College Park | understand recursion".

Sergei Olonichev wrote:

Hello,

I have found a problem with character classes definition in unicoded
regular expressions. It seems \s isn’t defined properly.

See the following simple program which ought to change space symbols
into “line feed”:
cat test.utf8 | ruby-1.8.0 -Ku -ne ‘$.gsub(/[\s]+/u,“\n”); puts $;’

I have forgotten “!” after “gsub” here in this letter but not when I
tested this problem, so “!” does not help.

···

test.utf8 contains the following in hex:
C2 A0 32 33 20 31 0A C2 A0 32 34 20 31 0A

which is UTF8 code for:
00A0 NS no-break space
0032 2 digit two
0033 3 digit three
0020 SP space
0031 1 digit one
000A LF line feed (lf)
00A0 NS no-break space
0032 2 digit two
0034 4 digit four
0020 SP space
0031 1 digit one
000A LF line feed (lf)

But Ruby does not make any changes (does not change “no-break space”
into “line feed”)!
Is that a bug?

Best wishes,
Sergei

Maybe the zlib library on your machine is in a non-standard directory. Ruby
configure script may not find it and goes without zlib support. I would
suggest browsing through configure messages if you recompile Ruby.

Search for zlib.h and libz* on your machine.

Regards,

Dalibor

···

On Tue, Oct 28, 2003 at 05:51:34AM +0900, Daniel Carrera wrote:

I think that my Ruby is broken. I did compile it from source, but I’m
missing the zlib module.


Dalibor Sramek insula.cz | In the eyes of cats,
dalibor.sramek@insula.cz | all things belong to cats.

Look at the date of your version: 2002-12-24. It’s an ancient copy, not
the official 1.8.0 release.

Ian

···

On Tue 28 Oct 2003 at 05:51:34 +0900, Daniel Carrera wrote:

I think that my Ruby is broken. I did compile it from source, but I’m
missing the zlib module.

$ ruby -v
ruby 1.8.0 (2002-12-24) [sparc-solaris2.8]
$
$ ruby -e " require ‘zlib’ "
-e:1:in `require’: No such file to load – zlib (LoadError)
$
$ ls -R lib/ruby/ | grep zlib
$

I’ve tried compiling the ruby-zlib module from RAA but without success
(see my earlier post).

Can anyone see anything I’m doing wrong? I don’t recall any particular
errors when I compiled ruby 1.8.0.


Ian Macdonald | Barker’s Proof: Proofreading is more
System Administrator | effective after publication.
ian@caliban.org |
http://www.caliban.org |
>

Yeah, that must have been it. This explains why downloading it and compiling again
solved it.

Cheers,

···

On Wed, Oct 29, 2003 at 06:56:55AM +0900, Ian Macdonald wrote:

Can anyone see anything I’m doing wrong? I don’t recall any particular
errors when I compiled ruby 1.8.0.

Look at the date of your version: 2002-12-24. It’s an ancient copy, not
the official 1.8.0 release.


Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | “To understand recursion, you must first
UMD, College Park | understand recursion”.