From: Eric Hodel Date: 2007-01-21T13:42:26+09:00 Subject: Re: Getting the version number for rubygems? On Jan 20, 2007, at 20:11, Gregory Brown wrote: > In ruport I have a tool that generates a bunch of boilerplate code for > folks, and in it, I use require_gem to lock the files down to a > specific version of Ruport. > > I'd like to make this friendly to RubyGems 0.9.1 by using the gem > method rather than require_gem when people have 0.9.1, but want to > generate require_gem for older versions. Just use #gem, and don't bother being backwards-compatible. RubyGems older than 0.9.1 has a serious security exploit. (About 20% of rubyists are running a version of RubyGems without #gem (prior to 0.9.1's release).) > So basically, is there a constant or method I can call that'll give me > back the version of rubygems that i'm running? Don't think so hard: require 'rubygems' Kernel.respond_to? :gem And now for the real answer to your question: The rubygems constant is in Gem::RubyGemsVersion, which you can get from 'rubygems/rubygems_version'. Kernel#gem first appeared in 0.9.0. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net I LIT YOUR GEM ON FIRE!