Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Kernel #:nodoc:all
- alias :fastlib_original_require :require
- #
- # Store the CWD when were initially loaded
- # required for resolving relative paths
- #
- @@fastlib_base_cwd = ::Dir.pwd
- #
- # This method hooks the original Kernel.require to support
- # loading files within FASTLIB archives
- #
- def require(name)
- fastlib_require(name) || fastlib_original_require(name)
- end
- #
- # This method handles the loading of FASTLIB archives
- #
- def fastlib_require(name)
- name = name + ".rb" if not name =~ /\.rb$/
- return false if fastlib_already_loaded?(name)
- return false if fastlib_already_tried?(name)
- # XXX Implement relative search paths within archives
- $:.map{ |path|
- (path =~ /^([A-Za-z]\:|\/)/ ) ? path : ::File.expand_path( ::File.join(@@fastlib_base_cwd, path) )
- }.map{ |path| ::Dir["#{path}/*.fastlib"] }.flatten.uniq.each do |lib|
- data = FastLib.load(lib, name)
- next if not data
- $" << name
- Object.class_eval(data, lib + "::" + name)
- return true
- end
- $fastlib_miss << name
- false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement