From: "Berger, Daniel" Date: 2005-10-11T22:07:31+09:00 Subject: Re: gems is a language change, not a pkging system > -----Original Message----- > From: Jim Weirich [mailto:jim@weirichhouse.org] > Sent: Tuesday, October 11, 2005 6:36 AM > To: ruby-core@ruby-lang.org > Subject: Re: gems is a language change, not a pkging system > > > > Berger, Daniel said: > > I guess I'll wait to ask at RubyConf why it couldn't just scan down > > the sitelibdir. :) > > How can you tell from sitedir whether a particular version of > a library has been installed? My preference would be that gems abort if the package is found *at all* in the sitelibdir, unless a "force" option is used. However, you could also make a best guess: # Or something along these lines if File.exists?("sitelibdir/some/package") require "some/package" constants = Some::Package.constants if constants.include?("VERSION") version = Some::Package.const_get("VERSION") # classes else if constants.include?("PACKAGE_VERSION") version = Some::Package.const_get("PACKAGE_VERSION") # modules else # not found end end This would rely on a convention of people defining a VERSION constant for classes, or a MODULE_VERSION for modules in their packages. It's not guaranteed to work, I realize, but it's better than nothing IMHO. Regards, Dan