[前][次][番号順一覧][スレッド一覧]

ruby-changes:5885

From: drbrain <ko1@a...>
Date: Wed, 18 Jun 2008 09:04:41 +0900 (JST)
Subject: [ruby-changes:5885] Ruby:r17393 (trunk): Fix RubyGems for 1.9, r1780

drbrain	2008-06-18 08:59:31 +0900 (Wed, 18 Jun 2008)

  New Revision: 17393

  Modified files:
    trunk/ChangeLog
    trunk/gem_prelude.rb
    trunk/lib/rubygems/commands/install_command.rb
    trunk/lib/rubygems/commands/query_command.rb
    trunk/lib/rubygems/commands/sources_command.rb
    trunk/lib/rubygems/dependency_installer.rb
    trunk/lib/rubygems/rubygems_version.rb
    trunk/lib/rubygems/source_index.rb
    trunk/lib/rubygems/validator.rb
    trunk/test/rubygems/test_gem_source_index.rb

  Log:
    Fix RubyGems for 1.9, r1780

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rubygems/test_gem_source_index.rb?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rubygems/commands/sources_command.rb?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rubygems/source_index.rb?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rubygems/rubygems_version.rb?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rubygems/commands/query_command.rb?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rubygems/validator.rb?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/gem_prelude.rb?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rubygems/commands/install_command.rb?r1=17393&r2=17392&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rubygems/dependency_installer.rb?r1=17393&r2=17392&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17392)
+++ ChangeLog	(revision 17393)
@@ -1,3 +1,10 @@
+Wed Jun 18 08:58:16 2008  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems/*:  Fix errors for 1.9.
+
+	* gem_prelude.rb:  Only remove methods from gem_prelude.rb when
+	loading real RubyGems.
+
 Wed Jun 18 07:03:30 2008  Eric Hodel  <drbrain@e...>
 
 	* lib/rubygems/*:  Update to RubyGems r1778 (pre 1.2).
Index: gem_prelude.rb
===================================================================
--- gem_prelude.rb	(revision 17392)
+++ gem_prelude.rb	(revision 17393)
@@ -1,9 +1,5 @@
 # depends on: array.rb dir.rb env.rb file.rb hash.rb module.rb regexp.rb
 
-# empty gem_prelude.rb
-#
-# p defined?(Gem)
-
 if defined?(Gem) then
 
   module Kernel
@@ -28,73 +24,69 @@
       :ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
     }
 
-    class << self
-
-      def default_dir
-        if defined? RUBY_FRAMEWORK_VERSION
-          return File.join(File.dirname(ConfigMap[:sitedir]), "Gems")
-        else
-          File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
-        end
+    def self.default_dir
+      if defined? RUBY_FRAMEWORK_VERSION
+        return File.join(File.dirname(ConfigMap[:sitedir]), "Gems")
+      else
+        File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
       end
+    end
 
-      def dir
-        @gem_home ||= nil
-        set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
-        @gem_home
-      end
+    def self.dir
+      @gem_home ||= nil
+      set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
+      @gem_home
+    end
 
-      def path
-        @gem_path ||= nil
-        unless @gem_path
-          paths = [ENV['GEM_PATH']]
-          paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
-          set_paths(paths.compact.join(File::PATH_SEPARATOR))
-        end
-        @gem_path
+    def self.path
+      @gem_path ||= nil
+      unless @gem_path
+        paths = [ENV['GEM_PATH']]
+        paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
+        set_paths(paths.compact.join(File::PATH_SEPARATOR))
       end
+      @gem_path
+    end
 
-      # Set the Gem home directory (as reported by +dir+).
-      def set_home(home)
-        @gem_home = home
-        ensure_gem_subdirectories(@gem_home)
-      end
+    # Set the Gem home directory (as reported by +dir+).
+    def self.set_home(home)
+      @gem_home = home
+      ensure_gem_subdirectories(@gem_home)
+    end
 
-      def set_paths(gpaths)
-        if gpaths
-          @gem_path = gpaths.split(File::PATH_SEPARATOR)
-          @gem_path << Gem.dir
-        else
-          @gem_path = [Gem.dir]
-        end
-        @gem_path.uniq!
-        @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
+    def self.set_paths(gpaths)
+      if gpaths
+        @gem_path = gpaths.split(File::PATH_SEPARATOR)
+        @gem_path << Gem.dir
+      else
+        @gem_path = [Gem.dir]
       end
+      @gem_path.uniq!
+      @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
+    end
 
-      def ensure_gem_subdirectories(path)
-      end
-
+    def self.ensure_gem_subdirectories(path)
     end
 
+    GEM_PRELUDE_METHODS = Gem.methods(false)
+
     module QuickLoader
 
-      class << self
-        def load_full_rubygems_library
-          class << Gem
-            Gem.methods(false).each do |method_name|
-              undef_method method_name
-            end
+      def self.load_full_rubygems_library
+        class << Gem
+          Gem::GEM_PRELUDE_METHODS.each do |method_name|
+            undef_method method_name
           end
+        end
 
-          Kernel.module_eval do
-            undef_method :gem if method_defined? :gem
-          end
+        Kernel.module_eval do
+          undef_method :gem if method_defined? :gem
+        end
 
-          $".delete File.join(Gem::ConfigMap[:libdir], 'ruby',
-                              Gem::ConfigMap[:ruby_version], 'rubygems.rb')
+        $".delete File.join(Gem::ConfigMap[:libdir], 'ruby',
+                            Gem::ConfigMap[:ruby_version], 'rubygems.rb')
 
-          require 'rubygems'
-        end
+        require 'rubygems'
       end
 
       GemPaths = {}
Index: lib/rubygems/validator.rb
===================================================================
--- lib/rubygems/validator.rb	(revision 17392)
+++ lib/rubygems/validator.rb	(revision 17393)
@@ -42,7 +42,7 @@
     # 
     # gem_path:: [String] Path to gem file
     def verify_gem_file(gem_path)
-      File.open gem_path, 'rb' do |file|
+      open gem_path, Gem.binary_mode do |file|
         gem_data = file.read
         verify_gem gem_data
       end
@@ -91,7 +91,7 @@
     
         begin
           verify_gem_file(gem_path)
-          File.open(gem_path, 'rb') do |file|
+          open gem_path, Gem.binary_mode do |file|
             format = Gem::Format.from_file_by_path(gem_path)
             format.file_entries.each do |entry, data|
               # Found this file.  Delete it from list
@@ -99,7 +99,7 @@
 
               next unless data # HACK `gem check -a mkrf`
 
-              File.open(File.join(gem_directory, entry['path']), 'rb') do |f|
+              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
                   errors[gem_name] << ErrorData.new(entry['path'], "installed file doesn't match original from gem")
Index: lib/rubygems/dependency_installer.rb
===================================================================
--- lib/rubygems/dependency_installer.rb	(revision 17392)
+++ lib/rubygems/dependency_installer.rb	(revision 17393)
@@ -133,7 +133,7 @@
         deps.each do |dep|
           results = find_gems_with_sources(dep).reverse
 
-          results.reject! do |spec,|
+          results.reject! do
             @source_index.any? do |_, installed_spec|
               dep.name == installed_spec.name and
                 dep.version_requirements.satisfied_by? installed_spec.version
Index: lib/rubygems/source_index.rb
===================================================================
--- lib/rubygems/source_index.rb	(revision 17392)
+++ lib/rubygems/source_index.rb	(revision 17393)
@@ -300,14 +300,12 @@
     outdateds = []
 
     latest_specs.each do |local|
-      name = local.name
+      dependency = Gem::Dependency.new local.name, ">= #{local.version}"
 
-      dependency = Gem::Dependency.new name, ">= #{local.version}"
-
       begin
         fetcher = Gem::SpecFetcher.fetcher
         remotes = fetcher.find_matching dependency
-        remotes = remotes.map { |(name, version,),| version }
+        remotes = remotes.map { |(name, version,_),_| version }
       rescue Gem::RemoteFetcher::FetchError => e
         raise unless fetcher.warn_legacy e do
           require 'rubygems/source_info_cache'
@@ -320,7 +318,7 @@
 
       latest = remotes.sort.last
 
-      outdateds << name if latest and local.version < latest
+      outdateds << local.name if latest and local.version < latest
     end
 
     outdateds
Index: lib/rubygems/commands/sources_command.rb
===================================================================
--- lib/rubygems/commands/sources_command.rb	(revision 17392)
+++ lib/rubygems/commands/sources_command.rb	(revision 17393)
@@ -111,10 +111,10 @@
       fetcher = Gem::SpecFetcher.fetcher
 
       if fetcher.legacy_repos.empty? then
-        Gem.sources.each do |source_uri|
-          source_uri = URI.parse source_uri
-          fetcher.load_specs source_uri, 'specs'
-          fetcher.load_specs source_uri, 'latest_specs'
+        Gem.sources.each do |update_uri|
+          update_uri = URI.parse update_uri
+          fetcher.load_specs update_uri, 'specs'
+          fetcher.load_specs update_uri, 'latest_specs'
         end
       else
         Gem::SourceInfoCache.cache true
Index: lib/rubygems/commands/query_command.rb
===================================================================
--- lib/rubygems/commands/query_command.rb	(revision 17392)
+++ lib/rubygems/commands/query_command.rb	(revision 17393)
@@ -131,18 +131,18 @@
       versions[spec_tuple.first] << [spec_tuple, source_uri]
     end
 
-    versions = versions.sort_by do |(name,),|
+    versions = versions.sort_by do |(name,_),_|
       name.downcase
     end
 
     versions.each do |gem_name, matching_tuples|
-      matching_tuples = matching_tuples.sort_by do |(name, version,),|
+      matching_tuples = matching_tuples.sort_by do |(name, version,_),_|
         version
       end.reverse
 
       seen = {}
 
-      matching_tuples.delete_if do |(name, version,),|
+      matching_tuples.delete_if do |(name, version,_),_|
         if seen[version] then
           true
         else
@@ -154,7 +154,7 @@
       entry = gem_name.dup
 
       if options[:versions] then
-        versions = matching_tuples.map { |(name, version,),| version }.uniq
+        versions = matching_tuples.map { |(name, version,_),_| version }.uniq
         entry << " (#{versions.join ', '})"
       end
 
Index: lib/rubygems/commands/install_command.rb
===================================================================
--- lib/rubygems/commands/install_command.rb	(revision 17392)
+++ lib/rubygems/commands/install_command.rb	(revision 17393)
@@ -50,7 +50,11 @@
 
     installed_gems = []
 
-    ENV['GEM_PATH'] = options[:install_dir] # HACK what does this do?
+    if options[:install_dir].nil? and RUBY_VERSION > '1.9' then
+      ENV.delete 'GEM_PATH'
+    else
+      ENV['GEM_PATH'] = options[:install_dir] # HACK what does this do?
+    end
 
     install_options = {
       :env_shebang => options[:env_shebang],
Index: lib/rubygems/rubygems_version.rb
===================================================================
--- lib/rubygems/rubygems_version.rb	(revision 17392)
+++ lib/rubygems/rubygems_version.rb	(revision 17393)
@@ -2,5 +2,5 @@
 # This file is auto-generated by build scripts.
 # See:  rake update_version
 module Gem
-  RubyGemsVersion = '1.1.1.1778'
+  RubyGemsVersion = '1.1.1'
 end
Index: test/rubygems/test_gem_source_index.rb
===================================================================
--- test/rubygems/test_gem_source_index.rb	(revision 17392)
+++ test/rubygems/test_gem_source_index.rb	(revision 17393)
@@ -128,13 +128,8 @@
 
     assert_equal '', @ui.output
 
-    expected = <<-EOF
-WARNING:  compile error
-#{spec_file}:1: syntax error, unexpected $end
-WARNING:  1 +
-    EOF
-
-    assert_equal expected, @ui.error
+    assert_match(/syntax error/, @ui.error)
+    assert_match(/1 \+/, @ui.error)
   end
 
   def test_self_load_specification_system_exit

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]