[Rubygems-developers] faster rubygems.rb loading by way of deferred plugin loads, and other resource usage enhancements

Eric Hodel drbrain at segment7.net
Fri Jul 9 19:39:47 EDT 2010

On Jul 9, 2010, at 09:25, Luis Lavena wrote:
>> A solution for command plugins would be to have plugins simply register a list of files that should be loaded when commands are going to be invoked. A continuation of this idea leads to an API something along the lines of:
>> Gem.register_plugin(:install, 'some_plugin/gem/installer')
>> Gem.register_plugin(:command, 'some_plugin/gem/command')
> Wouldn't be more appropriate Gem.register_command(:push,
> 'path/to/gemcutter/plugin') ?
> After all, you're registering commands, since the plugin loader has
> already been started.

I think register_plugin could be as simple as:

module Gem

  @plugins = Hash.new { |h,k| h[k] = [] }

  def self.register_plugin type, path
    @plugins[type] << path

And Gem::CommandManager would look in the hash to see what files it should load after it is required (if at all).

More information about the Rubygems-developers mailing list