Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 43 lines (33 sloc) 1.099 kb
ea8e85c Jim Weirich added copyright and license information, added datadir methods
jimweirich authored
1 #--
2 # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3 # All rights reserved.
4 # See LICENSE.txt for permissions.
5 #++
6
35dd71d Eric Hodel Correctly include documentation for methods added to Kernel
drbrain authored
7 module Kernel
fd92455 Gavin Sinclair * lib/rubygems/custom_require.rb: new file to replace
gsinclair authored
8
28aca90 Eric Hodel Privatize kernel methods, expose Kernel extensions to RDoc.
drbrain authored
9 ##
10 # The Kernel#require from before RubyGems was loaded.
11
12 alias gem_original_require require
13
14 ##
15 # When RubyGems is required, Kernel#require is replaced with our own which
16 # is capable of loading gems on demand.
fd92455 Gavin Sinclair * lib/rubygems/custom_require.rb: new file to replace
gsinclair authored
17 #
18 # When you call <tt>require 'x'</tt>, this is what happens:
2a08287 Jim Weirich Some reformatting of comments.
jimweirich authored
19 # * If the file can be loaded from the existing Ruby loadpath, it
20 # is.
21 # * Otherwise, installed gems are searched for a file that matches.
22 # If it's found in gem 'y', that gem is activated (added to the
23 # loadpath).
fd92455 Gavin Sinclair * lib/rubygems/custom_require.rb: new file to replace
gsinclair authored
24 #
2a08287 Jim Weirich Some reformatting of comments.
jimweirich authored
25 # The normal <tt>require</tt> functionality of returning false if
26 # that file has already been loaded is preserved.
28aca90 Eric Hodel Privatize kernel methods, expose Kernel extensions to RDoc.
drbrain authored
27
28 def require(path) # :doc:
575cc51 Jim Weirich Renamed require__ to gem_original_require.
jimweirich authored
29 gem_original_require path
84aa8c1 Jim Weirich Changed require to rethrow the original exception after attempting a gem...
jimweirich authored
30 rescue LoadError => load_error
36e6aff Ryan Davis Merged 1.3.7/ruby-core changes to master
zenspider authored
31 if load_error.message.end_with?(path) and Gem.try_activate(path) then
32 return gem_original_require(path)
fd92455 Gavin Sinclair * lib/rubygems/custom_require.rb: new file to replace
gsinclair authored
33 end
36e6aff Ryan Davis Merged 1.3.7/ruby-core changes to master
zenspider authored
34
35 raise load_error
fd92455 Gavin Sinclair * lib/rubygems/custom_require.rb: new file to replace
gsinclair authored
36 end
28aca90 Eric Hodel Privatize kernel methods, expose Kernel extensions to RDoc.
drbrain authored
37
38 private :require
39 private :gem_original_require
40
41 end
fd92455 Gavin Sinclair * lib/rubygems/custom_require.rb: new file to replace
gsinclair authored
42
Something went wrong with that request. Please try again.