summaryrefslogtreecommitdiff
path: root/lib/rubygems/compatibility.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 06:52:18 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 06:52:18 +0000
commit9694bb8cac12969300692dac5a1cf7aa4e3a46cd (patch)
treec3cb423d701f7049ba9382de052e2a937cd1302d /lib/rubygems/compatibility.rb
parent3f606b7063fc7a8b191556365ad343a314719a8d (diff)
* lib/rubygems*: Updated to RubyGems 2.0
* test/rubygems*: ditto. * common.mk (prelude): Updated for RubyGems 2.0 source rearrangement. * tool/change_maker.rb: Allow invalid UTF-8 characters in source files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/compatibility.rb')
-rw-r--r--lib/rubygems/compatibility.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb
new file mode 100644
index 0000000000..1137407bc5
--- /dev/null
+++ b/lib/rubygems/compatibility.rb
@@ -0,0 +1,51 @@
+# This file contains all sorts of little compatibility hacks that we've
+# had to introduce over the years. Quarantining them into one file helps
+# us know when we can get rid of them.
+
+# Ruby 1.9.x has introduced some things that are awkward, and we need to
+# support them, so we define some constants to use later.
+module Gem
+ # Only MRI 1.9.2 has the custom prelude.
+ GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/ and RUBY_ENGINE == "ruby"
+end
+
+# Gem::QuickLoader exists in the gem prelude code in ruby 1.9.2 itself.
+# We gotta get rid of it if it's there, before we do anything else.
+if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
+ Gem::QuickLoader.remove
+
+ $LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library
+
+ if $LOADED_FEATURES.any? do |path| path.end_with? '/rubygems.rb' end then
+ # TODO path does not exist here
+ raise LoadError, "another rubygems is already loaded from #{path}"
+ end
+
+ class << Gem
+ remove_method :try_activate if Gem.respond_to?(:try_activate, true)
+ end
+end
+
+module Gem
+ RubyGemsVersion = VERSION
+
+ RbConfigPriorities = %w[
+ EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
+ ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
+ rubylibdir
+ ]
+
+ unless defined?(ConfigMap)
+ ##
+ # Configuration settings from ::RbConfig
+ ConfigMap = Hash.new do |cm, key|
+ cm[key] = RbConfig::CONFIG[key.to_s]
+ end
+ else
+ RbConfigPriorities.each do |key|
+ ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
+ end
+ end
+
+ RubyGemsPackageVersion = VERSION
+end