1# :stopdoc: 2 3#-- 4# This file contains all sorts of little compatibility hacks that we've 5# had to introduce over the years. Quarantining them into one file helps 6# us know when we can get rid of them. 7# 8# Ruby 1.9.x has introduced some things that are awkward, and we need to 9# support them, so we define some constants to use later. 10#++ 11module Gem 12 # Only MRI 1.9.2 has the custom prelude. 13 GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/ and RUBY_ENGINE == "ruby" 14end 15 16# Gem::QuickLoader exists in the gem prelude code in ruby 1.9.2 itself. 17# We gotta get rid of it if it's there, before we do anything else. 18if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then 19 Gem::QuickLoader.remove 20 21 $LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library 22 23 if $LOADED_FEATURES.any? do |path| path.end_with? '/rubygems.rb' end then 24 # TODO path does not exist here 25 raise LoadError, "another rubygems is already loaded from #{path}" 26 end 27 28 class << Gem 29 remove_method :try_activate if Gem.respond_to?(:try_activate, true) 30 end 31end 32 33module Gem 34 RubyGemsVersion = VERSION 35 36 RbConfigPriorities = %w[ 37 EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name 38 ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir 39 rubylibdir 40 ] 41 42 unless defined?(ConfigMap) 43 ## 44 # Configuration settings from ::RbConfig 45 ConfigMap = Hash.new do |cm, key| 46 cm[key] = RbConfig::CONFIG[key.to_s] 47 end 48 else 49 RbConfigPriorities.each do |key| 50 ConfigMap[key.to_sym] = RbConfig::CONFIG[key] 51 end 52 end 53 54 RubyGemsPackageVersion = VERSION 55end 56