Hi!

Here comes the patch for zlib.rb and three new source files.
Hopefully this is enough for it to work with gems, at least.

I am running JRuby from HEAD, so this error doesn't make sense. It seems
as if the script isn't running in my CWD, which makes it impossible to
find the needed file.

Regards
 Ola Bini


----- Original Message -----
From: Charles O Nutter <[EMAIL PROTECTED]>
Date: Monday, March 20, 2006 11:44 pm
Subject: Re: [Jruby-devel] Status of Zlib and Gem
To: [email protected]

> If you are running with JRuby 0.8.2 you will proably not get gems 
> to run all
> the way. If that's the case, you should make sure to use the 
> current JRuby
> in CVS HEAD, which should run gems successfully up to the point it 
> needszlib.
> 
> You may try to send what you have as well, and we can see what it 
> fixes. I
> would love to see what you have and give it a try while you're 
> trying to get
> gems working at a basic level.
> 
> - Charlie
> 
> On 3/20/06, Ola Bini <[EMAIL PROTECTED]> wrote:
> >
> > Cool. 760 new files to serialize. =)
> >
> > That got me a long way. The snag now seems to be
> >   Dir.chdir("pkgs/sources") do
> >     load "sources.gemspec"
> >     spec = Gem.sources_spec
> >     gem_file = Gem::Builder.new(spec).build
> >     Gem::Installer.new(gem_file).install(true, Gem.dir, false)
> >   end
> > where it can't find "sources.gemspec". This is probably due to some
> > problems with CWD or whatnot. I'll take a closer look on it 
> tomorrow, if
> > you don't have any ideas about it.
> >
> > Regards
> > Ola Bini
> >
> > ----- Original Message -----
> > From: Thomas E Enebo <[EMAIL PROTECTED]>
> > Date: Monday, March 20, 2006 11:30 pm
> > Subject: Re: [Jruby-devel] Status of Zlib and Gem
> > To: [email protected]
> >
> > > On Mon, 20 Mar 2006, Ola Bini defenestrated me:
> > > > Hi.
> > > >
> > > > I have now implemented most of the basic functionality in 
> zlib.rb> > > (Zlib::Inflate, Zlib::Deflate, Zlib::GzipReader and 
> Zlib::GzipWriter> > > have the most basic functionality to make it 
> marginally useful).
> > > Sorry> to say, much of the more interesting features in gz are
> > > missing from the
> > > > java implementation, and I've been unable to find another
> > > implementation> right now.
> > > >
> > > > The good news is that the use of zlib in Gem's is fairly
> > > rudimentary. My
> > > > thinking was that I should try to install the package and see 
> if it
> > > > works, but this fails due to
> > > >  require 'find'
> > > > in post-install.rb.
> > >
> > >  Cool.  At this point you should consider copying 
> /usr/lib/ruby/1.8> > into jruby_home/lib/ruby/1.8.  The error you 
> are seeing is the fact
> > > that jruby has not yet included find.rb.  Copying the directory 
> should> > get you a long ways.
> > >
> > > -Tom
> > >
> > > --
> > > + http://www.tc.umn.edu/~enebo +---- mailto:[EMAIL PROTECTED] ----+
> > > | Thomas E Enebo, Protagonist  | "Luck favors the prepared    |
> > > |                              |  mind." -Louis Pasteur       |
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by xPML, a groundbreaking scripting
> > > languagethat extends applications into web and mobile media. 
> Attend> > the live webcast
> > > and join the prime developer group breaking into this new coding
> > > territory!http://sel.as-
> > >
> >
> > 
>
us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642_______________________________________________>
> Jruby-devel mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/jruby-devel
> > >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by xPML, a groundbreaking scripting
> > language
> > that extends applications into web and mobile media. Attend the live
> > webcast
> > and join the prime developer group breaking into this new coding
> > territory!
> > http://sel.as-
> us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642> 
> _______________________________________________> Jruby-devel 
> mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jruby-devel
> >
> 
> 
> 
> --
> Charles Oliver Nutter @ headius.blogspot.com
> JRuby Developer @ jruby.sourceforge.net
> Application Architect @ www.ventera.com
> 

Attachment: zlib.patch
Description: Binary data

/***** BEGIN LICENSE BLOCK *****
 * Version: CPL 1.0/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Common Public
 * License Version 1.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.eclipse.org/legal/cpl-v10.html
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * 
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the CPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the CPL, the GPL or the LGPL.
 ***** END LICENSE BLOCK *****/
package org.jruby.util;

import java.lang.reflect.Field;

import java.util.zip.Adler32;
import java.util.zip.Checksum;

/**
 * This class is a wrapper around Adler32 which provides the capability to 
 * update the running total. This functionality is provided by quite risky
 * reflection and should be fixed in a better way later on.
 */
public class Adler32Ext implements Checksum {
    private int adler;
    private final Adler32 intern;

    private static Field intern_adler; 

    static {
        try {
            intern_adler = Adler32.class.getDeclaredField("adler");
            intern_adler.setAccessible(true);
        } catch(final NoSuchFieldException nsfe) {
            throw new RuntimeException("This class have stopped working, it should be updated and FIXED now.");
        }
    }

    /**
     * Creates the basic object with default initial adler.
     */
    public Adler32Ext() {
        this(1);
    }

