Skip to content

Commit

Permalink
Upgrade to RubyGems 1.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Phoenix committed Sep 21, 2010
1 parent f36415c commit be8e5da
Show file tree
Hide file tree
Showing 31 changed files with 323 additions and 168 deletions.
4 changes: 2 additions & 2 deletions lib/bin/gem.rb
Expand Up @@ -9,10 +9,10 @@
require 'rubygems/gem_runner'
require 'rubygems/exceptions'

required_version = Gem::Requirement.new "> 1.8.3"
required_version = Gem::Requirement.new ">= 1.8.6"

unless required_version.satisfied_by? Gem.ruby_version then
abort "Expected Ruby Version #{required_version}, was #{Gem.ruby_version}"
abort "Expected Ruby Version #{required_version}, is #{Gem.ruby_version}"
end

args = ARGV.clone
Expand Down
68 changes: 43 additions & 25 deletions lib/rubygems.rb
Expand Up @@ -5,6 +5,8 @@
# See LICENSE.txt for permissions.
#++

gem_disabled = !defined? Gem

require 'rubygems/defaults'
require 'thread'
require 'etc'
Expand Down Expand Up @@ -98,7 +100,7 @@
# -The RubyGems Team

module Gem
RubyGemsVersion = VERSION = '1.3.6'
RubyGemsVersion = VERSION = '1.3.7'

##
# Raised when RubyGems is unable to load or activate a gem. Contains the
Expand Down Expand Up @@ -144,7 +146,7 @@ class LoadError < ::LoadError
# :stopdoc:
MUTEX = Mutex.new

RubyGemsPackageVersion = RubyGemsVersion
RubyGemsPackageVersion = VERSION
# :startdoc:

##
Expand Down Expand Up @@ -254,8 +256,6 @@ def self.activate(gem, *version_requirements)
File.join spec.full_gem_path, path
end

sitelibdir = ConfigMap[:sitelibdir]

# gem directories must come after -I and ENV['RUBYLIB']
insert_index = load_path_insert_index

Expand Down Expand Up @@ -312,8 +312,8 @@ def self.available?(gem, *requirements)
##
# Find the full path to the executable for gem +name+. If the +exec_name+
# is not given, the gem's default_executable is chosen, otherwise the
# specifed executable's path is returned. +version_requirements+ allows you
# to specify specific gem versions.
# specified executable's path is returned. +version_requirements+ allows
# you to specify specific gem versions.

def self.bin_path(name, exec_name = nil, *version_requirements)
version_requirements = Gem::Requirement.default if
Expand Down Expand Up @@ -342,7 +342,7 @@ def self.bin_path(name, exec_name = nil, *version_requirements)
# The mode needed to read a file as straight binary.

def self.binary_mode
@binary_mode ||= RUBY_VERSION > '1.9' ? 'rb:ascii-8bit' : 'rb'
'rb'
end

##
Expand Down Expand Up @@ -976,6 +976,28 @@ def self.win_platform?
@@win_platform
end

##
# Find all 'rubygems_plugin' files and load them

def self.load_plugins
plugins = Gem.find_files 'rubygems_plugin'

plugins.each do |plugin|

# Skip older versions of the GemCutter plugin: Its commands are in
# RubyGems proper now.

next if plugin =~ /gemcutter-0\.[0-3]/

begin
load plugin
rescue ::Exception => e
details = "#{plugin.inspect}: #{e.message} (#{e.class})"
warn "Error loading RubyGems plugin #{details}"
end
end
end

class << self

##
Expand Down Expand Up @@ -1085,38 +1107,34 @@ def RbConfig.datadir(package_name)
require 'rubygems/builder' # HACK: Needed for rake's package task.

begin
##
# Defaults the operating system (or packager) wants to provide for RubyGems.

require 'rubygems/defaults/operating_system'
rescue LoadError
end

if defined?(RUBY_ENGINE) then
begin
##
# Defaults the ruby implementation wants to provide for RubyGems

require "rubygems/defaults/#{RUBY_ENGINE}"
rescue LoadError
end
end

require 'rubygems/config_file'

if RUBY_VERSION < '1.9' then
require 'rubygems/custom_require'
end

Gem.clear_paths

plugins = Gem.find_files 'rubygems_plugin'

plugins.each do |plugin|
##
# Enables the require hook for RubyGems.
#
# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem
# constant at rubygems.rb load time.

# Skip older versions of the GemCutter plugin: Its commands are in
# RubyGems proper now.
require 'rubygems/custom_require' if gem_disabled or RUBY_VERSION < '1.9'

next if plugin =~ /gemcutter-0\.[0-3]/
Gem.clear_paths

begin
load plugin
rescue => e
warn "error loading #{plugin.inspect}: #{e.message} (#{e.class})"
end
end
Gem.load_plugins

2 changes: 2 additions & 0 deletions lib/rubygems/builder.rb
Expand Up @@ -4,6 +4,8 @@
# See LICENSE.txt for permissions.
#++

require 'rubygems/user_interaction'

##
# The Builder class processes RubyGem specification files
# to produce a .gem file.
Expand Down
12 changes: 12 additions & 0 deletions lib/rubygems/command.rb
Expand Up @@ -145,6 +145,18 @@ def execute
raise Gem::Exception, "generic command has no actions"
end

##
#
# Display to the user that a gem couldn't be found and reasons why
def show_lookup_failure(gem_name, version, errors=nil)
if errors and !errors.empty?
alert_error "Could not find a valid gem '#{gem_name}' (#{version}), here is why:"
errors.each { |x| say " #{x.wordy}" }
else
alert_error "Could not find a valid gem '#{gem_name}' (#{version}) in any repository"
end
end

##
# Get all gem names from the command line.

Expand Down
22 changes: 13 additions & 9 deletions lib/rubygems/command_manager.rb
Expand Up @@ -75,10 +75,10 @@ def initialize
end

##
# Register the command object.
# Register the Symbol +command+ as a gem command.

def register_command(command_obj)
@commands[command_obj] = false
def register_command(command)
@commands[command] = false
end

##
Expand Down Expand Up @@ -123,7 +123,7 @@ def process_args(args)
say Gem::Command::HELP
terminate_interaction(0)
when '-v', '--version'
say Gem::RubyGemsVersion
say Gem::VERSION
terminate_interaction(0)
when /^-/
alert_error "Invalid option: #{args[0]}. See 'gem --help'."
Expand Down Expand Up @@ -163,13 +163,17 @@ def load_and_instantiate(command_name)
begin
commands.const_get const_name
rescue NameError
if retried then
raise
else
retried = true
raise if retried

retried = true
begin
require "rubygems/commands/#{command_name}_command"
retry
rescue Exception => e
alert_error "Loading command: #{command_name} (#{e.class})\n #{e}"
ui.errs.puts "\t#{e.backtrace.join "\n\t"}" if
Gem.configuration.backtrace
end
retry
end.new
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/commands/contents_command.rb
Expand Up @@ -7,7 +7,7 @@ class Gem::Commands::ContentsCommand < Gem::Command

def initialize
super 'contents', 'Display the contents of the installed gems',
:specdirs => [], :lib_only => false
:specdirs => [], :lib_only => false, :prefix => true

add_version_option

Expand Down
4 changes: 3 additions & 1 deletion lib/rubygems/commands/dependency_command.rb
Expand Up @@ -159,7 +159,9 @@ def print_dependencies(spec, level = 0)
response
end

# Retuns list of [specification, dep] that are satisfied by spec.
##
# Returns an Array of [specification, dep] that are satisfied by +spec+.

def find_reverse_dependencies(spec)
result = []

Expand Down
5 changes: 3 additions & 2 deletions lib/rubygems/commands/environment_command.rb
Expand Up @@ -69,7 +69,7 @@ def execute
when /^packageversion/ then
out << Gem::RubyGemsPackageVersion
when /^version/ then
out << Gem::RubyGemsVersion
out << Gem::VERSION
when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
out << Gem.dir
when /^gempath/, /^path/, /^GEM_PATH/ then
Expand All @@ -79,7 +79,7 @@ def execute
when nil then
out = "RubyGems Environment:\n"

out << " - RUBYGEMS VERSION: #{Gem::RubyGemsVersion}\n"
out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n"

out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
Expand Down Expand Up @@ -109,6 +109,7 @@ def execute

out << " - GEM CONFIGURATION:\n"
Gem.configuration.each do |name, value|
value = value.gsub(/./, '*') if name == 'gemcutter_key'
out << " - #{name.inspect} => #{value.inspect}\n"
end

Expand Down
10 changes: 7 additions & 3 deletions lib/rubygems/commands/fetch_command.rb
Expand Up @@ -34,21 +34,25 @@ def usage # :nodoc:

def execute
version = options[:version] || Gem::Requirement.default
all = Gem::Requirement.default
all = Gem::Requirement.default != version

gem_names = get_all_gem_names

gem_names.each do |gem_name|
dep = Gem::Dependency.new gem_name, version
dep.prerelease = options[:prerelease]

specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, false, true,
specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, all, true,
dep.prerelease?)

specs_and_sources, errors =
Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
dep.prerelease?)

spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last

if spec.nil? then
alert_error "Could not find #{gem_name} in any repository"
show_lookup_failure gem_name, version, errors
next
end

Expand Down
3 changes: 2 additions & 1 deletion lib/rubygems/commands/install_command.rb
Expand Up @@ -127,7 +127,8 @@ def execute
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
rescue Gem::GemNotFoundException => e
alert_error e.message
show_lookup_failure e.name, e.version, e.errors

exit_code |= 2
end
end
Expand Down
19 changes: 16 additions & 3 deletions lib/rubygems/commands/query_command.rb
Expand Up @@ -21,7 +21,7 @@ def initialize(name = 'query',
options[:installed] = value
end

add_version_option
add_version_option command, "for use with --installed"

add_option('-n', '--name-matches REGEXP',
'Name of gem(s) to query on matches the',
Expand Down Expand Up @@ -185,8 +185,21 @@ def output_query_results(spec_tuples)
entry = gem_name.dup

if options[:versions] then
versions = matching_tuples.map { |(name, version,_),_| version }.uniq
entry << " (#{versions.join ', '})"
list = if platforms.empty? or options[:details] then
matching_tuples.map { |(name, version,_),_| version }.uniq
else
platforms.sort.reverse.map do |version, pls|
if pls == [Gem::Platform::RUBY] then
version
else
ruby = pls.delete Gem::Platform::RUBY
platform_list = [ruby, *pls.sort].compact
"#{version} #{platform_list.join ' '}"
end
end
end.join ', '

entry << " (#{list})"
end

if options[:details] then
Expand Down
8 changes: 5 additions & 3 deletions lib/rubygems/commands/server_command.rb
Expand Up @@ -5,7 +5,7 @@ class Gem::Commands::ServerCommand < Gem::Command

def initialize
super 'server', 'Documentation and gem repository HTTP server',
:port => 8808, :gemdir => Gem.dir, :daemon => false
:port => 8808, :gemdir => [], :daemon => false

OptionParser.accept :Port do |port|
if port =~ /\A\d+\z/ then
Expand All @@ -29,8 +29,9 @@ def initialize
end

add_option '-d', '--dir=GEMDIR',
'directory from which to serve gems' do |gemdir, options|
options[:gemdir] = File.expand_path gemdir
'directories from which to serve gems',
'multiple directories may be provided' do |gemdir, options|
options[:gemdir] << File.expand_path(gemdir)
end

add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
Expand Down Expand Up @@ -69,6 +70,7 @@ def description # :nodoc:
end

def execute
options[:gemdir] << Gem.dir if options[:gemdir].empty?
Gem::Server.run options
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/commands/setup_command.rb
Expand Up @@ -231,7 +231,7 @@ def install_lib(lib_dir)

def install_rdoc
gem_doc_dir = File.join Gem.dir, 'doc'
rubygems_name = "rubygems-#{Gem::RubyGemsVersion}"
rubygems_name = "rubygems-#{Gem::VERSION}"
rubygems_doc_dir = File.join gem_doc_dir, rubygems_name

if File.writable? gem_doc_dir and
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/commands/update_command.rb
Expand Up @@ -56,7 +56,7 @@ def execute

rubygems_update = Gem::Specification.new
rubygems_update.name = 'rubygems-update'
rubygems_update.version = Gem::Version.new Gem::RubyGemsVersion
rubygems_update.version = Gem::Version.new Gem::VERSION
hig['rubygems-update'] = rubygems_update

options[:user_install] = false
Expand Down

0 comments on commit be8e5da

Please sign in to comment.