The standard RubyGems loading mechanism keeps a cache (now called source_index) of all the gems and the files they include.
This not only takes quite some time when starting a ruby script or application, more importantly the memory consumption
grows with each gem that's installed on your system.
Minigems handles loading of required gems from your scripts. If however, other functionality is needed, the full rubygems
library will be loaded automatically to continue normal operation. In many respects it's similar to gem_prelude, but
it's more tightly integrated into Rubygems itself:
When installing a gem you can use the -m switch to create a minigems based wrapper, instead of the standard rubygems
based version. This is essential to work with minigems, as it makes sure that rubygems (full) hasn't been loaded at
all, making way for minigems to mimic the basic loading functionality: install gem foo -m
Additionally, a gem developer can enable the installation of a minigems wrapper by default by adding the line: s.minigems
= true to the gemspec definition. Should the end-user choose to use plain rubygems instead, the install option --no-minigems
can be used.
To remove any code duplication, common methods (for both the minigems as well as the rubygems version of the Gem module)
have been extracted into rubygems/core. It's shared between both implementations.
To fall back to a full rubygems system, method_missing will catch any method that's actually implemented by the full
rubygems. The same is true for any missing constants. At install time there's a list of Gem module methods that's get
pregenerated and added to minigems.rb, thus keeping current with the actual code itself.
Regarding unit tests, all tests pass when the 'require "rubygems"' line in gemutilities.rb is switched to
use 'minigems' instead. Off coarse, with plain 'rubygems' all tests are fine as well.
|