[macruby-changes] [3888] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 29 13:39:29 PDT 2010


Revision: 3888
          http://trac.macosforge.org/projects/ruby/changeset/3888
Author:   martinlagardette at apple.com
Date:     2010-03-29 13:39:29 -0700 (Mon, 29 Mar 2010)
Log Message:
-----------
Update to RubyGems 1.3.6

Modified Paths:
--------------
    MacRuby/trunk/bin/gem
    MacRuby/trunk/lib/rubygems/builder.rb
    MacRuby/trunk/lib/rubygems/command.rb
    MacRuby/trunk/lib/rubygems/command_manager.rb
    MacRuby/trunk/lib/rubygems/commands/dependency_command.rb
    MacRuby/trunk/lib/rubygems/commands/environment_command.rb
    MacRuby/trunk/lib/rubygems/commands/fetch_command.rb
    MacRuby/trunk/lib/rubygems/commands/install_command.rb
    MacRuby/trunk/lib/rubygems/commands/mirror_command.rb
    MacRuby/trunk/lib/rubygems/commands/pristine_command.rb
    MacRuby/trunk/lib/rubygems/commands/query_command.rb
    MacRuby/trunk/lib/rubygems/commands/rdoc_command.rb
    MacRuby/trunk/lib/rubygems/commands/server_command.rb
    MacRuby/trunk/lib/rubygems/commands/setup_command.rb
    MacRuby/trunk/lib/rubygems/commands/unpack_command.rb
    MacRuby/trunk/lib/rubygems/commands/update_command.rb
    MacRuby/trunk/lib/rubygems/commands/which_command.rb
    MacRuby/trunk/lib/rubygems/config_file.rb
    MacRuby/trunk/lib/rubygems/defaults.rb
    MacRuby/trunk/lib/rubygems/dependency.rb
    MacRuby/trunk/lib/rubygems/dependency_installer.rb
    MacRuby/trunk/lib/rubygems/dependency_list.rb
    MacRuby/trunk/lib/rubygems/doc_manager.rb
    MacRuby/trunk/lib/rubygems/format.rb
    MacRuby/trunk/lib/rubygems/gem_openssl.rb
    MacRuby/trunk/lib/rubygems/gem_path_searcher.rb
    MacRuby/trunk/lib/rubygems/indexer.rb
    MacRuby/trunk/lib/rubygems/install_update_options.rb
    MacRuby/trunk/lib/rubygems/installer.rb
    MacRuby/trunk/lib/rubygems/local_remote_options.rb
    MacRuby/trunk/lib/rubygems/package/tar_input.rb
    MacRuby/trunk/lib/rubygems/package.rb
    MacRuby/trunk/lib/rubygems/package_task.rb
    MacRuby/trunk/lib/rubygems/remote_fetcher.rb
    MacRuby/trunk/lib/rubygems/requirement.rb
    MacRuby/trunk/lib/rubygems/server.rb
    MacRuby/trunk/lib/rubygems/source_index.rb
    MacRuby/trunk/lib/rubygems/spec_fetcher.rb
    MacRuby/trunk/lib/rubygems/specification.rb
    MacRuby/trunk/lib/rubygems/test_utilities.rb
    MacRuby/trunk/lib/rubygems/uninstaller.rb
    MacRuby/trunk/lib/rubygems/user_interaction.rb
    MacRuby/trunk/lib/rubygems/validator.rb
    MacRuby/trunk/lib/rubygems/version.rb
    MacRuby/trunk/lib/rubygems/version_option.rb
    MacRuby/trunk/lib/rubygems.rb

Added Paths:
-----------
    MacRuby/trunk/lib/rubygems/commands/owner_command.rb
    MacRuby/trunk/lib/rubygems/commands/push_command.rb

Removed Paths:
-------------
    MacRuby/trunk/lib/rubygems/digest/
    MacRuby/trunk/lib/rubygems/indexer/
    MacRuby/trunk/lib/rubygems/timer.rb

Modified: MacRuby/trunk/bin/gem
===================================================================
--- MacRuby/trunk/bin/gem	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/bin/gem	2010-03-29 20:39:29 UTC (rev 3888)
@@ -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

Modified: MacRuby/trunk/lib/rubygems/builder.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/builder.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/builder.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -11,6 +11,7 @@
 class Gem::Builder
 
   include Gem::UserInteraction
+
   ##
   # Constructs a builder instance for the provided specification
   #
@@ -33,7 +34,7 @@
     @spec.validate
     @signer = sign
     write_package
-    say success
+    say success if Gem.configuration.verbose
     @spec.file_name
   end
 
@@ -42,7 +43,7 @@
   Successfully built RubyGem
   Name: #{@spec.name}
   Version: #{@spec.version}
-  File: #{@spec.full_name+'.gem'}
+  File: #{@spec.file_name}
 EOM
   end
 
@@ -86,5 +87,6 @@
       end
     end
   end
+
 end
 

Modified: MacRuby/trunk/lib/rubygems/command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -49,7 +49,7 @@
   def self.build_args
     @build_args ||= []
   end
-  
+
   def self.build_args=(value)
     @build_args = value
   end
@@ -160,8 +160,8 @@
   end
 
   ##
-  # Get the single gem name from the command line.  Fail if there is no gem
-  # name or if there is more than one gem name given.
+  # Get a single gem name from the command line.  Fail if there is no gem name
+  # or if there is more than one gem name given.
 
   def get_one_gem_name
     args = options[:args]
@@ -197,7 +197,7 @@
   #   def usage
   #     "#{program_name} FILE [FILE ...]"
   #   end
-  #   
+  #
   #   def arguments
   #     "FILE          name of file to find"
   #   end
@@ -248,11 +248,12 @@
   # Invoke the command with the given list of arguments.
 
   def invoke(*args)
-    handle_options(args)
-    if options[:help]
+    handle_options args
+
+    if options[:help] then
       show_help
-    elsif @when_invoked
-      @when_invoked.call(options)
+    elsif @when_invoked then
+      @when_invoked.call options
     else
       execute
     end
@@ -362,37 +363,39 @@
   def create_option_parser
     @parser = OptionParser.new
 
-    @parser.separator("")
+    @parser.separator nil
     regular_options = @option_groups.delete :options
 
     configure_options "", regular_options
 
     @option_groups.sort_by { |n,_| n.to_s }.each do |group_name, option_list|
+      @parser.separator nil
       configure_options group_name, option_list
     end
 
+    @parser.separator nil
     configure_options "Common", Gem::Command.common_options
 
-    @parser.separator("")
     unless arguments.empty?
-      @parser.separator("  Arguments:")
+      @parser.separator nil
+      @parser.separator "  Arguments:"
       arguments.split(/\n/).each do |arg_desc|
-        @parser.separator("    #{arg_desc}")
+        @parser.separator "    #{arg_desc}"
       end
-      @parser.separator("")
     end
 
-    @parser.separator("  Summary:")
+    @parser.separator nil
+    @parser.separator "  Summary:"
     wrap(@summary, 80 - 4).split("\n").each do |line|
-      @parser.separator("    #{line.strip}")
+      @parser.separator "    #{line.strip}"
     end
 
     if description then
       formatted = description.split("\n\n").map do |chunk|
-        wrap(chunk, 80 - 4)
-      end.join("\n")
+        wrap chunk, 80 - 4
+      end.join "\n"
 
-      @parser.separator ""
+      @parser.separator nil
       @parser.separator "  Description:"
       formatted.split("\n").each do |line|
         @parser.separator "    #{line.rstrip}"
@@ -400,10 +403,10 @@
     end
 
     unless defaults_str.empty?
-      @parser.separator("")
-      @parser.separator("  Defaults:")
+      @parser.separator nil
+      @parser.separator "  Defaults:"
       defaults_str.split(/\n/).each do |line|
-        @parser.separator("    #{line}")
+        @parser.separator "    #{line}"
       end
     end
   end
@@ -471,33 +474,33 @@
 
   # :stopdoc:
 
-  HELP = %{
-    RubyGems is a sophisticated package manager for Ruby.  This is a
-    basic help message containing pointers to more information.
+  HELP = <<-HELP
+RubyGems is a sophisticated package manager for Ruby.  This is a
+basic help message containing pointers to more information.
 
-      Usage:
-        gem -h/--help
-        gem -v/--version
-        gem command [arguments...] [options...]
+  Usage:
+    gem -h/--help
+    gem -v/--version
+    gem command [arguments...] [options...]
 
-      Examples:
-        gem install rake
-        gem list --local
-        gem build package.gemspec
-        gem help install
+  Examples:
+    gem install rake
+    gem list --local
+    gem build package.gemspec
+    gem help install
 
-      Further help:
-        gem help commands            list all 'gem' commands
-        gem help examples            show some examples of usage
-        gem help platforms           show information about platforms
-        gem help <COMMAND>           show help on COMMAND
-                                       (e.g. 'gem help install')
-        gem server                   present a web page at
-                                     http://localhost:8808/
-                                     with info about installed gems
-      Further information:
-        http://rubygems.rubyforge.org
-  }.gsub(/^    /, '')
+  Further help:
+    gem help commands            list all 'gem' commands
+    gem help examples            show some examples of usage
+    gem help platforms           show information about platforms
+    gem help <COMMAND>           show help on COMMAND
+                                   (e.g. 'gem help install')
+    gem server                   present a web page at
+                                 http://localhost:8808/
+                                 with info about installed gems
+  Further information:
+    http://rubygems.rubyforge.org
+  HELP
 
   # :startdoc:
 

Modified: MacRuby/trunk/lib/rubygems/command_manager.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/command_manager.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/command_manager.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -58,7 +58,9 @@
     register_command :lock
     register_command :mirror
     register_command :outdated
+    register_command :owner
     register_command :pristine
+    register_command :push
     register_command :query
     register_command :rdoc
     register_command :search

Modified: MacRuby/trunk/lib/rubygems/commands/dependency_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/dependency_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/dependency_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -15,6 +15,7 @@
 
     add_version_option
     add_platform_option
+    add_prerelease_option
 
     add_option('-R', '--[no-]reverse-dependencies',
                'Include reverse dependencies in the output') do
@@ -59,6 +60,7 @@
               end
 
     dependency = Gem::Dependency.new pattern, options[:version]
+    dependency.prerelease = options[:prerelease]
 
     if options[:reverse_dependencies] and remote? and not local? then
       alert_error 'Only reverse dependencies for local gems are supported.'
@@ -75,7 +77,10 @@
       fetcher = Gem::SpecFetcher.fetcher
 
       begin
-        fetcher.find_matching(dependency).each do |spec_tuple, source_uri|
+        specs_and_sources = fetcher.find_matching(dependency, false, true,
+                                                  dependency.prerelease?)
+
+        specs_and_sources.each do |spec_tuple, source_uri|
           spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
 
           source_indexes[source_uri].add_spec spec
@@ -120,8 +125,8 @@
     if options[:pipe_format] then
       specs.values.sort_by { |_, spec| spec }.each do |_, spec|
         unless spec.dependencies.empty?
-          spec.dependencies.each do |dep|
-            say "#{dep.name} --version '#{dep.version_requirements}'"
+          spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
+            say "#{dep.name} --version '#{dep.requirement}'"
           end
         end
       end
@@ -147,7 +152,7 @@
     response = ''
     response << '  ' * level + "Gem #{spec.full_name}\n"
     unless spec.dependencies.empty? then
-      spec.dependencies.each do |dep|
+      spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
         response << '  ' * level + "  #{dep}\n"
       end
     end
@@ -163,7 +168,7 @@
         dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
 
         if spec.name == dep.name and
-           dep.version_requirements.satisfied_by?(spec.version) then
+           dep.requirement.satisfied_by?(spec.version) then
           result << [sp.full_name, dep]
         end
       end

Modified: MacRuby/trunk/lib/rubygems/commands/environment_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/environment_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/environment_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -118,7 +118,7 @@
       end
 
     else
-      fail Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
+      raise Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
     end
     say out
     true

Modified: MacRuby/trunk/lib/rubygems/commands/fetch_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/fetch_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/fetch_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -17,6 +17,7 @@
 
     add_version_option
     add_platform_option
+    add_prerelease_option
   end
 
   def arguments # :nodoc:
@@ -39,20 +40,20 @@
 
     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, all
+      specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, false, true,
+                                                         dep.prerelease?)
 
-      specs_and_sources.sort_by { |spec,| spec.version }
+      spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
 
-      spec, source_uri = specs_and_sources.last
-
       if spec.nil? then
         alert_error "Could not find #{gem_name} in any repository"
         next
       end
 
       path = Gem::RemoteFetcher.fetcher.download spec, source_uri
-      FileUtils.mv path, "#{spec.full_name}.gem"
+      FileUtils.mv path, spec.file_name
 
       say "Downloaded #{spec.full_name}"
     end

Modified: MacRuby/trunk/lib/rubygems/commands/install_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/install_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/install_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -32,6 +32,7 @@
     add_local_remote_options
     add_platform_option
     add_version_option
+    add_prerelease_option "to be installed. (Only for listed gems)"
   end
 
   def arguments # :nodoc:

Modified: MacRuby/trunk/lib/rubygems/commands/mirror_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/mirror_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/mirror_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -51,7 +51,7 @@
         Dir.mkdir gems_dir
       end
 
-      sourceindex_data = ''
+      source_index_data = ''
 
       say "fetching: #{get_from}/Marshal.#{Gem.marshal_version}.Z"
 
@@ -70,18 +70,18 @@
       end
 
       open File.join(get_from.to_s, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y|
-        sourceindex_data = Zlib::Inflate.inflate y.read
+        source_index_data = Zlib::Inflate.inflate y.read
         open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out|
-          out.write sourceindex_data
+          out.write source_index_data
         end
       end
 
-      sourceindex = Marshal.load(sourceindex_data)
+      source_index = Marshal.load source_index_data
 
-      progress = ui.progress_reporter sourceindex.size,
-                                      "Fetching #{sourceindex.size} gems"
-      sourceindex.each do |fullname, gem|
-        gem_file = "#{fullname}.gem"
+      progress = ui.progress_reporter source_index.size,
+                                      "Fetching #{source_index.size} gems"
+      source_index.each do |fullname, gem|
+        gem_file = gem.file_name
         gem_dest = File.join gems_dir, gem_file
 
         unless File.exist? gem_dest then

Added: MacRuby/trunk/lib/rubygems/commands/owner_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/owner_command.rb	                        (rev 0)
+++ MacRuby/trunk/lib/rubygems/commands/owner_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -0,0 +1,75 @@
+require 'rubygems/command'
+require 'rubygems/local_remote_options'
+require 'rubygems/gemcutter_utilities'
+
+class Gem::Commands::OwnerCommand < Gem::Command
+  include Gem::LocalRemoteOptions
+  include Gem::GemcutterUtilities
+
+  def description # :nodoc:
+    'Manage gem owners on RubyGems.org.'
+  end
+
+  def arguments # :nodoc:
+    "GEM       gem to manage owners for"
+  end
+
+  def initialize
+    super 'owner', description
+    add_proxy_option
+    defaults.merge! :add => [], :remove => []
+
+    add_option '-a', '--add EMAIL', 'Add an owner' do |value, options|
+      options[:add] << value
+    end
+
+    add_option '-r', '--remove EMAIL', 'Remove an owner' do |value, options|
+      options[:remove] << value
+    end
+  end
+
+  def execute
+    sign_in
+    name = get_one_gem_name
+
+    add_owners    name, options[:add]
+    remove_owners name, options[:remove]
+    show_owners   name
+  end
+
+  def show_owners name
+    response = rubygems_api_request :get, "api/v1/gems/#{name}/owners.yaml" do |request|
+      request.add_field "Authorization", Gem.configuration.rubygems_api_key
+    end
+
+    with_response response do |resp|
+      owners = YAML.load resp.body
+
+      say "Owners for gem: #{name}"
+      owners.each do |owner|
+        say "- #{owner['email']}"
+      end
+    end
+  end
+
+  def add_owners name, owners
+    manage_owners :post, name, owners
+  end
+
+  def remove_owners name, owners
+    manage_owners :delete, name, owners
+  end
+
+  def manage_owners method, name, owners
+    owners.each do |owner|
+      response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
+        request.set_form_data 'email' => owner
+        request.add_field "Authorization", Gem.configuration.rubygems_api_key
+      end
+
+      with_response response
+    end
+  end
+
+end
+

Modified: MacRuby/trunk/lib/rubygems/commands/pristine_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/pristine_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/pristine_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -74,7 +74,7 @@
     say "Restoring gem(s) to pristine condition..."
 
     specs.each do |spec|
-      gem = Dir[File.join(Gem.dir, 'cache', "#{spec.full_name}.gem")].first
+      gem = Dir[File.join(Gem.dir, 'cache', spec.file_name)].first
 
       if gem.nil? then
         alert_error "Cached gem for #{spec.full_name} not found, use `gem install` to restore"

Added: MacRuby/trunk/lib/rubygems/commands/push_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/push_command.rb	                        (rev 0)
+++ MacRuby/trunk/lib/rubygems/commands/push_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -0,0 +1,45 @@
+require 'rubygems/command'
+require 'rubygems/local_remote_options'
+require 'rubygems/gemcutter_utilities'
+
+class Gem::Commands::PushCommand < Gem::Command
+  include Gem::LocalRemoteOptions
+  include Gem::GemcutterUtilities
+
+  def description # :nodoc:
+    'Push a gem up to RubyGems.org'
+  end
+
+  def arguments # :nodoc:
+    "GEM       built gem to push up"
+  end
+
+  def usage # :nodoc:
+    "#{program_name} GEM"
+  end
+
+  def initialize
+    super 'push', description
+    add_proxy_option
+  end
+
+  def execute
+    sign_in
+    send_gem get_one_gem_name
+  end
+
+  def send_gem name
+    say "Pushing gem to RubyGems.org..."
+
+    response = rubygems_api_request :post, "api/v1/gems" do |request|
+      request.body = Gem.read_binary name
+      request.add_field "Content-Length", request.body.size
+      request.add_field "Content-Type",   "application/octet-stream"
+      request.add_field "Authorization",  Gem.configuration.rubygems_api_key
+    end
+
+    with_response response
+  end
+
+end
+

Modified: MacRuby/trunk/lib/rubygems/commands/query_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/query_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/query_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -45,7 +45,7 @@
       options[:all] = value
     end
 
-    add_option(      '--prerelease',
+    add_option(      '--[no-]prerelease',
                'Display prerelease versions') do |value, options|
       options[:prerelease] = value
     end
@@ -111,6 +111,9 @@
       begin
         fetcher = Gem::SpecFetcher.fetcher
         spec_tuples = fetcher.find_matching dep, all, false, prerelease
+
+        spec_tuples += fetcher.find_matching dep, false, false, true if
+          prerelease and all
       rescue Gem::RemoteFetcher::FetchError => e
         if prerelease then
           raise Gem::OperationNotSupportedError,

Modified: MacRuby/trunk/lib/rubygems/commands/rdoc_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/rdoc_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/rdoc_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -8,7 +8,7 @@
   def initialize
     super 'rdoc', 'Generates RDoc for pre-installed gems',
           :version => Gem::Requirement.default,
-          :include_rdoc => true, :include_ri => true
+          :include_rdoc => true, :include_ri => true, :overwrite => false
 
     add_option('--all',
                'Generate RDoc/RI documentation for all',
@@ -17,15 +17,20 @@
     end
 
     add_option('--[no-]rdoc',
-               'Include RDoc generated documents') do |value, options|
+               'Generate RDoc HTML') do |value, options|
       options[:include_rdoc] = value
     end
 
     add_option('--[no-]ri',
-               'Include RI generated documents') do |value, options|
+               'Generate RI data') do |value, options|
       options[:include_ri] = value
     end
 
+    add_option('--[no-]overwrite',
+               'Overwrite installed documents') do |value, options|
+      options[:overwrite] = value
+    end
+
     add_version_option
   end
 
@@ -34,9 +39,16 @@
   end
 
   def defaults_str # :nodoc:
-    "--version '#{Gem::Requirement.default}' --rdoc --ri"
+    "--version '#{Gem::Requirement.default}' --rdoc --ri --no-overwrite"
   end
 
+  def description # :nodoc:
+    <<-DESC
+The rdoc command builds RDoc and RI documentation for installed gems.  Use
+--overwrite to force rebuilding of documentation.
+    DESC
+  end
+
   def usage # :nodoc:
     "#{program_name} [args]"
   end
@@ -53,24 +65,27 @@
     end
 
     if specs.empty?
-      fail "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
+      raise "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
     end
 
     if options[:include_ri]
-      specs.each do |spec|
-        Gem::DocManager.new(spec).generate_ri
+      specs.sort.each do |spec|
+        doc = Gem::DocManager.new(spec)
+        doc.generate_ri if options[:overwrite] || !doc.ri_installed?
       end
 
       Gem::DocManager.update_ri_cache
     end
 
     if options[:include_rdoc]
-      specs.each do |spec|
-        Gem::DocManager.new(spec).generate_rdoc
+      specs.sort.each do |spec|
+        doc = Gem::DocManager.new(spec)
+        doc.generate_rdoc if options[:overwrite] || !doc.rdoc_installed?
       end
     end
 
     true
   end
+
 end
 

Modified: MacRuby/trunk/lib/rubygems/commands/server_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/server_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/server_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -36,6 +36,12 @@
     add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
       options[:daemon] = daemon
     end
+
+    add_option '-b', '--bind=HOST,HOST',
+               'addresses to bind', Array do |address, options|
+      options[:addresses] ||= []
+      options[:addresses].push(*address)
+    end
   end
 
   def defaults_str # :nodoc:

Modified: MacRuby/trunk/lib/rubygems/commands/setup_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/setup_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/setup_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -2,7 +2,6 @@
 require 'fileutils'
 require 'rbconfig'
 require 'tmpdir'
-require 'pathname'
 
 ##
 # Installs RubyGems itself.  This command is ordinarily only available from a
@@ -57,10 +56,10 @@
   end
 
   def check_ruby_version
-    required_version = Gem::Version.new '1.8.3'
+    required_version = Gem::Requirement.new '>= 1.8.6'
 
-    unless Gem.ruby_version > required_version then
-      alert_error "Ruby version > #{required_version} required, is #{Gem.ruby_version}"
+    unless required_version.satisfied_by? Gem.ruby_version then
+      alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
       terminate_interaction 1
     end
   end
@@ -117,6 +116,8 @@
 
     say "RubyGems #{Gem::VERSION} installed"
 
+    uninstall_old_gemcutter
+
     install_rdoc
 
     say
@@ -359,5 +360,14 @@
     r.document args
   end
 
+  def uninstall_old_gemcutter
+    require 'rubygems/uninstaller'
+
+    ui = Gem::Uninstaller.new('gemcutter', :all => true, :ignore => true,
+                              :version => '< 0.4')
+    ui.uninstall
+  rescue Gem::InstallError
+  end
+
 end
 

Modified: MacRuby/trunk/lib/rubygems/commands/unpack_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/unpack_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/unpack_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -41,7 +41,7 @@
       path = get_path name, options[:version]
 
       if path then
-        basename = File.basename(path).sub(/\.gem$/, '')
+        basename = File.basename(path, '.gem')
         target_dir = File.expand_path File.join(options[:target], basename)
         FileUtils.mkdir_p target_dir
         Gem::Installer.new(path, :unpack => true).unpack target_dir
@@ -79,7 +79,7 @@
     # We expect to find (basename).gem in the 'cache' directory.
     # Furthermore, the name match must be exact (ignoring case).
     if gemname =~ /^#{selected.name}$/i
-      filename = selected.full_name + '.gem'
+      filename = selected.file_name
       path = nil
 
       Gem.path.find do |gem_dir|

Modified: MacRuby/trunk/lib/rubygems/commands/update_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/update_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/update_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -28,8 +28,8 @@
     end
 
     add_local_remote_options
-
     add_platform_option
+    add_prerelease_option "as update targets"
   end
 
   def arguments # :nodoc:
@@ -54,7 +54,7 @@
       say "Updating RubyGems"
 
       unless options[:args].empty? then
-        fail "No gem names are allowed with the --system option"
+        raise "No gem names are allowed with the --system option"
       end
 
       rubygems_update = Gem::Specification.new

Modified: MacRuby/trunk/lib/rubygems/commands/which_command.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/commands/which_command.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/commands/which_command.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -27,13 +27,11 @@
     "--no-gems-first --no-all"
   end
 
-  def usage # :nodoc:
-    "#{program_name} FILE [FILE ...]"
-  end
-
   def execute
     searcher = Gem::GemPathSearcher.new
 
+    found = false
+
     options[:args].each do |arg|
       dirs = $LOAD_PATH
       spec = searcher.find arg
@@ -44,19 +42,19 @@
         else
           dirs = $LOAD_PATH + gem_paths(spec)
         end
-
-        say "(checking gem #{spec.full_name} for #{arg})" if
-          Gem.configuration.verbose and $stdout.tty?
       end
 
       paths = find_paths arg, dirs
 
       if paths.empty? then
-        say "Can't find ruby library file or shared library #{arg}"
+        alert_error "Can't find ruby library file or shared library #{arg}"
       else
         say paths
+        found = true
       end
     end
+
+    terminate_interaction 1 unless found
   end
 
   def find_paths(package_name, dirs)
@@ -80,7 +78,7 @@
   end
 
   def usage # :nodoc:
-    "#{program_name} FILE [...]"
+    "#{program_name} FILE [FILE ...]"
   end
 
 end

Modified: MacRuby/trunk/lib/rubygems/config_file.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/config_file.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/config_file.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -4,11 +4,27 @@
 # See LICENSE.txt for permissions.
 #++
 
-require 'yaml'
+##
+# Gem::ConfigFile RubyGems options and gem command options from ~/.gemrc.
+#
+# ~/.gemrc is a YAML file that uses strings to match gem command arguments and
+# symbols to match RubyGems options.
+#
+# Gem command arguments use a String key that matches the command name and
+# allow you to specify default arguments:
+#
+#   install: --no-rdoc --no-ri
+#   update: --no-rdoc --no-ri
+#
+# You can use <tt>gem:</tt> to set default arguments for all commands.
+#
+# RubyGems options use symbol keys.  Valid options are:
+#
+# +:backtrace+:: See #backtrace
+# +:benchmark+:: See #benchmark
+# +:sources+:: Sets Gem::sources
+# +:verbose+:: See #verbose
 
-# Store the gem command options specified in the configuration file.  The
-# config file object acts much like a hash.
-
 class Gem::ConfigFile
 
   DEFAULT_BACKTRACE = false
@@ -52,49 +68,74 @@
 
   SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
 
+  ##
   # List of arguments supplied to the config file object.
+
   attr_reader :args
 
-  # Where to look for gems
+  ##
+  # Where to look for gems (deprecated)
+
   attr_accessor :path
 
+  ##
+  # Where to install gems (deprecated)
+
   attr_accessor :home
 
+  ##
   # True if we print backtraces on errors.
+
   attr_writer :backtrace
 
+  ##
   # True if we are benchmarking this run.
+
   attr_accessor :benchmark
 
-  # Bulk threshold value.  If the number of missing gems are above
-  # this threshold value, then a bulk download technique is used.
+  ##
+  # Bulk threshold value.  If the number of missing gems are above this
+  # threshold value, then a bulk download technique is used.  (deprecated)
+
   attr_accessor :bulk_threshold
 
+  ##
   # Verbose level of output:
   # * false -- No output
   # * true -- Normal output
   # * :loud -- Extra output
+
   attr_accessor :verbose
 
+  ##
   # True if we want to update the SourceInfoCache every time, false otherwise
+
   attr_accessor :update_sources
 
+  ##
+  # API key for RubyGems.org
+
+  attr_reader :rubygems_api_key
+
+  ##
   # Create the config file object.  +args+ is the list of arguments
   # from the command line.
   #
   # The following command line options are handled early here rather
   # than later at the time most command options are processed.
   #
-  # * --config-file and --config-file==NAME -- Obviously these need
-  #   to be handled by the ConfigFile object to ensure we get the
-  #   right config file.
+  # <tt>--config-file</tt>, <tt>--config-file==NAME</tt>::
+  #   Obviously these need to be handled by the ConfigFile object to ensure we
+  #   get the right config file.
   #
-  # * --backtrace -- Backtrace needs to be turned on early so that
-  #   errors before normal option parsing can be properly handled.
+  # <tt>--backtrace</tt>::
+  #   Backtrace needs to be turned on early so that errors before normal
+  #   option parsing can be properly handled.
   #
-  # * --debug -- Enable Ruby level debug messages.  Handled early
-  #   for the same reason as --backtrace.
-  #
+  # <tt>--debug</tt>::
+  #   Enable Ruby level debug messages.  Handled early for the same reason as
+  #   --backtrace.
+
   def initialize(arg_list)
     @config_file_name = nil
     need_config_file_name = false
@@ -131,21 +172,53 @@
     @hash = @hash.merge user_config
 
     # HACK these override command-line args, which is bad
-    @backtrace = @hash[:backtrace] if @hash.key? :backtrace
-    @benchmark = @hash[:benchmark] if @hash.key? :benchmark
-    @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
+    @backtrace        = @hash[:backtrace]        if @hash.key? :backtrace
+    @benchmark        = @hash[:benchmark]        if @hash.key? :benchmark
+    @bulk_threshold   = @hash[:bulk_threshold]   if @hash.key? :bulk_threshold
+    @home             = @hash[:gemhome]          if @hash.key? :gemhome
+    @path             = @hash[:gempath]          if @hash.key? :gempath
+    @update_sources   = @hash[:update_sources]   if @hash.key? :update_sources
+    @verbose          = @hash[:verbose]          if @hash.key? :verbose
+
+    load_rubygems_api_key
+
     Gem.sources = @hash[:sources] if @hash.key? :sources
-    @verbose = @hash[:verbose] if @hash.key? :verbose
-    @update_sources = @hash[:update_sources] if @hash.key? :update_sources
-    @path = @hash[:gempath] if @hash.key? :gempath
-    @home = @hash[:gemhome] if @hash.key? :gemhome
-
     handle_arguments arg_list
   end
 
+  ##
+  # Location of RubyGems.org credentials
+
+  def credentials_path
+    File.join(Gem.user_home, '.gem', 'credentials')
+  end
+
+  def load_rubygems_api_key
+    api_key_hash = File.exists?(credentials_path) ? load_file(credentials_path) : @hash
+
+    @rubygems_api_key = api_key_hash[:rubygems_api_key] if api_key_hash.key? :rubygems_api_key
+  end
+
+  def rubygems_api_key=(api_key)
+    config = load_file(credentials_path).merge(:rubygems_api_key => api_key)
+
+    dirname = File.dirname(credentials_path)
+    Dir.mkdir(dirname) unless File.exists?(dirname)
+
+    require 'yaml'
+
+    File.open(credentials_path, 'w') do |f|
+      f.write config.to_yaml
+    end
+
+    @rubygems_api_key = api_key
+  end
+
   def load_file(filename)
+    return {} unless filename and File.exists?(filename)
     begin
-      YAML.load(File.read(filename)) if filename and File.exist?(filename)
+      require 'yaml'
+      YAML.load(File.read(filename))
     rescue ArgumentError
       warn "Failed to load #{config_file_name}"
     rescue Errno::EACCES
@@ -239,8 +312,9 @@
 
   # Writes out this config file, replacing its source.
   def write
-    File.open config_file_name, 'w' do |fp|
-      fp.write self.to_yaml
+    require 'yaml'
+    open config_file_name, 'w' do |io|
+      io.write to_yaml
     end
   end
 

Modified: MacRuby/trunk/lib/rubygems/defaults.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/defaults.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/defaults.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -9,7 +9,7 @@
   # An Array of the default sources that come with RubyGems
 
   def self.default_sources
-    %w[http://gems.rubyforge.org/]
+    %w[http://rubygems.org/]
   end
 
   ##

Modified: MacRuby/trunk/lib/rubygems/dependency.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/dependency.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/dependency.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -1,14 +1,22 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
+require "rubygems/requirement"
 
 ##
-# The Dependency class holds a Gem name and a Gem::Requirement
+# The Dependency class holds a Gem name and a Gem::Requirement.
 
 class Gem::Dependency
 
+  # :stopdoc:
+  @warned_version_requirement = false
+
+  def self.warned_version_requirement
+    @warned_version_requirement
+  end
+
+  def self.warned_version_requirement= value
+    @warned_version_requirement = value
+  end
+  # :startdoc:
+
   ##
   # Valid dependency types.
   #--
@@ -16,9 +24,9 @@
   # Gem::Specification::CURRENT_SPECIFICATION_VERSION as well.
 
   TYPES = [
-    :development,
-    :runtime,
-  ]
+           :development,
+           :runtime,
+          ]
 
   ##
   # Dependency name or regular expression.
@@ -26,122 +34,172 @@
   attr_accessor :name
 
   ##
-  # Dependency type.
+  # Allows you to force this dependency to be a prerelease.
 
-  attr_reader :type
+  attr_writer :prerelease
 
   ##
-  # Dependent versions.
+  # Dependency type.
 
-  attr_writer :version_requirements
+  attr_reader :type
 
   ##
-  # Orders dependencies by name only.
+  # Constructs a dependency with +name+ and +requirements+. The last
+  # argument can optionally be the dependency type, which defaults to
+  # <tt>:runtime</tt>.
 
-  def <=>(other)
-    [@name] <=> [other.name]
-  end
+  def initialize name, *requirements
+    type         = Symbol === requirements.last ? requirements.pop : :runtime
+    requirements = requirements.first if 1 == requirements.length # unpack
 
-  ##
-  # Constructs a dependency with +name+ and +requirements+.
-
-  def initialize(name, version_requirements, type=:runtime)
-    @name = name
-
     unless TYPES.include? type
-      raise ArgumentError, "Valid types are #{TYPES.inspect}, not #{@type.inspect}"
+      raise ArgumentError, "Valid types are #{TYPES.inspect}, "
+        + "not #{@type.inspect}"
     end
 
-    @type = type
+    @name        = name
+    @requirement = Gem::Requirement.create requirements
+    @type        = type
+    @prerelease  = false
 
-    @version_requirements = Gem::Requirement.create version_requirements
-    @version_requirement = nil   # Avoid warnings.
+    # This is for Marshal backwards compatability. See the comments in
+    # +requirement+ for the dirty details.
+
+    @version_requirements = @requirement
   end
 
-  def version_requirements
-    normalize if defined? @version_requirement and @version_requirement
-    @version_requirements
+  ##
+  # What does this dependency require?
+
+  ##
+  # A dependency's hash is the XOR of the hashes of +name+, +type+,
+  # and +requirement+.
+
+  def hash # :nodoc:
+    name.hash ^ type.hash ^ requirement.hash
   end
 
-  def requirement_list
-    version_requirements.as_list
+  def inspect # :nodoc:
+    "<%s type=%p name=%p requirements=%p>" %
+      [self.class, @type, @name, requirement.to_s]
   end
 
-  alias requirements_list requirement_list
+  ##
+  # Does this dependency require a prerelease?
 
-  def normalize
-    ver = @version_requirement.instance_variable_get :@version
-    @version_requirements = Gem::Requirement.new([ver])
-    @version_requirement = nil
+  def prerelease?
+    @prerelease || requirement.prerelease?
   end
 
-  def to_s # :nodoc:
-    "#{name} (#{version_requirements}, #{@type || :runtime})"
-  end
-
   def pretty_print(q) # :nodoc:
     q.group 1, 'Gem::Dependency.new(', ')' do
-      q.pp @name
+      q.pp name
       q.text ','
       q.breakable
 
-      q.pp @version_requirements
+      q.pp requirement
 
       q.text ','
       q.breakable
 
-      q.pp @type
+      q.pp type
     end
   end
 
-  def ==(other) # :nodoc:
-    self.class === other &&
-      self.name == other.name &&
-      self.type == other.type &&
-      self.version_requirements == other.version_requirements
+  def requirement
+    return @requirement if defined?(@requirement) and @requirement
+
+    # @version_requirements and @version_requirement are legacy ivar
+    # names, and supported here because older gems need to keep
+    # working and Dependency doesn't implement marshal_dump and
+    # marshal_load. In a happier world, this would be an
+    # attr_accessor. The horrifying instance_variable_get you see
+    # below is also the legacy of some old restructurings.
+    #
+    # Note also that because of backwards compatibility (loading new
+    # gems in an old RubyGems installation), we can't add explicit
+    # marshaling to this class until we want to make a big
+    # break. Maybe 2.0.
+    #
+    # Children, define explicit marshal and unmarshal behavior for
+    # public classes. Marshal formats are part of your public API.
+
+    if defined?(@version_requirement) && @version_requirement
+      version = @version_requirement.instance_variable_get :@version
+      @version_requirement  = nil
+      @version_requirements = Gem::Requirement.new version
+    end
+
+    @requirement = @version_requirements if defined?(@version_requirements)
   end
 
   ##
-  # Uses this dependency as a pattern to compare to +other+.  This dependency
-  # will match if the name matches the other's name, and other has only an
-  # equal version requirement that satisfies this dependency.
+  # Rails subclasses Gem::Dependency and uses this method, so we'll hack
+  # around it.
 
-  def =~(other)
-    other = if self.class === other then
-              other
-            else
-              return false unless other.respond_to? :name and
-                                  other.respond_to? :version
+  alias __requirement requirement # :nodoc:
 
-              Gem::Dependency.new other.name, other.version
-            end
+  def requirements_list
+    requirement.as_list
+  end
 
-    pattern = @name
-    pattern = /\A#{Regexp.escape @name}\Z/ unless Regexp === pattern
+  def to_s # :nodoc:
+    "#{name} (#{requirement}, #{type})"
+  end
 
-    return false unless pattern =~ other.name
+  def version_requirements # :nodoc:
+    unless Gem::Dependency.warned_version_requirement then
+      warn "#{Gem.location_of_caller.join ':'}:Warning: " \
+           "Gem::Dependency#version_requirements is deprecated " \
+           "and will be removed on or after August 2010.  " \
+           "Use #requirement"
 
-    reqs = other.version_requirements.requirements
+      Gem::Dependency.warned_version_requirement = true
+    end
 
-    return false unless reqs.length == 1
-    return false unless reqs.first.first == '='
+    __requirement
+  end
 
-    version = reqs.first.last
+  alias_method :version_requirement, :version_requirements
 
-    version_requirements.satisfied_by? version
+  def == other # :nodoc:
+    Gem::Dependency === other &&
+      self.name        == other.name &&
+      self.type        == other.type &&
+      self.requirement == other.requirement
   end
 
   ##
-  # A dependency's hash is the sum of the hash of the #name, #type and
-  # #version_requirements
+  # Dependencies are ordered by name.
 
-  def hash
-    name.hash + type.hash + version_requirements.hash
+  def <=> other
+    [@name] <=> [other.name]
   end
 
-  def inspect # :nodoc:
-    "<%s type=%p name=%p requirements=%p>" % [self.class, @type, @name,
-      version_requirements.to_s]
+  ##
+  # Uses this dependency as a pattern to compare to +other+. This
+  # dependency will match if the name matches the other's name, and
+  # other has only an equal version requirement that satisfies this
+  # dependency.
+
+  def =~ other
+    unless Gem::Dependency === other
+      other = Gem::Dependency.new other.name, other.version rescue return false
+    end
+
+    pattern = name
+    pattern = /\A#{Regexp.escape pattern}\Z/ unless Regexp === pattern
+
+    return false unless pattern =~ other.name
+
+    reqs = other.requirement.requirements
+
+    return false unless reqs.length == 1
+    return false unless reqs.first.first == '='
+
+    version = reqs.first.last
+
+    requirement.satisfied_by? version
   end
 
 end

Modified: MacRuby/trunk/lib/rubygems/dependency_installer.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/dependency_installer.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/dependency_installer.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -38,7 +38,7 @@
   # :format_executable:: See Gem::Installer#initialize.
   # :ignore_dependencies:: Don't install any dependencies.
   # :install_dir:: See Gem::Installer#install.
-  # :prerelease:: Allow prerelease versions
+  # :prerelease:: Allow prerelease versions.  See #install.
   # :security_policy:: See Gem::Installer::new and Gem::Security.
   # :user_install:: See Gem::Installer.new
   # :wrappers:: See Gem::Installer::new
@@ -89,14 +89,18 @@
 
     if @domain == :both or @domain == :remote then
       begin
-        requirements = dep.version_requirements.requirements.map do |req, ver|
+        requirements = dep.requirement.requirements.map do |req, ver|
           req
         end
 
-        all = !@prerelease && (requirements.length > 1 ||
+        all = !dep.prerelease? &&
+              # we only need latest if there's one requirement and it is
+              # guaranteed to match the newest specs
+              (requirements.length > 1 or
                 (requirements.first != ">=" and requirements.first != ">"))
 
-        found = Gem::SpecFetcher.fetcher.fetch dep, all, true, @prerelease
+        found = Gem::SpecFetcher.fetcher.fetch dep, all, true, dep.prerelease?
+
         gems_and_sources.push(*found)
 
       rescue Gem::RemoteFetcher::FetchError => e
@@ -120,7 +124,7 @@
   def gather_dependencies
     specs = @specs_and_sources.map { |spec,_| spec }
 
-    dependency_list = Gem::DependencyList.new
+    dependency_list = Gem::DependencyList.new @development
     dependency_list.add(*specs)
 
     unless @ignore_dependencies then
@@ -143,7 +147,7 @@
 
             @source_index.any? do |_, installed_spec|
               dep.name == installed_spec.name and
-                dep.version_requirements.satisfied_by? installed_spec.version
+                dep.requirement.satisfied_by? installed_spec.version
             end
           end
 
@@ -164,7 +168,9 @@
   # +version+.  Returns an Array of specs and sources required for
   # installation of the gem.
 
-  def find_spec_by_name_and_version gem_name, version = Gem::Requirement.default
+  def find_spec_by_name_and_version(gem_name,
+                                    version = Gem::Requirement.default,
+                                    prerelease = false)
     spec_and_source = nil
 
     glob = if File::ALT_SEPARATOR then
@@ -189,6 +195,7 @@
 
     if spec_and_source.nil? then
       dep = Gem::Dependency.new gem_name, version
+      dep.prerelease = true if prerelease
       spec_and_sources = find_gems_with_sources(dep).reverse
 
       spec_and_source = spec_and_sources.find { |spec, source|
@@ -205,13 +212,24 @@
   end
 
   ##
-  # Installs the gem and all its dependencies.  Returns an Array of installed
-  # gems specifications.
+  # Installs the gem +dep_or_name+ and all its dependencies.  Returns an Array
+  # of installed gem specifications.
+  #
+  # If the +:prerelease+ option is set and there is a prerelease for
+  # +dep_or_name+ the prerelease version will be installed.
+  #
+  # Unless explicitly specified as a prerelease dependency, prerelease gems
+  # that +dep_or_name+ depend on will not be installed.
+  #
+  # If c-1.a depends on b-1 and a-1.a and there is a gem b-1.a available then
+  # c-1.a, b-1 and a-1.a will be installed.  b-1.a will need to be installed
+  # separately.
 
   def install dep_or_name, version = Gem::Requirement.default
     if String === dep_or_name then
-      find_spec_by_name_and_version dep_or_name, version
+      find_spec_by_name_and_version dep_or_name, version, @prerelease
     else
+      dep_or_name.prerelease = @prerelease
       @specs_and_sources = [find_gems_with_sources(dep_or_name).last]
     end
 

Modified: MacRuby/trunk/lib/rubygems/dependency_list.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/dependency_list.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/dependency_list.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -6,23 +6,41 @@
 
 require 'tsort'
 
+##
+# Gem::DependencyList is used for installing and uninstalling gems in the
+# correct order to avoid conflicts.
+
 class Gem::DependencyList
 
   include Enumerable
   include TSort
 
-  def self.from_source_index(src_index)
-    deps = new
+  ##
+  # Allows enabling/disabling use of development dependencies
 
-    src_index.each do |full_name, spec|
-      deps.add spec
+  attr_accessor :development
+
+  ##
+  # Creates a DependencyList from a Gem::SourceIndex +source_index+
+
+  def self.from_source_index(source_index)
+    list = new
+
+    source_index.each do |full_name, spec|
+      list.add spec
     end
 
-    deps
+    list
   end
 
-  def initialize
+  ##
+  # Creates a new DependencyList.  If +development+ is true, development
+  # dependencies will be included.
+
+  def initialize development = false
     @specs = []
+
+    @development = development
   end
 
   ##
@@ -33,8 +51,9 @@
   end
 
   ##
-  # Return a list of the specifications in the dependency list, sorted in
-  # order so that no spec in the list depends on a gem earlier in the list.
+  # Return a list of the gem specifications in the dependency list, sorted in
+  # order so that no gemspec in the list depends on a gemspec earlier in the
+  # list.
   #
   # This is useful when removing gems from a set of installed gems.  By
   # removing them in the returned order, you don't get into as many dependency
@@ -77,6 +96,10 @@
     @specs.find { |spec| spec.full_name == full_name }
   end
 
+  def inspect # :nodoc:
+    "#<%s:0x%x %p>" % [self.class, object_id, map { |s| s.full_name }]
+  end
+
   ##
   # Are all the dependencies in the list satisfied?
 
@@ -89,10 +112,10 @@
   end
 
   ##
-  # Is is ok to remove a gem from the dependency list?
+  # Is is ok to remove a gemspec from the dependency list?
   #
   # If removing the gemspec creates breaks a currently ok dependency, then it
-  # is NOT ok to remove the gem.
+  # is NOT ok to remove the gemspec.
 
   def ok_to_remove?(full_name)
     gem_to_remove = find_name full_name
@@ -117,13 +140,16 @@
     }
   end
 
+  ##
+  # Removes the gemspec matching +full_name+ from the dependency list
+
   def remove_by_name(full_name)
     @specs.delete_if { |spec| spec.full_name == full_name }
   end
 
   ##
   # Return a hash of predecessors.  <tt>result[spec]</tt> is an Array of
-  # gemspecs that have a dependency satisfied by the named spec.
+  # gemspecs that have a dependency satisfied by the named gemspec.
 
   def spec_predecessors
     result = Hash.new { |h,k| h[k] = [] }
@@ -152,7 +178,10 @@
   def tsort_each_child(node, &block)
     specs = @specs.sort.reverse
 
-    node.dependencies.each do |dep|
+    dependencies = node.runtime_dependencies
+    dependencies.push(*node.development_dependencies) if @development
+
+    dependencies.each do |dep|
       specs.each do |spec|
         if spec.satisfies_requirement? dep then
           begin

Modified: MacRuby/trunk/lib/rubygems/doc_manager.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/doc_manager.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/doc_manager.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -98,6 +98,13 @@
   end
 
   ##
+  # Is the RI documentation installed?
+
+  def ri_installed?
+    File.exist?(File.join(@doc_dir, "ri"))
+  end
+
+  ##
   # Generate the RI documents for this gem spec.
   #
   # Note that if both RI and RDoc documents are generated from the same

Modified: MacRuby/trunk/lib/rubygems/format.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/format.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/format.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -14,25 +14,22 @@
 
 class Gem::Format
 
-  attr_accessor :spec, :file_entries, :gem_path
+  attr_accessor :spec
+  attr_accessor :file_entries
+  attr_accessor :gem_path
 
   extend Gem::UserInteraction
 
   ##
-  # Constructs an instance of a Format object, representing the gem's
-  # data structure.
-  #
-  # gem:: [String] The file name of the gem
-  #
+  # Constructs a Format representing the gem's data which came from +gem_path+
+
   def initialize(gem_path)
     @gem_path = gem_path
   end
 
   ##
-  # Reads the named gem file and returns a Format object, representing 
-  # the data from the gem file
-  #
-  # file_path:: [String] Path to the gem file
+  # Reads the gem +file_path+ using +security_policy+ and returns a Format
+  # representing the data in the gem
 
   def self.from_file_by_path(file_path, security_policy = nil)
     format = nil
@@ -41,25 +38,24 @@
       raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
     end
 
-    # check for old version gem
-    if File.read(file_path, 20).include?("MD5SUM =")
+    start = File.read file_path, 20
+
+    if start.nil? or start.length < 20 then
+      nil
+    elsif start.include?("MD5SUM =") # old version gems
       require 'rubygems/old_format'
 
-      format = Gem::OldFormat.from_file_by_path(file_path)
+      Gem::OldFormat.from_file_by_path file_path
     else
       open file_path, Gem.binary_mode do |io|
-        format = from_io io, file_path, security_policy
+        from_io io, file_path, security_policy
       end
     end
-
-    return format
   end
 
   ##
-  # Reads a gem from an io stream and returns a Format object, representing
-  # the data from the gem file
-  #
-  # io:: [IO] Stream from which to read the gem
+  # Reads a gem from +io+ at +gem_path+ using +security_policy+ and returns a
+  # Format representing the data from the gem
 
   def self.from_io(io, gem_path="(io)", security_policy = nil)
     format = new gem_path

Modified: MacRuby/trunk/lib/rubygems/gem_openssl.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/gem_openssl.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/gem_openssl.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -30,7 +30,7 @@
 
     def ensure_ssl_available
       unless ssl_available?
-        fail Gem::Exception, "SSL is not installed on this system"
+        raise Gem::Exception, "SSL is not installed on this system"
       end
     end
   end

Modified: MacRuby/trunk/lib/rubygems/gem_path_searcher.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/gem_path_searcher.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/gem_path_searcher.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -1,9 +1,3 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
 ##
 # GemPathSearcher has the capability to find loadable files inside
 # gems.  It generates data up front to speed up searches later.
@@ -14,14 +8,16 @@
   # Initialise the data we need to make searches later.
 
   def initialize
-    # We want a record of all the installed gemspecs, in the order
-    # we wish to examine them.
+    # We want a record of all the installed gemspecs, in the order we wish to
+    # examine them.
     @gemspecs = init_gemspecs
-    # Map gem spec to glob of full require_path directories.
-    # Preparing this information may speed up searches later.
+
+    # Map gem spec to glob of full require_path directories.  Preparing this
+    # information may speed up searches later.
     @lib_dirs = {}
+
     @gemspecs.each do |spec|
-      @lib_dirs[spec.object_id] = lib_dirs_for(spec)
+      @lib_dirs[spec.object_id] = lib_dirs_for spec
     end
   end
 
@@ -72,6 +68,7 @@
   # Some of the intermediate results are cached in @lib_dirs for speed.
 
   def matching_files(spec, path)
+    return [] unless @lib_dirs[spec.object_id] # case no paths
     glob = File.join @lib_dirs[spec.object_id], "#{path}#{Gem.suffix_pattern}"
     Dir[glob].select { |f| File.file? f.untaint }
   end
@@ -95,7 +92,8 @@
   #   '/usr/local/lib/ruby/gems/1.8/gems/foobar-1.0/{lib,ext}'
 
   def lib_dirs_for(spec)
-    "#{spec.full_gem_path}/{#{spec.require_paths.join(',')}}"
+    "#{spec.full_gem_path}/{#{spec.require_paths.join(',')}}" if
+      spec.require_paths
   end
 
 end

Modified: MacRuby/trunk/lib/rubygems/indexer.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/indexer.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/indexer.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -58,7 +58,7 @@
 
   def initialize(directory, options = {})
     unless ''.respond_to? :to_xs then
-      fail "Gem::Indexer requires that the XML Builder library be installed:" \
+      raise "Gem::Indexer requires that the XML Builder library be installed:" \
            "\n\tgem install builder"
     end
 
@@ -350,7 +350,7 @@
         end
 
         index.sort_by { |_, spec| [-spec.date.to_i, spec] }.each do |_, spec|
-          gem_path = CGI.escapeHTML "http://#{@rss_gems_host}/gems/#{spec.full_name}.gem"
+          gem_path = CGI.escapeHTML "http://#{@rss_gems_host}/gems/#{spec.file_name}"
           size = File.stat(spec.loaded_from).size rescue next
 
           description = spec.description || spec.summary || ''

Modified: MacRuby/trunk/lib/rubygems/install_update_options.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/install_update_options.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/install_update_options.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -95,8 +95,7 @@
 
     add_option(:"Install/Update",       '--[no-]user-install',
                'Install in user\'s home directory instead',
-               'of GEM_HOME. Defaults to using home',
-               'only if GEM_HOME is not writable.') do |value, options|
+               'of GEM_HOME.') do |value, options|
       options[:user_install] = value
     end
 
@@ -105,13 +104,6 @@
                 "dependencies") do |value, options|
       options[:development] = true
     end
-
-    add_option(:"Install/Update", "--prerelease",
-               "Install prerelease versions of a gem if",
-               "available. Defaults to skipping",
-               "prereleases.") do |value, options|
-      options[:prerelease] = true
-    end
   end
 
   ##

Modified: MacRuby/trunk/lib/rubygems/installer.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/installer.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/installer.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -5,7 +5,6 @@
 #++
 
 require 'fileutils'
-require 'pathname'
 require 'rbconfig'
 
 require 'rubygems/format'
@@ -29,6 +28,12 @@
 class Gem::Installer
 
   ##
+  # Paths where env(1) might live.  Some systems are broken and have it in
+  # /bin
+
+  ENV_PATHS = %w[/usr/bin/env /bin/env]
+
+  ##
   # Raised when there is an error while building extensions.
   #
   class ExtensionBuildError < Gem::InstallError; end
@@ -52,17 +57,11 @@
 
   attr_reader :spec
 
-  @home_install_warning = false
   @path_warning = false
 
   class << self
 
     ##
-    # True if we've warned about ~/.gems install
-
-    attr_accessor :home_install_warning
-
-    ##
     # True if we've warned about PATH not including Gem.bindir
 
     attr_accessor :path_warning
@@ -106,7 +105,7 @@
     @env_shebang         = options[:env_shebang]
     @force               = options[:force]
     gem_home             = options[:install_dir]
-    @gem_home            = Pathname.new(gem_home).expand_path
+    @gem_home            = File.expand_path(gem_home)
     @ignore_dependencies = options[:ignore_dependencies]
     @format_executable   = options[:format_executable]
     @security_policy     = options[:security_policy]
@@ -121,27 +120,6 @@
       raise Gem::InstallError, "invalid gem format for #{@gem}"
     end
 
-    begin
-      FileUtils.mkdir_p @gem_home
-    rescue Errno::EACCES, Errno::ENOTDIR
-      # We'll divert to ~/.gems below
-    end
-
-    if not File.writable? @gem_home or
-        # TODO: Shouldn't have to test for existence of bindir; tests need it.
-        (@gem_home.to_s == Gem.dir and File.exist? Gem.bindir and
-         not File.writable? Gem.bindir) then
-      if options[:user_install] == false then # You don't want to use ~
-        raise Gem::FilePermissionError, @gem_home
-      elsif options[:user_install].nil? then
-        unless self.class.home_install_warning or options[:unpack] then
-          alert_warning "Installing to ~/.gem since #{@gem_home} and\n\t  #{Gem.bindir} aren't both writable."
-          self.class.home_install_warning = true
-        end
-      end
-      options[:user_install] = true
-    end
-
     if options[:user_install] and not options[:unpack] then
       @gem_home = Gem.user_dir
 
@@ -152,12 +130,11 @@
           self.class.path_warning = true
         end
       end
-
-      FileUtils.mkdir_p @gem_home unless File.directory? @gem_home
-      # If it's still not writable, you've got issues.
-      raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home
     end
 
+    FileUtils.mkdir_p @gem_home
+    raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home
+
     @spec = @format.spec
 
     @gem_dir = File.join(@gem_home, "gems", @spec.full_name).untaint
@@ -183,14 +160,15 @@
     unless @force then
       if rrv = @spec.required_ruby_version then
         unless rrv.satisfied_by? Gem.ruby_version then
-          raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}"
+          raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}."
         end
       end
 
       if rrgv = @spec.required_rubygems_version then
         unless rrgv.satisfied_by? Gem::Version.new(Gem::RubyGemsVersion) then
           raise Gem::InstallError,
-                "#{@spec.name} requires RubyGems version #{rrgv}"
+            "#{@spec.name} requires RubyGems version #{rrgv}. " +
+            "Try 'gem update --system' to update RubyGems itself."
         end
       end
 
@@ -229,8 +207,7 @@
 
     say @spec.post_install_message unless @spec.post_install_message.nil?
 
-    @spec.loaded_from = File.join(@gem_home, 'specifications',
-                                  "#{@spec.full_name}.gemspec")
+    @spec.loaded_from = File.join(@gem_home, 'specifications', @spec.spec_name)
 
     @source_index.add_spec @spec
 
@@ -262,7 +239,7 @@
   # True if the gems in the source_index satisfy +dependency+.
 
   def installation_satisfies_dependency?(dependency)
-    @source_index.find_name(dependency.name, dependency.version_requirements).size > 0
+    @source_index.find_name(dependency.name, dependency.requirement).size > 0
   end
 
   ##
@@ -281,8 +258,7 @@
   def write_spec
     rubycode = @spec.to_ruby
 
-    file_name = File.join @gem_home, 'specifications',
-                          "#{@spec.full_name}.gemspec"
+    file_name = File.join @gem_home, 'specifications', @spec.spec_name
 
     file_name.untaint
 
@@ -392,23 +368,25 @@
   # necessary.
 
   def shebang(bin_file_name)
-    if @env_shebang then
-      "#!/usr/bin/env " + Gem::ConfigMap[:ruby_install_name]
-    else
-      path = File.join @gem_dir, @spec.bindir, bin_file_name
+    ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
+    path = File.join @gem_dir, @spec.bindir, bin_file_name
+    first_line = File.open(path, "rb") {|file| file.gets}
 
-      File.open(path, "rb") do |file|
-        first_line = file.gets
-        if first_line =~ /^#!/ then
-          # Preserve extra words on shebang line, like "-w".  Thanks RPA.
-          shebang = first_line.sub(/\A\#!.*?ruby\S*/, "#!#{Gem.ruby}")
-        else
-          # Create a plain shebang line.
-          shebang = "#!#{Gem.ruby}"
-        end
+    if /\A#!/ =~ first_line then
+      # Preserve extra words on shebang line, like "-w".  Thanks RPA.
+      shebang = first_line.sub(/\A\#!.*?ruby\S*(?=(\s+\S+))/, "#!#{Gem.ruby}")
+      opts = $1
+      shebang.strip! # Avoid nasty ^M issues.
+    end
 
-        shebang.strip # Avoid nasty ^M issues.
-      end
+    if not ruby_name then
+      "#!#{Gem.ruby}#{opts}"
+    elsif opts then
+      "#!/bin/sh\n'exec' #{ruby_name.dump} '-x' \"$0\" \"$@\"\n#{shebang}"
+    else
+      # Create a plain shebang line.
+      @env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path }
+      "#!#{@env_path} #{ruby_name}"
     end
   end
 
@@ -514,7 +492,7 @@
   # Ensures that files can't be installed outside the gem directory.
 
   def extract_files
-    expand_and_validate_gem_dir
+    @gem_dir = File.expand_path @gem_dir
 
     raise ArgumentError, "format required to extract from" if @format.nil?
 
@@ -558,24 +536,5 @@
     end
   end
 
-  private
-
-  ##
-  # HACK Pathname is broken on windows.
-
-  def absolute_path? pathname
-    pathname.absolute? or (Gem.win_platform? and pathname.to_s =~ /\A[a-z]:/i)
-  end
-
-  def expand_and_validate_gem_dir
-    @gem_dir = Pathname.new(@gem_dir).expand_path
-
-    unless absolute_path?(@gem_dir) then # HACK is this possible after #expand_path?
-      raise ArgumentError, "install directory %p not absolute" % @gem_dir
-    end
-
-    @gem_dir = @gem_dir.to_s
-  end
-
 end
 

Modified: MacRuby/trunk/lib/rubygems/local_remote_options.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/local_remote_options.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/local_remote_options.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -101,10 +101,9 @@
   end
 
   ##
-  # Add the --update-source option
+  # Add the --update-sources option
 
   def add_update_sources_option
-
     add_option(:"Local/Remote", '-u', '--[no-]update-sources',
                'Update local source cache') do |value, options|
       Gem.configuration.update_sources = value

Modified: MacRuby/trunk/lib/rubygems/package/tar_input.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/package/tar_input.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/package/tar_input.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -1,3 +1,4 @@
+# -*- coding: iso-8859-1 -*-
 #++
 # Copyright (C) 2004 Mauricio Julio Fern\xE1ndez Pradier
 # See LICENSE.txt for additional licensing information.
@@ -199,7 +200,8 @@
   # times.  And that's the way it is.
 
   def zipped_stream(entry)
-    if defined? Rubinius then
+    if defined? Rubinius or defined? Maglev then
+      # these implementations have working Zlib
       zis = Zlib::GzipReader.new entry
       dis = zis.read
       is = StringIO.new(dis)

Modified: MacRuby/trunk/lib/rubygems/package.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/package.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/package.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -9,7 +9,6 @@
 require 'yaml'
 require 'zlib'
 
-require 'rubygems/digest/md5'
 require 'rubygems/security'
 require 'rubygems/specification'
 

Modified: MacRuby/trunk/lib/rubygems/package_task.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/package_task.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/package_task.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -97,22 +97,27 @@
 
   def define
     super
+
     task :package => [:gem]
+
+    gem_file = gem_spec.file_name
+    gem_path = File.join package_dir, gem_file
+
     desc "Build the gem file #{gem_file}"
-    task :gem => ["#{package_dir}/#{gem_file}"]
-    file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
-      when_writing("Creating #{gem_spec.full_name}.gem") {
+    task :gem => [gem_path]
+
+    trace = Rake.application.options.trace
+    Gem.configuration.verbose = trace
+
+    file gem_path => [package_dir] + @gem_spec.files do
+      when_writing "Creating #{gem_spec.file_name}" do
         Gem::Builder.new(gem_spec).build
-        verbose(true) {
-          mv gem_file, "#{package_dir}/#{gem_file}"
-        }
-      }
+        verbose trace do
+          mv gem_file, gem_path
+        end
+      end
     end
   end
 
-  def gem_file
-    "#{@gem_spec.full_name}.gem"
-  end
-
 end
 

Modified: MacRuby/trunk/lib/rubygems/remote_fetcher.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/remote_fetcher.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/remote_fetcher.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -81,7 +81,7 @@
       cache_dir = File.join(Gem.user_dir, 'cache')
     end
 
-    gem_file_name = "#{spec.full_name}.gem"
+    gem_file_name = spec.file_name
     local_gem_path = File.join cache_dir, gem_file_name
 
     FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
@@ -138,12 +138,18 @@
       say "Using local gem #{local_gem_path}" if
         Gem.configuration.really_verbose
     when nil then # TODO test for local overriding cache
+      source_path = if Gem.win_platform? && source_uri.scheme &&
+                       !source_uri.path.include?(':') then
+                      "#{source_uri.scheme}:#{source_uri.path}"
+                    else
+                      source_uri.path
+                    end
+
+      source_path = URI.unescape source_path
+
       begin
-        if Gem.win_platform? && source_uri.scheme && !source_uri.path.include?(':')
-          FileUtils.cp URI.unescape(source_uri.scheme + ':' + source_uri.path), local_gem_path
-        else
-          FileUtils.cp URI.unescape(source_uri.path), local_gem_path
-        end
+        FileUtils.cp source_path, local_gem_path unless
+          File.expand_path(source_path) == File.expand_path(local_gem_path)
       rescue Errno::EACCES
         local_gem_path = source_uri.to_s
       end
@@ -329,6 +335,8 @@
       request.add_field 'If-Modified-Since', last_modified.rfc2822
     end
 
+    yield request if block_given?
+
     connection = connection_for uri
 
     retried = false
@@ -336,10 +344,16 @@
 
     begin
       @requests[connection.object_id] += 1
+
+      say "#{request.method} #{uri}" if
+        Gem.configuration.really_verbose
       response = connection.request request
-      say "#{request.method} #{response.code} #{response.message}: #{uri}" if
+      say "#{response.code} #{response.message}" if
         Gem.configuration.really_verbose
+
     rescue Net::HTTPBadResponse
+      say "bad response" if Gem.configuration.really_verbose
+
       reset connection
 
       raise FetchError.new('too many bad responses', uri) if bad_response
@@ -349,7 +363,7 @@
     # HACK work around EOFError bug in Net::HTTP
     # NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible
     # to install gems.
-    rescue EOFError, Errno::ECONNABORTED, Errno::ECONNRESET
+    rescue EOFError, Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
       requests = @requests[connection.object_id]
       say "connection reset after #{requests} requests, retrying" if
         Gem.configuration.really_verbose

Modified: MacRuby/trunk/lib/rubygems/requirement.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/requirement.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/requirement.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -1,41 +1,33 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
+require "rubygems/version"
 
 ##
-# Requirement version includes a prefaced comparator in addition
-# to a version number.
-#
-# A Requirement object can actually contain multiple, er,
-# requirements, as in (> 1.2, < 2.0).
+# A Requirement is a set of one or more version restrictions. It supports a
+# few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.
 
 class Gem::Requirement
-
   include Comparable
 
-  attr_reader :requirements
-
-  OPS = {
+  OPS = { #:nodoc:
     "="  =>  lambda { |v, r| v == r },
     "!=" =>  lambda { |v, r| v != r },
-    ">"  =>  lambda { |v, r| v > r },
-    "<"  =>  lambda { |v, r| v < r },
+    ">"  =>  lambda { |v, r| v > r  },
+    "<"  =>  lambda { |v, r| v < r  },
     ">=" =>  lambda { |v, r| v >= r },
     "<=" =>  lambda { |v, r| v <= r },
     "~>" =>  lambda { |v, r| v = v.release; v >= r && v < r.bump }
   }
 
-  OP_RE = OPS.keys.map{ |k| Regexp.quote k }.join '|'
+  quoted  = OPS.keys.map { |k| Regexp.quote k }.join "|"
+  PATTERN = /\A\s*(#{quoted})?\s*(#{Gem::Version::VERSION_PATTERN})\s*\z/
 
   ##
-  # Factory method to create a Gem::Requirement object.  Input may be a
-  # Version, a String, or nil.  Intended to simplify client code.
+  # Factory method to create a Gem::Requirement object.  Input may be
+  # a Version, a String, or nil.  Intended to simplify client code.
   #
-  # If the input is "weird", the default version requirement is returned.
+  # If the input is "weird", the default version requirement is
+  # returned.
 
-  def self.create(input)
+  def self.create input
     case input
     when Gem::Requirement then
       input
@@ -43,9 +35,9 @@
       new input
     else
       if input.respond_to? :to_str then
-        self.new [input.to_str]
+        new [input.to_str]
       else
-        self.default
+        default
       end
     end
   end
@@ -58,113 +50,99 @@
   # "A default "version requirement" can surely _only_ be '> 0'."
 
   def self.default
-    self.new ['>= 0']
+    new '>= 0'
   end
 
   ##
-  # Constructs a Requirement from +requirements+ which can be a String, a
-  # Gem::Version, or an Array of those.  See #parse for details on the
-  # formatting of requirement strings.
+  # Parse +obj+, returning an <tt>[op, version]</tt> pair. +obj+ can
+  # be a String or a Gem::Version.
+  #
+  # If +obj+ is a String, it can be either a full requirement
+  # specification, like <tt>">= 1.2"</tt>, or a simple version number,
+  # like <tt>"1.2"</tt>.
+  #
+  #     parse("> 1.0")                 # => [">", "1.0"]
+  #     parse("1.0")                   # => ["=", "1.0"]
+  #     parse(Gem::Version.new("1.0")) # => ["=,  "1.0"]
 
-  def initialize(requirements)
-    @requirements = case requirements
-                    when Array then
-                      requirements.map do |requirement|
-                        parse(requirement)
-                      end
-                    else
-                      [parse(requirements)]
-                    end
-    @version = nil   # Avoid warnings.
+  def self.parse obj
+    return ["=", obj] if Gem::Version === obj
+
+    unless PATTERN =~ obj.to_s
+      raise ArgumentError, "Illformed requirement [#{obj.inspect}]"
+    end
+
+    [$1 || "=", Gem::Version.new($2)]
   end
 
   ##
-  # Marshal raw requirements, rather than the full object
+  # An array of requirement pairs. The first element of the pair is
+  # the op, and the second is the Gem::Version.
 
-  def marshal_dump # :nodoc:
-    [@requirements]
-  end
+  attr_reader :requirements #:nodoc:
 
   ##
-  # Load custom marshal format
+  # Constructs a requirement from +requirements+. Requirements can be
+  # Strings, Gem::Versions, or Arrays of those. +nil+ and duplicate
+  # requirements are ignored. An empty set of +requirements+ is the
+  # same as <tt>">= 0"</tt>.
 
-  def marshal_load(array) # :nodoc:
-    @requirements = array[0]
-    @version = nil
-  end
+  def initialize *requirements
+    requirements = requirements.flatten
+    requirements.compact!
+    requirements.uniq!
 
-  def to_s # :nodoc:
-    as_list.join(", ")
+    requirements << ">= 0" if requirements.empty?
+    @requirements = requirements.map! { |r| self.class.parse r }
   end
 
-  def pretty_print(q) # :nodoc:
-    q.group 1, 'Gem::Requirement.new(', ')' do
-      q.pp as_list
-    end
+  def as_list # :nodoc:
+    requirements.map { |op, version| "#{op} #{version}" }
   end
 
-  def as_list
-    normalize
-    @requirements.map do |op, version| "#{op} #{version}" end
+  def hash # :nodoc:
+    requirements.hash
   end
 
-  def normalize
-    return if not defined? @version or @version.nil?
-    @requirements = [parse(@version)]
-    @nums = nil
-    @version = nil
-    @op = nil
+  def marshal_dump # :nodoc:
+    [@requirements]
   end
 
-  ##
-  # True if this requirement satisfied by the Gem::Version +version+.
-
-  def satisfied_by?(version)
-    normalize
-    @requirements.all? { |op, rv| satisfy?(op, version, rv) }
+  def marshal_load array # :nodoc:
+    @requirements = array[0]
   end
 
-  ##
-  # Is "+version+ +op+ +required_version+" satisfied?
-
-  def satisfy?(op, version, required_version)
-    OPS[op].call(version, required_version)
+  def prerelease?
+    requirements.any? { |r| r.last.prerelease? }
   end
 
-  def prerelease?
-    # TODO: why is @requirements a nested array?
-    @requirements.any?{ |r| r[1].prerelease? }
+  def pretty_print q # :nodoc:
+    q.group 1, 'Gem::Requirement.new(', ')' do
+      q.pp as_list
+    end
   end
 
   ##
-  # Parse the version requirement obj returning the operator and version.
-  #
-  # The requirement can be a String or a Gem::Version.  A String can be an
-  # operator (<, <=, =, >=, >, !=, ~>), a version number, or both, operator
-  # first.
+  # True if +version+ satisfies this Requirement.
 
-  def parse(obj)
-    case obj
-    when /^\s*(#{OP_RE})\s*(#{Gem::Version::VERSION_PATTERN})\s*$/o then
-      [$1, Gem::Version.new($2)]
-    when /^\s*(#{Gem::Version::VERSION_PATTERN})\s*$/o then
-      ['=', Gem::Version.new($1)]
-    when /^\s*(#{OP_RE})\s*$/o then
-      [$1, Gem::Version.new('0')]
-    when Gem::Version then
-      ['=', obj]
-    else
-      fail ArgumentError, "Illformed requirement [#{obj.inspect}]"
-    end
+  def satisfied_by? version
+    requirements.all? { |op, rv| OPS[op].call version, rv }
   end
 
-  def <=>(other) # :nodoc:
-    to_s <=> other.to_s
+  def to_s # :nodoc:
+    as_list.join ", "
   end
 
-  def hash # :nodoc:
-    to_s.hash
+  def <=> other # :nodoc:
+    to_s <=> other.to_s
   end
-
 end
 
+# :stopdoc:
+# Gem::Version::Requirement is used in a lot of old YAML specs. It's aliased
+# here for backwards compatibility. I'd like to remove this, maybe in RubyGems
+# 2.0.
+
+::Gem::Version::Requirement = ::Gem::Requirement
+# :startdoc:
+

Modified: MacRuby/trunk/lib/rubygems/server.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/server.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/server.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -39,9 +39,9 @@
   SEARCH = <<-SEARCH
       <form class="headerSearch" name="headerSearchForm" method="get" action="/rdoc">
         <div id="search" style="float:right">
-          <span>Filter/Search</span>
-          <input id="q" type="text" style="width:10em" name="q"/>
-          <button type="submit" style="display:none" />
+          <label for="q">Filter/Search</label>
+          <input id="q" type="text" style="width:10em" name="q">
+          <button type="submit" style="display:none"></button>
         </div>
       </form>
   SEARCH
@@ -426,15 +426,17 @@
   RDOC_SEARCH
 
   def self.run(options)
-    new(options[:gemdir], options[:port], options[:daemon]).run
+    new(options[:gemdir], options[:port], options[:daemon],
+        options[:addresses]).run
   end
 
-  def initialize(gem_dir, port, daemon)
+  def initialize(gem_dir, port, daemon, addresses = nil)
     Socket.do_not_reverse_lookup = true
 
     @gem_dir = gem_dir
     @port = port
     @daemon = daemon
+    @addresses = addresses
     logger = WEBrick::Log.new nil, WEBrick::BasicLog::FATAL
     @server = WEBrick::HTTPServer.new :DoNotListen => true, :Logger => logger
 
@@ -498,6 +500,37 @@
     end
   end
 
+  ##
+  # Creates server sockets based on the addresses option.  If no addresses
+  # were given a server socket for all interfaces is created.
+
+  def listen addresses = @addresses
+    addresses = [nil] unless addresses
+
+    listeners = 0
+
+    addresses.each do |address|
+      begin
+        @server.listen address, @port
+        @server.listeners[listeners..-1].each do |listener|
+          host, port = listener.addr.values_at 2, 1
+          host = "[#{host}]" if host =~ /:/ # we don't reverse lookup
+          say "Server started at http://#{host}:#{port}"
+        end
+
+        listeners = @server.listeners.length
+      rescue SystemCallError
+        next
+      end
+    end
+
+    if @server.listeners.empty? then
+      say "Unable to start a server."
+      say "Check for running servers or your --bind and --port arguments"
+      terminate_interaction 1
+    end
+  end
+
   def quick(req, res)
     @source_index.refresh!
 
@@ -566,7 +599,7 @@
       deps = spec.dependencies.map do |dep|
         { "name"    => dep.name,
           "type"    => dep.type,
-          "version" => dep.version_requirements.to_s, }
+          "version" => dep.requirement.to_s, }
       end
 
       deps = deps.sort_by { |dep| [dep["name"].downcase, dep["version"]] }
@@ -602,7 +635,7 @@
       "only_one_executable" => true,
       "full_name" => "rubygems-#{Gem::RubyGemsVersion}",
       "has_deps" => false,
-      "homepage" => "http://rubygems.org/",
+      "homepage" => "http://docs.rubygems.org/",
       "name" => 'rubygems',
       "rdoc_installed" => true,
       "summary" => "RubyGems itself",
@@ -716,10 +749,8 @@
   end
 
   def run
-    @server.listen nil, @port
+    listen
 
-    say "Starting gem server on http://localhost:#{@port}/"
-
     WEBrick::Daemon.start if @daemon
 
     @server.mount_proc "/yaml", method(:yaml)

Modified: MacRuby/trunk/lib/rubygems/source_index.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/source_index.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/source_index.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -253,18 +253,18 @@
   # change in the index.
 
   def index_signature
-    require 'rubygems/digest/sha2'
+    require 'digest'
 
-    Gem::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
+    Digest::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
   end
 
   ##
   # The signature for the given gem specification.
 
   def gem_signature(gem_full_name)
-    require 'rubygems/digest/sha2'
+    require 'digest'
 
-    Gem::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
+    Digest::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
   end
 
   def size
@@ -303,7 +303,7 @@
       version_requirement = platform_only || Gem::Requirement.default
     when Gem::Dependency then
       only_platform = platform_only
-      version_requirement = gem_pattern.version_requirements
+      version_requirement = gem_pattern.requirement
       gem_pattern = if Regexp === gem_pattern.name then
                       gem_pattern.name
                     elsif gem_pattern.name.empty? then

Modified: MacRuby/trunk/lib/rubygems/spec_fetcher.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/spec_fetcher.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/spec_fetcher.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -197,7 +197,7 @@
 
     if type == :all
       list.values.map do |gems|
-        gems.reject! { |g| g[1].prerelease? }
+        gems.reject! { |g| !g[1] || g[1].prerelease? }
       end
     end
 
@@ -242,7 +242,7 @@
         FileUtils.mkdir_p cache_dir
 
         open local_file, 'wb' do |io|
-          Marshal.dump specs, io
+          io << spec_dump
         end
       rescue
       end

Modified: MacRuby/trunk/lib/rubygems/specification.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/specification.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/specification.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -17,7 +17,7 @@
 # defined in a .gemspec file or a Rakefile, and looks like this:
 #
 #   spec = Gem::Specification.new do |s|
-#     s.name = 'rfoo'
+#     s.name = 'example'
 #     s.version = '1.0'
 #     s.summary = 'Example gem specification'
 #     ...
@@ -409,15 +409,19 @@
   # :startdoc:
 
   ##
-  # Specification constructor.  Assigns the default values to the attributes
-  # and yields itself for further initialization.
+  # Specification constructor.  Assigns the default values to the
+  # attributes and yields itself for further
+  # initialization. Optionally takes +name+ and +version+.
 
-  def initialize
+  def initialize name = nil, version = nil
     @new_platform = nil
     assign_defaults
     @loaded = false
     @loaded_from = nil
 
+    self.name = name if name
+    self.version = version if version
+
     yield self if block_given?
 
     @@gather.call(self) if @@gather
@@ -498,7 +502,7 @@
 
   def self.load(filename)
     gemspec = nil
-    fail "NESTED Specification.load calls not allowed!" if @@gather
+    raise "NESTED Specification.load calls not allowed!" if @@gather
     @@gather = proc { |gs| gemspec = gs }
     data = File.read(filename)
     eval(data)
@@ -598,10 +602,12 @@
   end
 
   ##
-  # The default (generated) file name of the gem.
+  # The default (generated) file name of the gem.  See also #spec_name.
+  #
+  #   spec.file_name # => "example-1.0.gem"
 
   def file_name
-    full_name + ".gem"
+    full_name + '.gem'
   end
 
   ##
@@ -620,7 +626,7 @@
 
   def satisfies_requirement?(dependency)
     return @name == dependency.name &&
-      dependency.version_requirements.satisfied_by?(@version)
+      dependency.requirement.satisfied_by?(@version)
   end
 
   ##
@@ -630,6 +636,15 @@
     [@name, @version, @new_platform == Gem::Platform::RUBY ? -1 : 1]
   end
 
+  ##
+  # The default name of the gemspec.  See also #file_name
+  #
+  #   spec.spec_name # => "example-1.0.gemspec"
+
+  def spec_name
+    full_name + '.gemspec'
+  end
+
   def <=>(other) # :nodoc:
     sort_obj <=> other.sort_obj
   end
@@ -1033,14 +1048,18 @@
   ##
   # :attr_accessor: rubygems_version
   #
-  # The version of RubyGems used to create this gem
+  # The version of RubyGems used to create this gem.
+  #
+  # Do not set this, it is set automatically when the gem is packaged.
 
   required_attribute :rubygems_version, Gem::RubyGemsVersion
 
   ##
   # :attr_accessor: specification_version
   #
-  # The Gem::Specification version of this gemspec
+  # The Gem::Specification version of this gemspec.
+  #
+  # Do not set this, it is set automatically when the gem is packaged.
 
   required_attribute :specification_version, CURRENT_SPECIFICATION_VERSION
 
@@ -1062,6 +1081,8 @@
   # :attr_accessor: date
   #
   # The date this gem was created
+  #
+  # Do not set this, it is set automatically when the gem is packaged.
 
   required_attribute :date, TODAY
 
@@ -1069,13 +1090,20 @@
   # :attr_accessor: summary
   #
   # A short summary of this gem's description.  Displayed in `gem list -d`.
+  #
+  # The description should be more detailed than the summary.  For example,
+  # you might wish to copy the entire README into the description.
+  #
+  # As of RubyGems 1.3.2 newlines are no longer stripped.
 
   required_attribute :summary
 
   ##
   # :attr_accessor: require_paths
   #
-  # Paths in the gem to add to $LOAD_PATH when this gem is activated
+  # Paths in the gem to add to $LOAD_PATH when this gem is activated.
+  #
+  # The default 'lib' is typically sufficient.
 
   required_attribute :require_paths, ['lib']
 
@@ -1085,6 +1113,13 @@
   # :attr_accessor: email
   #
   # A contact email for this gem
+  #
+  # If you are providing multiple authors and multiple emails they should be
+  # in the same order such that:
+  #
+  #   Hash[*spec.authors.zip(spec.emails).flatten]
+  #
+  # Gives a hash of author name to email address.
 
   attribute :email
 
@@ -1122,6 +1157,8 @@
   # :attr_accessor: default_executable
   #
   # The default executable for this gem.
+  #
+  # This is not used.
 
   attribute :default_executable
 
@@ -1149,7 +1186,7 @@
   ##
   # :attr_accessor: required_ruby_version
   #
-  # The ruby of version required by this gem
+  # The version of ruby required by this gem
 
   attribute :required_ruby_version, Gem::Requirement.default
 
@@ -1164,6 +1201,9 @@
   # :attr_accessor: platform
   #
   # The platform this gem runs on.  See Gem::Platform for details.
+  #
+  # Setting this to any value other than Gem::Platform::RUBY or
+  # Gem::Platform::CURRENT is probably wrong.
 
   attribute :platform, Gem::Platform::RUBY
 
@@ -1192,7 +1232,14 @@
   ##
   # :attr_accessor: authors
   #
-  # The list of authors who wrote this gem
+  # The list of author names who wrote this gem.
+  #
+  # If you are providing multiple authors and multiple emails they should be
+  # in the same order such that:
+  #
+  #   Hash[*spec.authors.zip(spec.emails).flatten]
+  #
+  # Gives a hash of author name to email address.
 
   array_attribute :authors
 
@@ -1228,21 +1275,21 @@
   ##
   # :attr_accessor: rdoc_options
   #
-  # An ARGV-style array of options to RDoc
+  # An ARGV style array of options to RDoc
 
   array_attribute :rdoc_options
 
   ##
   # :attr_accessor: extra_rdoc_files
   #
-  # Extra files to add to RDoc
+  # Extra files to add to RDoc such as README or doc/examples.txt
 
   array_attribute :extra_rdoc_files
 
   ##
   # :attr_accessor: executables
   #
-  # Executables included in the gem
+  # Executables included in the gem.
 
   array_attribute :executables
 
@@ -1266,6 +1313,9 @@
   # :attr_reader: dependencies
   #
   # A list of Gem::Dependency objects this gem depends on.
+  #
+  # Use #add_dependency or #add_development_dependency to add dependencies to
+  # a gem.
 
   array_attribute :dependencies
 

Modified: MacRuby/trunk/lib/rubygems/test_utilities.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/test_utilities.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/test_utilities.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -23,6 +23,7 @@
 class Gem::FakeFetcher
 
   attr_reader :data
+  attr_reader :last_request
   attr_accessor :paths
 
   def initialize
@@ -30,17 +31,21 @@
     @paths = []
   end
 
-  def fetch_path path, mtime = nil
+  def find_data(path)
     path = path.to_s
     @paths << path
-    raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
+    raise ArgumentError, 'need full URI' unless path =~ %r'^https?://'
 
     unless @data.key? path then
       raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
     end
 
-    data = @data[path]
+    @data[path]
+  end
 
+  def fetch_path path, mtime = nil
+    data = find_data(path)
+
     if data.respond_to?(:call) then
       data.call
     else
@@ -52,6 +57,30 @@
     end
   end
 
+  # Thanks, FakeWeb!
+  def open_uri_or_path(path)
+    data = find_data(path)
+    body, code, msg = data
+
+    response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg)
+    response.instance_variable_set(:@body, body)
+    response.instance_variable_set(:@read, true)
+    response
+  end
+
+  def request(uri, request_class, last_modified = nil)
+    data = find_data(uri)
+    body, code, msg = data
+
+    @last_request = request_class.new uri.request_uri
+    yield @last_request if block_given?
+
+    response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg)
+    response.instance_variable_set(:@body, body)
+    response.instance_variable_set(:@read, true)
+    response
+  end
+
   def fetch_size(path)
     path = path.to_s
     @paths << path
@@ -68,7 +97,7 @@
   end
 
   def download spec, source_uri, install_dir = Gem.dir
-    name = "#{spec.full_name}.gem"
+    name = spec.file_name
     path = File.join(install_dir, 'cache', name)
 
     Gem.ensure_gem_subdirectories install_dir

Deleted: MacRuby/trunk/lib/rubygems/timer.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/timer.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/timer.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -1,28 +0,0 @@
-#
-# This file defines a $log variable for logging, and a time() method for
-# recording timing information.
-#
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-
-file, lineno = Gem.location_of_caller
-
-warn "#{file}:#{lineno}:Warning: RubyGems' lib/rubygems/timer.rb deprecated and will be removed on or after June 2009."
-
-$log = Object.new
-
-# :stopdoc:
-def $log.debug(message)
-  Gem.debug message
-end
-
-def time(msg, width=25, &block)
-  Gem.time(msg, width, &block)
-end
-# :startdoc:
-

Modified: MacRuby/trunk/lib/rubygems/uninstaller.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/uninstaller.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/uninstaller.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -202,7 +202,7 @@
       spec.name, spec.version, spec.original_platform].join '-'
 
     spec_dir = File.join spec.installation_path, 'specifications'
-    gemspec = File.join spec_dir, "#{spec.full_name}.gemspec"
+    gemspec = File.join spec_dir, spec.spec_name
 
     unless File.exist? gemspec then
       gemspec = File.join spec_dir, "#{original_platform_name}.gemspec"
@@ -211,7 +211,7 @@
     FileUtils.rm_rf gemspec
 
     cache_dir = File.join spec.installation_path, 'cache'
-    gem = File.join cache_dir, "#{spec.full_name}.gem"
+    gem = File.join cache_dir, spec.file_name
 
     unless File.exist? gem then
       gem = File.join cache_dir, "#{original_platform_name}.gem"
@@ -251,7 +251,7 @@
     spec.dependent_gems.each do |gem,dep,satlist|
       msg <<
         ("#{gem.name}-#{gem.version} depends on " +
-        "[#{dep.name} (#{dep.version_requirements})]")
+        "[#{dep.name} (#{dep.requirement})]")
     end
     msg << 'If you remove this gems, one or more dependencies will not be met.'
     msg << 'Continue with Uninstall?'

Modified: MacRuby/trunk/lib/rubygems/user_interaction.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/user_interaction.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/user_interaction.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -112,6 +112,7 @@
    :alert_error,
    :alert_warning,
    :ask,
+   :ask_for_password,
    :ask_yes_no,
    :choose_from_list,
    :say,
@@ -218,6 +219,50 @@
   end
 
   ##
+  # Ask for a password. Does not echo response to terminal.
+
+  def ask_for_password(question)
+    return nil if not @ins.tty?
+
+    @outs.print(question + "  ")
+    @outs.flush
+
+    Gem.win_platform? ? ask_for_password_on_windows : ask_for_password_on_unix
+  end
+
+  ##
+  # Asks for a password that works on windows. Ripped from the Heroku gem.
+
+  def ask_for_password_on_windows
+    require "Win32API"
+    char = nil
+    password = ''
+
+    while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
+      break if char == 10 || char == 13 # received carriage return or newline
+      if char == 127 || char == 8 # backspace and delete
+        password.slice!(-1, 1)
+      else
+        password << char.chr
+      end
+    end
+
+    puts
+    password
+  end
+
+  ##
+  # Asks for a password that works on unix
+
+  def ask_for_password_on_unix
+    system "stty -echo"
+    password = @ins.gets
+    password.chomp! if password
+    system "stty echo"
+    password
+  end
+
+  ##
   # Display a statement.
 
   def say(statement="")

Modified: MacRuby/trunk/lib/rubygems/validator.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/validator.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/validator.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -6,7 +6,7 @@
 
 require 'find'
 
-require 'rubygems/digest/md5'
+require 'digest'
 require 'rubygems/format'
 require 'rubygems/installer'
 
@@ -40,7 +40,7 @@
     sum_data = gem_data.gsub(/MD5SUM = "([a-z0-9]+)"/,
                              "MD5SUM = \"#{"F" * 32}\"")
 
-    unless Gem::MD5.hexdigest(sum_data) == $1.to_s then
+    unless Digest::MD5.hexdigest(sum_data) == $1.to_s then
       raise Gem::VerificationError, 'invalid checksum for gem file'
     end
   end
@@ -93,9 +93,8 @@
       next unless gems.include? gem_spec.name unless gems.empty?
 
       install_dir = gem_spec.installation_path
-      gem_path = File.join(install_dir, "cache", gem_spec.full_name) + ".gem"
-      spec_path = File.join(install_dir, "specifications",
-                            gem_spec.full_name) + ".gemspec"
+      gem_path = File.join install_dir, "cache", gem_spec.file_name
+      spec_path = File.join install_dir, "specifications", gem_spec.spec_name
       gem_directory = gem_spec.full_gem_path
 
       unless File.directory? gem_directory then
@@ -139,8 +138,8 @@
               next unless data # HACK `gem check -a mkrf`
 
               open File.join(gem_directory, entry['path']), Gem.binary_mode do |f|
-                unless Gem::MD5.hexdigest(f.read).to_s ==
-                    Gem::MD5.hexdigest(data).to_s then
+                unless Digest::MD5.hexdigest(f.read).to_s ==
+                    Digest::MD5.hexdigest(data).to_s then
                   errors[gem_name][entry['path']] = "Modified from original"
                 end
               end

Modified: MacRuby/trunk/lib/rubygems/version.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/version.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/version.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -1,9 +1,3 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
 ##
 # The Version class processes string versions into comparable
 # values. A version string should normally be a series of numbers
@@ -24,72 +18,153 @@
 # 2. 1.0.b
 # 3. 1.0.a
 # 4. 0.9
+#
+# == How Software Changes
+#
+# Users expect to be able to specify a version constraint that gives them
+# some reasonable expectation that new versions of a library will work with
+# their software if the version constraint is true, and not work with their
+# software if the version constraint is false.  In other words, the perfect
+# system will accept all compatible versions of the library and reject all
+# incompatible versions.
+#
+# Libraries change in 3 ways (well, more than 3, but stay focused here!).
+#
+# 1. The change may be an implementation detail only and have no effect on
+#    the client software.
+# 2. The change may add new features, but do so in a way that client software
+#    written to an earlier version is still compatible.
+# 3. The change may change the public interface of the library in such a way
+#    that old software is no longer compatible.
+#
+# Some examples are appropriate at this point.  Suppose I have a Stack class
+# that supports a <tt>push</tt> and a <tt>pop</tt> method.
+#
+# === Examples of Category 1 changes:
+#
+# * Switch from an array based implementation to a linked-list based
+#   implementation.
+# * Provide an automatic (and transparent) backing store for large stacks.
+#
+# === Examples of Category 2 changes might be:
+#
+# * Add a <tt>depth</tt> method to return the current depth of the stack.
+# * Add a <tt>top</tt> method that returns the current top of stack (without
+#   changing the stack).
+# * Change <tt>push</tt> so that it returns the item pushed (previously it
+#   had no usable return value).
+#
+# === Examples of Category 3 changes might be:
+#
+# * Changes <tt>pop</tt> so that it no longer returns a value (you must use
+#   <tt>top</tt> to get the top of the stack).
+# * Rename the methods to <tt>push_item</tt> and <tt>pop_item</tt>.
+#
+# == RubyGems Rational Versioning
+#
+# * Versions shall be represented by three non-negative integers, separated
+#   by periods (e.g. 3.1.4).  The first integers is the "major" version
+#   number, the second integer is the "minor" version number, and the third
+#   integer is the "build" number.
+#
+# * A category 1 change (implementation detail) will increment the build
+#   number.
+#
+# * A category 2 change (backwards compatible) will increment the minor
+#   version number and reset the build number.
+#
+# * A category 3 change (incompatible) will increment the major build number
+#   and reset the minor and build numbers.
+#
+# * Any "public" release of a gem should have a different version.  Normally
+#   that means incrementing the build number.  This means a developer can
+#   generate builds all day long for himself, but as soon as he/she makes a
+#   public release, the version must be updated.
+#
+# === Examples
+#
+# Let's work through a project lifecycle using our Stack example from above.
+#
+# Version 0.0.1:: The initial Stack class is release.
+# Version 0.0.2:: Switched to a linked=list implementation because it is
+#                 cooler.
+# Version 0.1.0:: Added a <tt>depth</tt> method.
+# Version 1.0.0:: Added <tt>top</tt> and made <tt>pop</tt> return nil
+#                 (<tt>pop</tt> used to return the  old top item).
+# Version 1.1.0:: <tt>push</tt> now returns the value pushed (it used it
+#                 return nil).
+# Version 1.1.1:: Fixed a bug in the linked list implementation.
+# Version 1.1.2:: Fixed a bug introduced in the last fix.
+#
+# Client A needs a stack with basic push/pop capability.  He writes to the
+# original interface (no <tt>top</tt>), so his version constraint looks
+# like:
+#
+#   gem 'stack', '~> 0.0'
+#
+# Essentially, any version is OK with Client A.  An incompatible change to
+# the library will cause him grief, but he is willing to take the chance (we
+# call Client A optimistic).
+#
+# Client B is just like Client A except for two things: (1) He uses the
+# <tt>depth</tt> method and (2) he is worried about future
+# incompatibilities, so he writes his version constraint like this:
+#
+#   gem 'stack', '~> 0.1'
+#
+# The <tt>depth</tt> method was introduced in version 0.1.0, so that version
+# or anything later is fine, as long as the version stays below version 1.0
+# where incompatibilities are introduced.  We call Client B pessimistic
+# because he is worried about incompatible future changes (it is OK to be
+# pessimistic!).
+#
+# == Preventing Version Catastrophe:
+#
+# From: http://blog.zenspider.com/2008/10/rubygems-howto-preventing-cata.html
+#
+# Let's say you're depending on the fnord gem version 2.y.z. If you
+# specify your dependency as ">= 2.0.0" then, you're good, right? What
+# happens if fnord 3.0 comes out and it isn't backwards compatible
+# with 2.y.z? Your stuff will break as a result of using ">=". The
+# better route is to specify your dependency with a "spermy" version
+# specifier. They're a tad confusing, so here is how the dependency
+# specifiers work:
+#
+#   Specification From  ... To (exclusive)
+#   ">= 3.0"      3.0   ... &infin;
+#   "~> 3.0"      3.0   ... 4.0
+#   "~> 3.0.0"    3.0.0 ... 3.1
+#   "~> 3.5"      3.5   ... 4.0
+#   "~> 3.5.0"    3.5.0 ... 3.6
 
 class Gem::Version
+  include Comparable
 
-  class Part
-    include Comparable
+  VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z]+)*' # :nodoc:
+  ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})*\s*\z/ # :nodoc:
 
-    attr_reader :value
+  ##
+  # A string representation of this Version.
 
-    def initialize(value)
-      @value = (value =~ /\A\d+\z/) ? value.to_i : value
-    end
-
-    def to_s
-      self.value.to_s
-    end
-
-    def inspect
-      @value
-    end
-
-    def alpha?
-      String === value
-    end
-
-    def numeric?
-      Fixnum === value
-    end
-
-    def <=>(other)
-      if    self.numeric? && other.alpha? then
-        1
-      elsif self.alpha? && other.numeric? then
-        -1
-      else
-        self.value <=> other.value
-      end
-    end
-
-    def succ
-      self.class.new(self.value.succ)
-    end
-  end
-
-  include Comparable
-
-  VERSION_PATTERN = '[0-9]+(\.[0-9a-z]+)*'
-
   attr_reader :version
+  alias to_s version
 
-  def self.correct?(version)
-    pattern = /\A\s*(#{VERSION_PATTERN})*\s*\z/
+  ##
+  # True if the +version+ string matches RubyGems' requirements.
 
-    version.is_a? Integer or
-      version =~ pattern or
-      version.to_s =~ pattern
+  def self.correct? version
+    version.to_s =~ ANCHORED_VERSION_PATTERN
   end
 
   ##
-  # Factory method to create a Version object.  Input may be a Version or a
-  # String.  Intended to simplify client code.
+  # Factory method to create a Version object. Input may be a Version
+  # or a String. Intended to simplify client code.
   #
   #   ver1 = Version.create('1.3.17')   # -> (Version object)
   #   ver2 = Version.create(ver1)       # -> (ver1)
   #   ver3 = Version.create(nil)        # -> nil
 
-  def self.create(input)
+  def self.create input
     if input.respond_to? :version then
       input
     elsif input.nil? then
@@ -103,149 +178,131 @@
   # Constructs a Version from the +version+ string.  A version string is a
   # series of digits or ASCII letters separated by dots.
 
-  def initialize(version)
+  def initialize version
     raise ArgumentError, "Malformed version number string #{version}" unless
       self.class.correct?(version)
 
-    self.version = version
-  end
+    @version = version.to_s
+    @version.strip!
 
-  def inspect # :nodoc:
-    "#<#{self.class} #{@version.inspect}>"
+    segments # prime @segments
   end
 
   ##
-  # Dump only the raw version string, not the complete object
+  # Return a new version object where the next to the last revision
+  # number is one greater (e.g., 5.3.1 => 5.4).
+  #
+  # Pre-release (alpha) parts, e.g, 5.3.1.b2 => 5.4, are ignored.
 
-  def marshal_dump
-    [@version]
+  def bump
+    segments = self.segments.dup
+    segments.pop while segments.any? { |s| String === s }
+    segments.pop if segments.size > 1
+
+    segments[-1] = segments[-1].succ
+    self.class.new segments.join(".")
   end
 
   ##
-  # Load custom marshal format
+  # A Version is only eql? to another version if it's specified to the
+  # same precision. Version "1.0" is not the same as version "1".
 
-  def marshal_load(array)
-    self.version = array[0]
+  def eql? other
+    self.class === other and segments == other.segments
   end
 
-  def parts
-    @parts ||= normalize
+  def hash # :nodoc:
+    segments.hash
   end
 
-  ##
-  # Strip ignored trailing zeros.
-
-  def normalize
-    parts_arr = parse_parts_from_version_string
-    if parts_arr.length != 1
-      parts_arr.pop while parts_arr.last && parts_arr.last.value == 0
-      parts_arr = [Part.new(0)] if parts_arr.empty?
-    end
-    parts_arr
+  def inspect # :nodoc:
+    "#<#{self.class} #{version.inspect}>"
   end
 
   ##
-  # Returns the text representation of the version
+  # Dump only the raw version string, not the complete object. It's a
+  # string for backwards (RubyGems 1.3.5 and earlier) compatibility.
 
-  def to_s
-    @version
+  def marshal_dump
+    [version]
   end
 
-  def to_yaml_properties
-    ['@version']
-  end
+  ##
+  # Load custom marshal format. It's a string for backwards (RubyGems
+  # 1.3.5 and earlier) compatibility.
 
-  def version=(version)
-    @version = version.to_s.strip
-    normalize
+  def marshal_load array
+    initialize array[0]
   end
 
   ##
-  # A version is considered a prerelease if any part contains a letter.
+  # A version is considered a prerelease if it contains a letter.
 
   def prerelease?
-    parts.any? { |part| part.alpha? }
+    @prerelease ||= segments.any? { |s| String === s }
   end
-  
-  ##
-  # The release for this version (e.g. 1.2.0.a -> 1.2.0)
-  # Non-prerelease versions return themselves
-  def release
-    return self unless prerelease?
-    rel_parts = parts.dup
-    rel_parts.pop while rel_parts.any? { |part| part.alpha? }
-    self.class.new(rel_parts.join('.'))
-  end
 
-  def yaml_initialize(tag, values)
-    self.version = values['version']
+  def pretty_print q # :nodoc:
+    q.text "Gem::Version.new(#{version.inspect})"
   end
 
   ##
-  # Compares this version with +other+ returning -1, 0, or 1 if the other
-  # version is larger, the same, or smaller than this one.
+  # The release for this version (e.g. 1.2.0.a -> 1.2.0).
+  # Non-prerelease versions return themselves.
 
-  def <=>(other)
-    return nil unless self.class === other
-    return 1 unless other
-    mine, theirs = balance(self.parts.dup, other.parts.dup)
-    mine <=> theirs
-  end
+  def release
+    return self unless prerelease?
 
-  def balance(a, b)
-    a << Part.new(0) while a.size < b.size
-    b << Part.new(0) while b.size < a.size
-    [a, b]
+    segments = self.segments.dup
+    segments.pop while segments.any? { |s| String === s }
+    self.class.new segments.join('.')
   end
 
-  ##
-  # A Version is only eql? to another version if it has the same version
-  # string.  "1.0" is not the same version as "1".
+  def segments # :nodoc:
 
-  def eql?(other)
-    self.class === other and @version == other.version
-  end
+    # @segments is lazy so it can pick up @version values that come
+    # from old marshaled versions, which don't go through
+    # marshal_load. +segments+ is called in +initialize+ to "prime
+    # the pump" in normal cases.
 
-  def hash # :nodoc:
-    @version.hash
+    @segments ||= @version.scan(/[0-9a-z]+/i).map do |s|
+      /^\d+$/ =~ s ? s.to_i : s
+    end
   end
 
   ##
-  # Return a new version object where the next to the last revision number is
-  # one greater. (e.g.  5.3.1 => 5.4)
-  #
-  # Pre-release (alpha) parts are ignored. (e.g 5.3.1.b2 => 5.4)
+  # A recommended version for use with a ~> Requirement.
 
-  def bump
-    parts = parse_parts_from_version_string
-    parts.pop while parts.any? { |part| part.alpha? }
-    parts.pop if parts.size > 1
-    parts[-1] = parts[-1].succ
-    self.class.new(parts.join("."))
-  end
+  def spermy_recommendation
+    segments = self.segments.dup
 
-  def parse_parts_from_version_string # :nodoc:
-    @version.to_s.scan(/[0-9a-z]+/i).map { |s| Part.new(s) }
-  end
+    segments.pop    while segments.any? { |s| String === s }
+    segments.pop    while segments.size > 2
+    segments.push 0 while segments.size < 2
 
-  def pretty_print(q) # :nodoc:
-    q.text "Gem::Version.new(#{@version.inspect})"
+    "~> #{segments.join(".")}"
   end
 
-  #:stopdoc:
+  ##
+  # Compares this version with +other+ returning -1, 0, or 1 if the other
+  # version is larger, the same, or smaller than this one.
 
-  require 'rubygems/requirement'
+  def <=> other
+    return   1 unless other # HACK: comparable with nil? why?
+    return nil unless self.class === other
 
-  ##
-  # Gem::Requirement's original definition is nested in Version.
-  # Although an inappropriate place, current gems specs reference the nested
-  # class name explicitly.  To remain compatible with old software loading
-  # gemspecs, we leave a copy of original definition in Version, but define an
-  # alias Gem::Requirement for use everywhere else.
+    lhsize = segments.size
+    rhsize = other.segments.size
+    limit  = (lhsize > rhsize ? lhsize : rhsize) - 1
 
-  Requirement = ::Gem::Requirement
+    0.upto(limit) do |i|
+      lhs, rhs = segments[i] || 0, other.segments[i] || 0
 
-  # :startdoc:
+      return  -1         if String  === lhs && Numeric === rhs
+      return   1         if Numeric === lhs && String  === rhs
+      return lhs <=> rhs if lhs != rhs
+    end
 
+    return 0
+  end
 end
-

Modified: MacRuby/trunk/lib/rubygems/version_option.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/version_option.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems/version_option.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -6,10 +6,14 @@
 
 require 'rubygems'
 
+##
 # Mixin methods for --version and --platform Gem::Command options.
+
 module Gem::VersionOption
 
+  ##
   # Add the --platform option to the option parser.
+
   def add_platform_option(task = command, *wrap)
     OptionParser.accept Gem::Platform do |value|
       if value == Gem::Platform::RUBY then
@@ -31,7 +35,19 @@
     end
   end
 
+  ##
+  # Add the --prerelease option to the option parser.
+
+  def add_prerelease_option(*wrap)
+    add_option("--[no-]prerelease",
+               "Allow prerelease versions of a gem", *wrap) do |value, options|
+      options[:prerelease] = value
+    end
+  end
+
+  ##
   # Add the --version option to the option parser.
+
   def add_version_option(task = command, *wrap)
     OptionParser.accept Gem::Requirement do |value|
       Gem::Requirement.new value

Modified: MacRuby/trunk/lib/rubygems.rb
===================================================================
--- MacRuby/trunk/lib/rubygems.rb	2010-03-29 20:35:29 UTC (rev 3887)
+++ MacRuby/trunk/lib/rubygems.rb	2010-03-29 20:39:29 UTC (rev 3888)
@@ -9,69 +9,6 @@
 require 'thread'
 require 'etc'
 
-module Gem
-
-  RubyGemsVersion = VERSION = '1.3.5'
-
-  ##
-  # 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 :version_requirement
-
-  end
-
-end
-
-module Kernel
-
-  ##
-  # Use Kernel#gem to activate a specific version of +gem_name+.
-  #
-  # +version_requirements+ is a list of version requirements that the
-  # specified gem must match, most commonly "= example.version.number".  See
-  # Gem::Requirement for how to specify a version requirement.
-  #
-  # If you will be activating the latest version of a gem, there is no need to
-  # call Kernel#gem, Kernel#require will do the right thing for you.
-  #
-  # Kernel#gem returns true if the gem was activated, otherwise false.  If the
-  # gem could not be found, didn't match the version requirements, or a
-  # different version was already activated, an exception will be raised.
-  #
-  # Kernel#gem should be called *before* any require statements (otherwise
-  # RubyGems may load a conflicting library version).
-  #
-  # In older RubyGems versions, the environment variable GEM_SKIP could be
-  # used to skip activation of specified gems, for example to test out changes
-  # that haven't been installed yet.  Now RubyGems defers to -I and the
-  # RUBYLIB environment variable to skip activation of a gem.
-  #
-  # Example:
-  #
-  #   GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
-
-  def gem(gem_name, *version_requirements) # :doc:
-    skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
-    raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
-    Gem.activate(gem_name, *version_requirements)
-  end
-
-  private :gem
-
-end
-
 ##
 # RubyGems is the Ruby standard for publishing and managing third party
 # libraries.
@@ -86,6 +23,7 @@
 #
 # * {Creating Gems}[http://docs.rubygems.org/read/chapter/5]
 # * Gem::Specification
+# * Gem::Version for version dependency notes
 #
 # Further RubyGems documentation can be found at:
 #
@@ -96,7 +34,8 @@
 # == RubyGems Plugins
 #
 # As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or
-# $LOAD_PATH.  Plugins must be named 'rubygems_plugin' are discovered via
+# $LOAD_PATH.  Plugins must be named 'rubygems_plugin' (.rb, .so, etc) and
+# placed at the root of your gem's #require_path.  Plugins are discovered via
 # Gem::find_files then loaded.  Take care when implementing a plugin as your
 # plugin file may be loaded multiple times if multiple versions of your gem
 # are installed.
@@ -122,7 +61,7 @@
 # == Bugs
 #
 # You can submit bugs to the
-# {RubyGems bug tracker}[http://rubyforge.org/tracker/?atid=575&group_id=126&func=browse]
+# {RubyGems bug tracker}[http://rubyforge.org/tracker/?atid=575&group_id=126]
 # on RubyForge
 #
 # == Credits
@@ -131,26 +70,26 @@
 #
 # RubyGems was originally developed at RubyConf 2003 by:
 #
-# * Rich Kilmer -- rich(at)infoether.com
-# * Chad Fowler -- chad(at)chadfowler.com
-# * David Black -- dblack(at)wobblini.net
+# * Rich Kilmer  -- rich(at)infoether.com
+# * Chad Fowler  -- chad(at)chadfowler.com
+# * David Black  -- dblack(at)wobblini.net
 # * Paul Brannan -- paul(at)atdesk.com
-# * Jim Weirch -- {jim(at)weirichhouse.org}[mailto:jim at weirichhouse.org]
+# * Jim Weirch   -- jim(at)weirichhouse.org
 #
 # Contributors:
 #
-# * Gavin Sinclair -- gsinclair(at)soyabean.com.au
-# * George Marrows -- george.marrows(at)ntlworld.com
-# * Dick Davies -- rasputnik(at)hellooperator.net
+# * Gavin Sinclair     -- gsinclair(at)soyabean.com.au
+# * George Marrows     -- george.marrows(at)ntlworld.com
+# * Dick Davies        -- rasputnik(at)hellooperator.net
 # * Mauricio Fernandez -- batsman.geo(at)yahoo.com
-# * Simon Strandgaard -- neoneye(at)adslhome.dk
-# * Dave Glasser -- glasser(at)mit.edu
-# * Paul Duncan -- pabs(at)pablotron.org
-# * Ville Aine -- vaine(at)cs.helsinki.fi
-# * Eric Hodel -- drbrain(at)segment7.net
-# * Daniel Berger -- djberg96(at)gmail.com
-# * Phil Hagelberg -- technomancy(at)gmail.com
-# * Ryan Davis
+# * Simon Strandgaard  -- neoneye(at)adslhome.dk
+# * Dave Glasser       -- glasser(at)mit.edu
+# * Paul Duncan        -- pabs(at)pablotron.org
+# * Ville Aine         -- vaine(at)cs.helsinki.fi
+# * Eric Hodel         -- drbrain(at)segment7.net
+# * Daniel Berger      -- djberg96(at)gmail.com
+# * Phil Hagelberg     -- technomancy(at)gmail.com
+# * Ryan Davis         -- ryand-ruby(at)zenspider.com
 #
 # (If your name is missing, PLEASE let us know!)
 #
@@ -159,30 +98,41 @@
 # -The RubyGems Team
 
 module Gem
+  RubyGemsVersion = VERSION = '1.3.6'
 
   ##
+  # 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 :version_requirement
+  end
+
+  ##
   # Configuration settings from ::RbConfig
 
   ConfigMap = {} unless defined?(ConfigMap)
 
   require 'rbconfig'
-  # :stopdoc:
-  RbConfig = Config unless defined? ::RbConfig
-  # :startdoc:
 
   ConfigMap.merge!(
-    :EXEEXT => RbConfig::CONFIG["EXEEXT"],
-    :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
-    :arch => RbConfig::CONFIG["arch"],
-    :bindir => RbConfig::CONFIG["bindir"],
-    :datadir => RbConfig::CONFIG["datadir"],
-    :libdir => RbConfig::CONFIG["libdir"],
+    :EXEEXT            => RbConfig::CONFIG["EXEEXT"],
+    :RUBY_SO_NAME      => RbConfig::CONFIG["RUBY_SO_NAME"],
+    :arch              => RbConfig::CONFIG["arch"],
+    :bindir            => RbConfig::CONFIG["bindir"],
+    :datadir           => RbConfig::CONFIG["datadir"],
+    :libdir            => RbConfig::CONFIG["libdir"],
     :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
-    :ruby_version => RbConfig::CONFIG["ruby_version"],
-    :sitedir => RbConfig::CONFIG["sitedir"],
-    :sitelibdir => RbConfig::CONFIG["sitelibdir"],
-    :vendordir => RbConfig::CONFIG["vendordir"] ,
-    :vendorlibdir => RbConfig::CONFIG["vendorlibdir"]
+    :ruby_version      => RbConfig::CONFIG["ruby_version"],
+    :sitedir           => RbConfig::CONFIG["sitedir"],
+    :sitelibdir        => RbConfig::CONFIG["sitelibdir"],
+    :vendordir         => RbConfig::CONFIG["vendordir"] ,
+    :vendorlibdir      => RbConfig::CONFIG["vendorlibdir"]
   )
 
   ##
@@ -253,11 +203,11 @@
     end
 
     unless gem.respond_to?(:name) and
-           gem.respond_to?(:version_requirements) then
+           gem.respond_to?(:requirement) then
       gem = Gem::Dependency.new(gem, version_requirements)
     end
 
-    matches = Gem.source_index.find_name(gem.name, gem.version_requirements)
+    matches = Gem.source_index.find_name(gem.name, gem.requirement)
     report_activate_error(gem) if matches.empty?
 
     if @loaded_specs[gem.name] then
@@ -275,7 +225,7 @@
 
          e = Gem::LoadError.new msg
          e.name = gem.name
-         e.version_requirement = gem.version_requirements
+         e.version_requirement = gem.requirement
 
          raise e
       end
@@ -351,7 +301,7 @@
     requirements = Gem::Requirement.default if requirements.empty?
 
     unless gem.respond_to?(:name) and
-           gem.respond_to?(:version_requirements) then
+           gem.respond_to?(:requirement) then
       gem = Gem::Dependency.new gem, requirements
     end
 
@@ -546,22 +496,22 @@
   #   least on Win32).
 
   def self.find_home
-    ['HOME', 'USERPROFILE'].each do |homekey|
-      return ENV[homekey] if ENV[homekey]
-    end
+    unless RUBY_VERSION > '1.9' then
+      ['HOME', 'USERPROFILE'].each do |homekey|
+        return ENV[homekey] if ENV[homekey]
+      end
 
-    if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
-      return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
+      if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
+        return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
+      end
     end
 
-    begin
-      File.expand_path("~")
-    rescue
-      if File::ALT_SEPARATOR then
-          "C:/"
-      else
-          "/"
-      end
+    File.expand_path "~"
+  rescue
+    if File::ALT_SEPARATOR then
+      "C:/"
+    else
+      "/"
     end
   end
 
@@ -815,15 +765,15 @@
 
     if matches.empty? then
       error = Gem::LoadError.new(
-          "Could not find RubyGem #{gem.name} (#{gem.version_requirements})\n")
+          "Could not find RubyGem #{gem.name} (#{gem.requirement})\n")
     else
       error = Gem::LoadError.new(
           "RubyGem version error: " +
-          "#{gem.name}(#{matches.first.version} not #{gem.version_requirements})\n")
+          "#{gem.name}(#{matches.first.version} not #{gem.requirement})\n")
     end
 
     error.name = gem.name
-    error.version_requirement = gem.version_requirements
+    error.version_requirement = gem.requirement
     raise error
   end
 
@@ -894,9 +844,8 @@
   # Set the Gem home directory (as reported by Gem.dir).
 
   def self.set_home(home)
-    home = home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+    home = home.gsub File::ALT_SEPARATOR, File::SEPARATOR if File::ALT_SEPARATOR
     @gem_home = home
-    ensure_gem_subdirectories(@gem_home)
   end
 
   private_class_method :set_home
@@ -921,18 +870,6 @@
     end
 
     @gem_path.uniq!
-    @gem_path.each do |path|
-      if 0 == File.expand_path(path).index(Gem.user_home)
-        next unless File.directory? Gem.user_home
-        unless win_platform? then
-          # only create by matching user
-          if Etc.getpwuid.nil? || Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid
-            next
-          end
-        end
-      end
-      ensure_gem_subdirectories path
-    end
   end
 
   private_class_method :set_paths
@@ -1085,21 +1022,55 @@
 
 end
 
-module Config
-  # :stopdoc:
-  class << self
-    # Return the path to the data directory associated with the named
-    # package.  If the package is loaded as a gem, return the gem
-    # specific data directory.  Otherwise return a path to the share
-    # area as define by "#{ConfigMap[:datadir]}/#{package_name}".
-    def datadir(package_name)
-      Gem.datadir(package_name) ||
-        File.join(Gem::ConfigMap[:datadir], package_name)
-    end
+module Kernel
+
+  ##
+  # Use Kernel#gem to activate a specific version of +gem_name+.
+  #
+  # +version_requirements+ is a list of version requirements that the
+  # specified gem must match, most commonly "= example.version.number".  See
+  # Gem::Requirement for how to specify a version requirement.
+  #
+  # If you will be activating the latest version of a gem, there is no need to
+  # call Kernel#gem, Kernel#require will do the right thing for you.
+  #
+  # Kernel#gem returns true if the gem was activated, otherwise false.  If the
+  # gem could not be found, didn't match the version requirements, or a
+  # different version was already activated, an exception will be raised.
+  #
+  # Kernel#gem should be called *before* any require statements (otherwise
+  # RubyGems may load a conflicting library version).
+  #
+  # In older RubyGems versions, the environment variable GEM_SKIP could be
+  # used to skip activation of specified gems, for example to test out changes
+  # that haven't been installed yet.  Now RubyGems defers to -I and the
+  # RUBYLIB environment variable to skip activation of a gem.
+  #
+  # Example:
+  #
+  #   GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
+
+  def gem(gem_name, *version_requirements) # :doc:
+    skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
+    raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
+    Gem.activate(gem_name, *version_requirements)
   end
-  # :startdoc:
+
+  private :gem
+
 end
 
+##
+# Return the path to the data directory associated with the named package.  If
+# the package is loaded as a gem, return the gem specific data directory.
+# Otherwise return a path to the share area as define by
+# "#{ConfigMap[:datadir]}/#{package_name}".
+
+def RbConfig.datadir(package_name)
+  Gem.datadir(package_name) ||
+    File.join(Gem::ConfigMap[:datadir], package_name)
+end
+
 require 'rubygems/exceptions'
 require 'rubygems/version'
 require 'rubygems/requirement'
@@ -1133,6 +1104,12 @@
 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 => e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100329/b1950d01/attachment-0001.html>


More information about the macruby-changes mailing list