Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Moved lots of stuff from rubygems.rb. (steveklabnik)
- Loading branch information
Showing
6 changed files
with
123 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This file contains all sorts of little compatability 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 | ||
QUICKLOADER_SUCKAGE = RUBY_VERSION =~ /^1\.9\.1/ | ||
GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/ | ||
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 | ||
] | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,73 @@ | ||
class Gem::ErrorReason; end # TODO: remove, unnecessary superclass | ||
|
||
# TODO move to lib/rubygems/platform_mismatch.rb | ||
# TODO write tests | ||
#-- | ||
# Generated when a gem is found that isn't usable on the current platform. | ||
## | ||
# This file contains all the various exceptions and other errors that are used | ||
# inside of RubyGems. | ||
# | ||
class Gem::PlatformMismatch < Gem::ErrorReason | ||
# DOC: Confirm _all_ | ||
|
||
attr_reader :name | ||
attr_reader :version | ||
attr_reader :platforms | ||
module Gem | ||
## | ||
# Raised when RubyGems is unable to load or activate a gem. Contains the | ||
# name and version requirements of the gem that either conflicts with | ||
# already activated gems or that RubyGems is otherwise unable to activate. | ||
|
||
def initialize(name, version) | ||
@name = name | ||
@version = version | ||
@platforms = [] | ||
end | ||
class LoadError < ::LoadError | ||
# Name of gem | ||
attr_accessor :name | ||
|
||
def add_platform(platform) | ||
@platforms << platform | ||
# Version requirement of gem | ||
attr_accessor :requirement | ||
end | ||
|
||
#-- | ||
# Replace only "platforms", remove duplicate strings | ||
def wordy | ||
prefix = "Found #{@name} (#{@version})" | ||
# FIX: does this need to exist? The subclass is the only other reference | ||
# I can find. | ||
class ErrorReason; end | ||
|
||
# Generated when trying to lookup a gem to indicate that the gem | ||
# was found, but that it isn't usable on the current platform. | ||
# | ||
# fetch and install read these and report them to the user to aid | ||
# in figuring out why a gem couldn't be installed. | ||
# | ||
class PlatformMismatch < ErrorReason | ||
|
||
## | ||
# the name of the gem | ||
attr_reader :name | ||
|
||
## | ||
# the version | ||
attr_reader :version | ||
|
||
## | ||
# The platforms that are mismatched | ||
attr_reader :platforms | ||
|
||
if @platforms.size == 1 | ||
"#{prefix}, but was for platform #{@platforms[0]}" | ||
else | ||
"#{prefix}, but was for platforms #{@platforms.join(' ,')}" | ||
def initialize(name, version) | ||
@name = name | ||
@version = version | ||
@platforms = [] | ||
end | ||
|
||
## | ||
# append a platform to the list of mismatched platforms. | ||
# | ||
# Platforms are added via this instead of injected via the constructor | ||
# so that we can loop over a list of mismatches and just add them rather | ||
# than perform some kind of calculation mismatch summary before creation. | ||
def add_platform(platform) | ||
@platforms << platform | ||
end | ||
end | ||
|
||
## | ||
# A wordy description of the error. | ||
def wordy | ||
prefix = "Found #{@name} (#{@version})" | ||
|
||
"Found %s (%), but was for platform%s %s" % | ||
[@name, | ||
@version, | ||
@platforms.size == 1 ? 's' : '', | ||
@platforms.join(' ,')] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters