Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ Moved lots of stuff from rubygems.rb. (steveklabnik)

  • Loading branch information...
commit 3714bed078894b450e7dc3163108c8b528ca4ee8 1 parent 9c892e7
@zenspider zenspider authored
View
1  Manifest.txt
@@ -48,6 +48,7 @@ lib/rubygems/commands/uninstall_command.rb
lib/rubygems/commands/unpack_command.rb
lib/rubygems/commands/update_command.rb
lib/rubygems/commands/which_command.rb
+lib/rubygems/compatability.rb
lib/rubygems/config_file.rb
lib/rubygems/custom_require.rb
lib/rubygems/defaults.rb
View
81 lib/rubygems.rb
@@ -95,87 +95,20 @@
#
# -The RubyGems Team
-# 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.
-#
-# REFACTOR: Pulling this kind of thing out into some sort of file with
-# all of the hacks would be a Good Idea.
-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
-
-require 'rubygems/defaults'
require 'rbconfig'
-require "rubygems/deprecate"
-
module Gem
VERSION = '1.8.10'
- DEFAULT_HOST = "https://rubygems.org"
-
- ##
- # 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.
-
- class LoadError < ::LoadError
- # Name of gem
- attr_accessor :name
-
- # Version requirement of gem
- attr_accessor :requirement
- end
-
- # REFACTOR: Things like stopdoc tend to indicate that something might not
- # be particularly well factored, and in this case, this is true. We're
- # sort of patching over weirdness with RbConfig. This should be pulled
- # out into some sort of file with all the compatibility hacks in it.
-
- # :stopdoc:
-
- 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
+end
- RubyGemsPackageVersion = VERSION
+require 'rubygems/defaults'
+require 'rubygems/deprecate'
+require 'rubygems/compatability'
+require 'rubygems/errors'
+module Gem
RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__)
-
- # :startdoc:
-
+
##
# An Array of Regexps that match windows ruby platforms.
View
50 lib/rubygems/compatability.rb
@@ -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
View
3  lib/rubygems/defaults.rb
@@ -1,6 +1,5 @@
module Gem
-
- # TODO: move this whole file back into rubygems.rb
+ DEFAULT_HOST = "https://rubygems.org"
@post_install_hooks ||= []
@done_installing_hooks ||= []
View
89 lib/rubygems/errors.rb
@@ -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
View
2  lib/rubygems/test_case.rb
@@ -18,7 +18,7 @@
gem 'json'
end
-require "rubygems/deprecate"
+require 'rubygems/deprecate'
require 'minitest/autorun'
require 'fileutils'
require 'tmpdir'
Please sign in to comment.
Something went wrong with that request. Please try again.