[Rubygems-developers] Gem Names not correlated to require name

Jim Weirich jim.weirich at gmail.com
Wed Oct 1 00:06:29 EDT 2008

On Sep 30, 2008, at 11:50 PM, Jim Freeze wrote:
> On Tue, Sep 30, 2008 at 10:26 PM, Jim Weirich  
> <jim.weirich at gmail.com> wrote:
>> Are you asking for this:
>>  def bunny_foo_foo(gem_name)
>>    gem gem_name
>>    require the_default_load_file_for_gem(gem_name)
>>  end
> I am not up to speed with the exact nature of gem. Is it the same as:
>  def bunny_foo_foo(gem_name)
>    require 'rubygems'
>    require the_default_load_file_for_gem(gem_name)
>  end

No, it does neither of those two things.

> I'm assuming the gem bascially stages a gem for later requiring.

That is a good description of it.  It accomplishes that by arranging  
the Ruby load path so that a normal ruby require will find the proper  
files stored in the gem.

>> or are you asking for:
>>  def bunny_foo_foo(gem_name)
>>    require the_default_load_file_for_gem(gem_name)
>>  end
> One way to write this would be to
>   def bunny_foo_foo(gem_name)
>     require File.join(path_to(gem_name), "lib/bootstrap")
>   end

Interesting.  I would suggest that the bootstrap file NOT be located  
in the lib directory (nor the bin directory), but be located somewhere  
that will not be put on the load path.  This will prevent accidental  
loading of the file.

I'm still not sure what advantage this has over a simple convention of  
providing a base require file using the same name as the gem.

-- Jim Weirich
-- jim.weirich at gmail.com

More information about the Rubygems-developers mailing list