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

Jim Freeze rubygems at freeze.org
Tue Sep 30 17:15:46 EDT 2008


On Tue, Sep 30, 2008 at 4:07 PM, Austin Ziegler <halostatue at gmail.com> wrote:
> On Tue, Sep 30, 2008 at 4:51 PM, Jim Freeze <rubygems at freeze.org> wrote:
>> One way (just one, mind you) is that if require_gem really required
>> the gem. So, you would have
>>
>>  require_gem 'gem_name_here'
>>
>> and the gem did the requiring of the files internal.
>>
>> Just a thought.
>
> No, no no no no.
>
> That's what it used to do (with autoload).
>
> This is bad, bad, bad, bad, bad. (Which is why it was deprecated.)

Are you sure? I thought require_gem was the same as require, in that
it required a file, but searched for it in the gem paths.

I have never created a gem that one could load with

  require 'gem_name'

because that would require my gem to have an init hook and that hook
is where the real require would happen. Maybe I am getting old and
forgetful, but I don't remember ever doing that for the gems that I
have written.

> You shouldn't be using "require_gem" anyway; you should be using "gem"
> to activate particular gems/versions.
>
> I'd suggest that good practice would be including a dummy file that
> matches your gem name, if appropriate.

Yes, I have seen this with activesupport.rb and active_support.rb

> That is, if I were to do this with PDF::Writer, I would make it so
> that you could "require 'pdf-writer'" (since that's the name of the
> gem), instead of "pdf/writer".
>


-- 
Jim Freeze


More information about the Rubygems-developers mailing list