[Rubygems-developers] Thoughts on handling bin and man files

Chad Fowler chad at chadfowler.com
Fri Mar 19 16:43:28 EST 2004


On Fri, 19 Mar 2004, Richard Kilmer wrote:

# 
# On Mar 19, 2004, at 11:22 AM, Chad Fowler wrote:
# 
# > $ rake  # runs rake out of a directory that's normally in the path
# > $ gem --run rake --version 0.3.0   # runs a specific version of the 
# > rake
# > executable from its gem directory
# 
# Hm...this creates an interesting issue.
# 
# if you run the 'rake' script it would normally have:
# 
#    require 'rake'
# 
# at the top of the script...this is bad...because if you just run this 
# script the gem for rake has not been loaded.
# 
# if this changes to...
# 
#    require 'rubygems'
#    require_gem 'rake'
# 
# ...then this executable script is dependent on RubyGems, which limits 
# its usability outside of RubyGems (as a .tar.gz).
# 
# now, what if the installed 'rake' executable was generated by our gem 
# installer that would have:
# 
#    require 'rubygems'
#    require_gem 'rake', "= 0.3.0" #=> or whatever version of the gem this 
# was generated for.
#    load 'bin/rake'  #=> or whatever the binary that this is referring to 
# is.
# 

Now that I think about this some more, how about this:

   ...optparse stuff...
   require 'rubygems'
   require_gem('rake', options[:gem_version] || "> 0.0.0") 
   load 'bin/rake'

This way you could invoke the following from the command line:

  rake --gem-version 0.4.0

...for a specific version, or

  rake
 
...for the latest version.  require_gem() loads the latest version if no 
version is specified.

Comments?

Chad



More information about the Rubygems-developers mailing list