Sha256: 80bb28b4fbcfce586a63c6936aac9b63a5a234e7bf2f537b0e38f9b85589b371

Contents?: true

Size: 1.66 KB

Versions: 30

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true
# :stopdoc:

#--
# 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 path = $LOADED_FEATURES.find {|n| n.end_with? '/rubygems.rb'} then
    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

  # TODO remove at RubyGems 3

  RbConfigPriorities = %w[
    MAJOR
    MINOR
    TEENY
    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| # TODO remove at RubyGems 3
      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

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
rubygems-update-2.7.11 lib/rubygems/compatibility.rb
rubygems-update-2.7.10 lib/rubygems/compatibility.rb
rubygems-update-2.7.9 lib/rubygems/compatibility.rb
rubygems-update-2.7.8 lib/rubygems/compatibility.rb
rubygems-update-2.7.7 lib/rubygems/compatibility.rb
rubygems-update-2.7.6 lib/rubygems/compatibility.rb
rubygems-update-2.7.5 lib/rubygems/compatibility.rb
rubygems-update-2.7.4 lib/rubygems/compatibility.rb
rubygems-update-2.7.4.pre1 lib/rubygems/compatibility.rb
rubygems-update-2.7.3 lib/rubygems/compatibility.rb
rubygems-update-2.7.2 lib/rubygems/compatibility.rb
rubygems-update-2.7.1 lib/rubygems/compatibility.rb
rubygems-update-2.7.0 lib/rubygems/compatibility.rb
rubygems-update-2.6.14 lib/rubygems/compatibility.rb
rubygems-update-2.6.13 lib/rubygems/compatibility.rb
rubygems-update-2.6.12 lib/rubygems/compatibility.rb
rubygems-update-2.6.11 lib/rubygems/compatibility.rb
rubygems-update-2.6.10 lib/rubygems/compatibility.rb
rubygems-update-2.6.9 lib/rubygems/compatibility.rb
ruby-compiler-0.1.1 vendor/ruby/lib/rubygems/compatibility.rb