    /**
     * Creates the basic object with the adler provided.
     *
     * @param adler the number to use as starting point for the Adler-32 algorithm
     */
    public Adler32Ext(final int adler) {
        super();
        this.adler=adler;
        this.intern = new Adler32();
        setAdlerRef(this.adler);
    }

    /**
     * Sets the adler running total to the specified value.
     *
     * @param adler the number to use as current value for the Adler-32 algorithm
     */
    public void setAdler(final int adler) {
        this.adler = adler;
        setAdlerRef(this.adler);
    }

    /**
     * @see java.util.zip.Checksum#update
     */
    public void update(final int b) {
        this.intern.update(b);
    }

    /**
     * @see java.util.zip.Checksum#update
     */
    public void update(final byte[] b, final int off, final int len) {
        this.intern.update(b,off,len);
    }

    /**
     * @see java.util.zip.Checksum#update
     */
    public void update(final byte[] b) {
        this.intern.update(b);
    }

    /**
     * @see java.util.zip.Checksum#reset
     */
    public void reset() {
        this.intern.reset();
	this.adler = 1;
    }

    /**
     * @see java.util.zip.Checksum#getValue
     */
    public long getValue() {
	return this.intern.getValue();
    }

    /**
     * Helper method to set the reference through reflection.
     *
     * @param val the value to set.
     */
    private void setAdlerRef(final int val) {
        try {
            intern_adler.setInt(intern,val);
        } catch(final IllegalAccessException e) {
            throw new IllegalStateException(e.toString());
        }
    }
}
/***** BEGIN LICENSE BLOCK *****
 * Version: CPL 1.0/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Common Public
 * License Version 1.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.eclipse.org/legal/cpl-v10.html
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * 
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the CPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the CPL, the GPL or the LGPL.
 ***** END LICENSE BLOCK *****/
package org.jruby.util;

import java.lang.reflect.Field;

import java.util.zip.CRC32;
import java.util.zip.Checksum;

/**
 * This class is a wrapper around CRC32 which provides the capability to 
 * update the running total. This functionality is provided by quite risky
 * reflection and should be fixed in a better way later on.
 */
public class CRC32Ext implements Checksum {
    private int crc;
    private final CRC32 intern;

    private static Field intern_crc; 

    static {
        try {
            intern_crc = CRC32.class.getDeclaredField("crc");
            intern_crc.setAccessible(true);
        } catch(final NoSuchFieldException nsfe) {
            throw new RuntimeException("This class have stopped working, it should be updated and FIXED now.");
        }
    }

    /**
     * Creates the basic object with default initial crc checksum.
     */
    public CRC32Ext() {
        this(1);
    }

    /**
     * Creates the basic object with the crc checksum provided.
     *
     * @param crc the number to use as starting point for the CRC-32 algorithm
     */
    public CRC32Ext(final int crc) {
        super();
        this.crc=crc;
        this.intern = new CRC32();
        setCrcRef(this.crc);
    }

    /**
     * Sets the crc running total to the specified value.
     *
     * @param crc the number to use as current value for the CRC-32 algorithm
     */
    public void setCrc(final int crc) {
        this.crc = crc;
        setCrcRef(this.crc);
    }

    /**
     * @see java.util.zip.Checksum#update
     */
    public void update(final int b) {
        this.intern.update(b);
    }

    /**
     * @see java.util.zip.Checksum#update
     */
    public void update(final byte[] b, final int off, final int len) {
        this.intern.update(b,off,len);
    }

    /**
     * @see java.util.zip.Checksum#update
     */
    public void update(final byte[] b) {
        this.intern.update(b);
    }

    /**
     * @see java.util.zip.Checksum#reset
     */
    public void reset() {
        this.intern.reset();
	this.crc = 1;
    }

    /**
     * @see java.util.zip.Checksum#getValue
     */
    public long getValue() {
	return this.intern.getValue();
    }

    /**
     * Helper method to set the reference through reflection.
     *
     * @param val the value to set.
     */
    private void setCrcRef(final int val) {
        try {
            intern_crc.setInt(intern,val);
        } catch(final IllegalAccessException e) {
            throw new IllegalStateException(e.toString());
        }
    }
}
/***** BEGIN LICENSE BLOCK *****
 * Version: CPL 1.0/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Common Public
 * License Version 1.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.eclipse.org/legal/cpl-v10.html
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * 
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the CPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the CPL, the GPL or the LGPL.
 ***** END LICENSE BLOCK *****/
package org.jruby.util;

import java.io.InputStream;
import java.io.OutputStream;

import org.jruby.RubyIO;

/**
 * A wrapper object to allow access to the IO-internal input and outputstreams.
 * This class is a hack, and should be replaced by Ruby classes that extend
 * OutputStream and InputStream to act as wrappers to IO-objects.
 * This is not possible at this point, since those classes are abstract.
 *
 * The fatal flaw of this class is that there is no possibility for duck typing.
 */
public class IOConverter {
    private final RubyIO io;

    /**
     * Creates a new converter with the IO object provided.
     *
     * @param io the io object
     */
    public IOConverter(final RubyIO io) {
        this.io = io;
    }
    
    /**
     * Returns the internal OutputStream.
     *
     * @return the output stream
     */
    public OutputStream asOutputStream() {
        return io.getOutStream();
    }

    /**
     * Returns the internal InputStream.
     *
     * @return the input stream
     */
    public InputStream asInputStream() {
        return io.getInStream();
    }
}

Reply via email to