Sha256: a5d31f4fb4788ad356c4e7078aae060f09812640c3acf454a5715ae657083de8

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module Gem
    module QuickLoader
      module PreludeRequire
        def require_prelude lib          
          begin
            require_pre_prelude lib
          rescue ::LoadError => e
            if Gem.push_all_gems_that_might_match_and_reload_files(lib, e)
              require_pre_prelude lib
            else
              # re-raise
              raise e
            end
          end
        end
      end
      
      def push_all_gems_that_might_match_and_reload_files lib, error
        sub_lib = lib.gsub("\\", '/').split('/')[-1].split('.')[0]
        success = false
        raise if ALL_CACHES.empty? # should never be empty...
        ALL_CACHES.each{|path, gem_list|
          for gem_name, long_file_list in gem_list 
            if idx = long_file_list.index(sub_lib)
              puts 'activating' + gem_name + sub_lib.to_s if $DEBUG
              if gem(gem_name)
                puts 'gem activated ' + gem_name + ' ' + sub_lib + ' ' + long_file_list[idx] if $VERBOSE || $DEBUG
                success = true
              end
              puts 'done activeating' + gem_name + sub_lib if $DEBUG
            end
            
          end
        }
        success
      end
      
    end
  end
  
  module Kernel
    include Gem::QuickLoader::PreludeRequire
    alias :require_pre_prelude :require
    alias :require :require_prelude
  end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faster_rubygems-0.9.2 lib/faster_rubygems/prelude_cached_load.rb