pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: pkgsrc

OBATA Akio wrote:
On Tue, 18 Mar 2008 15:14:31 +0900, Johnny C. Lam <> 

Log Message:
Allow for loading libraries installed as gems.  Bump PKGREVISION.

This mean all ruby script will have to "require rubygems"?
Not only packages in pkgsrc but also own ruby script using modules in pkgsrc.

Ruby scripts that use extensions that are installed as gems need to do one of the following:

(1) Try loading "rubygems" at the start of the script, but ignoring a load failure:

        require 'rubygems' rescue LoadError
        require 'sqlite3'

(2) Do a fallback loading of an extension if it fails to load without rubygems:

          require 'sqlite3'
        rescue LoadError
          require 'rubygems'
          require 'sqlite3'

Doing it the second way is more efficient -- you only load rubygems if you really need it. The first way is more convenient in terms of lines of code, but it always load rubygems if it's on the system regardless of whether it's needed or not.


        -- Johnny C. Lam

Home | Main Index | Thread Index | Old Index