Module Kernel
In: lib/rubygems/custom_require.rb

Methods

require  

External Aliases

require -> gem_original_require
  The Kernel#require from before RubyGems was loaded.

Private Instance methods

When RubyGems is required, Kernel#require is replaced with our own which is capable of loading gems on demand.

When you call require ‘x‘, this is what happens:

  • If the file can be loaded from the existing Ruby loadpath, it is.
  • Otherwise, installed gems are searched for a file that matches. If it‘s found in gem ‘y’, that gem is activated (added to the loadpath).

The normal require functionality of returning false if that file has already been loaded is preserved.

[Source]

    # File lib/rubygems/custom_require.rb, line 28
28:   def require(path) # :doc:
29:     gem_original_require path
30:   rescue LoadError => load_error
31:     if load_error.message.end_with?(path) and Gem.try_activate(path) then
32:       return gem_original_require(path)
33:     end
34: 
35:     raise load_error
36:   end

[Validate]