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

ruby-changes:31767

From: drbrain <ko1@a...>
Date: Tue, 26 Nov 2013 04:15:04 +0900 (JST)
Subject: [ruby-changes:31767] drbrain:r43845 (trunk): * lib/rubygems: Update to RubyGems master 612f85a. Notable changes:

drbrain	2013-11-26 04:14:49 +0900 (Tue, 26 Nov 2013)

  New Revision: 43845

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43845

  Log:
    * lib/rubygems:  Update to RubyGems master 612f85a.  Notable changes:
    
      Fixed installation and activation of git: and path: gems via
      Gem.use_gemdeps
    
      Improved documentation coverage
    
    * test/rubygems:  ditto.

  Added files:
    trunk/lib/rubygems/resolver/local_specification.rb
    trunk/test/rubygems/test_gem_resolver_local_specification.rb
    trunk/test/rubygems/test_gem_resolver_specification.rb
  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/available_set.rb
    trunk/lib/rubygems/basic_specification.rb
    trunk/lib/rubygems/installer.rb
    trunk/lib/rubygems/installer_test_case.rb
    trunk/lib/rubygems/request_set.rb
    trunk/lib/rubygems/resolver/activation_request.rb
    trunk/lib/rubygems/resolver/api_specification.rb
    trunk/lib/rubygems/resolver/conflict.rb
    trunk/lib/rubygems/resolver/dependency_request.rb
    trunk/lib/rubygems/resolver/git_specification.rb
    trunk/lib/rubygems/resolver/installed_specification.rb
    trunk/lib/rubygems/resolver/installer_set.rb
    trunk/lib/rubygems/resolver/requirement_list.rb
    trunk/lib/rubygems/resolver/specification.rb
    trunk/lib/rubygems/resolver/vendor_set.rb
    trunk/lib/rubygems/resolver/vendor_specification.rb
    trunk/lib/rubygems/resolver.rb
    trunk/lib/rubygems/security/trust_dir.rb
    trunk/lib/rubygems/source/git.rb
    trunk/lib/rubygems/test_utilities.rb
    trunk/lib/rubygems/user_interaction.rb
    trunk/lib/rubygems/util.rb
    trunk/lib/rubygems.rb
    trunk/test/rubygems/test_gem_available_set.rb
    trunk/test/rubygems/test_gem_dependency_installer.rb
    trunk/test/rubygems/test_gem_resolver.rb
    trunk/test/rubygems/test_gem_resolver_api_specification.rb
    trunk/test/rubygems/test_gem_resolver_git_specification.rb
    trunk/test/rubygems/test_gem_resolver_index_specification.rb
    trunk/test/rubygems/test_gem_resolver_installed_specification.rb
    trunk/test/rubygems/test_gem_resolver_vendor_set.rb
    trunk/test/rubygems/test_gem_resolver_vendor_specification.rb
    trunk/test/rubygems/test_gem_source_git.rb
    trunk/test/rubygems/test_gem_util.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43844)
+++ ChangeLog	(revision 43845)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Nov 26 04:12:10 2013  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems:  Update to RubyGems master 612f85a.  Notable changes:
+
+	  Fixed installation and activation of git: and path: gems via
+	  Gem.use_gemdeps
+
+	  Improved documentation coverage
+
+	* test/rubygems:  ditto.
+
 Mon Nov 25 22:23:03 2013  Zachary Scott  <e@z...>
 
 	* lib/xmlrpc.rb: [DOC] Fix link to xmlrpc4r site [Bug #9148]
Index: lib/rubygems/basic_specification.rb
===================================================================
--- lib/rubygems/basic_specification.rb	(revision 43844)
+++ lib/rubygems/basic_specification.rb	(revision 43845)
@@ -9,6 +9,11 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L9
 
   attr_reader :loaded_from
 
+  ##
+  # Allows correct activation of git: and path: gems.
+
+  attr_writer :full_gem_path # :nodoc:
+
   def self.default_specifications_dir
     File.join(Gem.default_dir, "specifications", "default")
   end
Index: lib/rubygems/installer_test_case.rb
===================================================================
--- lib/rubygems/installer_test_case.rb	(revision 43844)
+++ lib/rubygems/installer_test_case.rb	(revision 43845)
@@ -56,11 +56,6 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer_test_case.rb#L56
   ##
   # Available through requiring rubygems/installer_test_case
 
-  attr_writer :spec
-
-  ##
-  # Available through requiring rubygems/installer_test_case
-
   attr_writer :wrappers
 end
 
Index: lib/rubygems/available_set.rb
===================================================================
--- lib/rubygems/available_set.rb	(revision 43844)
+++ lib/rubygems/available_set.rb	(revision 43845)
@@ -127,7 +127,7 @@ class Gem::AvailableSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/available_set.rb#L127
     end
 
     match.map do |t|
-      Gem::Resolver::InstalledSpecification.new(self, t.spec, t.source)
+      Gem::Resolver::LocalSpecification.new(self, t.spec, t.source)
     end
   end
 
Index: lib/rubygems/request_set.rb
===================================================================
--- lib/rubygems/request_set.rb	(revision 43844)
+++ lib/rubygems/request_set.rb	(revision 43845)
@@ -166,29 +166,22 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L166
 
     installed = []
 
-    sorted_requests.each do |req|
-      if existing.find { |s| s.full_name == req.spec.full_name }
-        yield req, nil if block_given?
-        next
-      end
+    options[:install_dir] = dir
+    options[:only_install_dir] = true
 
-      path = req.download(dir)
+    sorted_requests.each do |request|
+      spec = request.spec
 
-      unless path then # already installed
-        yield req, nil if block_given?
+      if existing.find { |s| s.full_name == spec.full_name } then
+        yield request, nil if block_given?
         next
       end
 
-      options[:install_dir] = dir
-      options[:only_install_dir] = true
-
-      inst = Gem::Installer.new path, options
-
-      yield req, inst if block_given?
-
-      inst.install
+      spec.install options do |installer|
+        yield request, installer if block_given?
+      end
 
-      installed << req
+      installed << request
     end
 
     installed
Index: lib/rubygems/source/git.rb
===================================================================
--- lib/rubygems/source/git.rb	(revision 43844)
+++ lib/rubygems/source/git.rb	(revision 43845)
@@ -91,8 +91,8 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L91
       success = system @git, 'reset', '--quiet', '--hard', @reference
 
       success &&=
-        system @git, 'submodule', 'update',
-               '--quiet', '--init', '--recursive', out: IO::NULL if @need_submodules
+        Gem::Util.silent_system @git, 'submodule', 'update',
+               '--quiet', '--init', '--recursive' if @need_submodules
 
       success
     end
@@ -161,7 +161,9 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L161
         file      = File.basename spec_file
 
         Dir.chdir directory do
-          Gem::Specification.load file
+          spec = Gem::Specification.load file
+          spec.full_gem_path = File.expand_path '.' if spec
+          spec
         end
       end.compact
     end
Index: lib/rubygems/security/trust_dir.rb
===================================================================
--- lib/rubygems/security/trust_dir.rb	(revision 43844)
+++ lib/rubygems/security/trust_dir.rb	(revision 43845)
@@ -1,10 +1,26 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/security/trust_dir.rb#L1
+##
+# The TrustDir manages the trusted certificates for gem signature
+# verification.
+
 class Gem::Security::TrustDir
 
+  ##
+  # Default permissions for the trust directory and its contents
+
   DEFAULT_PERMISSIONS = {
     :trust_dir    => 0700,
     :trusted_cert => 0600,
   }
 
+  ##
+  # The directory where trusted certificates will be stored.
+
+  attr_reader :dir
+
+  ##
+  # Creates a new TrustDir using +dir+ where the directory and file
+  # permissions will be checked according to +permissions+
+
   def initialize dir, permissions = DEFAULT_PERMISSIONS
     @dir = dir
     @permissions = permissions
@@ -12,8 +28,6 @@ class Gem::Security::TrustDir https://github.com/ruby/ruby/blob/trunk/lib/rubygems/security/trust_dir.rb#L28
     @digester = Gem::Security::DIGEST_ALGORITHM
   end
 
-  attr_reader :dir
-
   ##
   # Returns the path to the trusted +certificate+
 
Index: lib/rubygems/util.rb
===================================================================
--- lib/rubygems/util.rb	(revision 43844)
+++ lib/rubygems/util.rb	(revision 43845)
@@ -1,4 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/util.rb#L1
+##
+# This module contains various utility methods as module methods.
+
 module Gem::Util
+
+  @silent_mutex = nil
+
   ##
   # Zlib::GzipReader wrapper that unzips +data+.
 
@@ -60,4 +66,56 @@ module Gem::Util https://github.com/ruby/ruby/blob/trunk/lib/rubygems/util.rb#L66
     end
   end
 
+  ##
+  # Invokes system, but silences all output.
+
+  def self.silent_system *command
+    require 'thread'
+
+    @silent_mutex ||= Mutex.new
+
+    null_device = Gem.win_platform? ? 'NUL' : '/dev/null'
+
+    @silent_mutex.synchronize do
+      begin
+        stdout = STDOUT.dup
+        stderr = STDERR.dup
+
+        STDOUT.reopen null_device, 'w'
+        STDERR.reopen null_device, 'w'
+
+        return system(*command)
+      ensure
+        STDOUT.reopen stdout
+        STDERR.reopen stderr
+      end
+    end
+  end
+
+  ##
+  # Enumerates the parents of +directory+.
+
+  def self.traverse_parents directory
+    return enum_for __method__, directory unless block_given?
+
+    here = File.expand_path directory
+    start = here
+
+    Dir.chdir start
+
+    begin
+      loop do
+        yield here
+
+        Dir.chdir '..'
+
+        return if Dir.pwd == here # toplevel
+
+        here = Dir.pwd
+      end
+    ensure
+      Dir.chdir start
+    end
+  end
+
 end
Index: lib/rubygems/user_interaction.rb
===================================================================
--- lib/rubygems/user_interaction.rb	(revision 43844)
+++ lib/rubygems/user_interaction.rb	(revision 43845)
@@ -666,6 +666,11 @@ end https://github.com/ruby/ruby/blob/trunk/lib/rubygems/user_interaction.rb#L666
 # STDOUT, and STDERR.
 
 class Gem::ConsoleUI < Gem::StreamUI
+
+  ##
+  # The Console UI has no arguments as it defaults to reading input from
+  # stdin, output to stdout and warnings or errors to stderr.
+
   def initialize
     super STDIN, STDOUT, STDERR, true
   end
@@ -675,6 +680,10 @@ end https://github.com/ruby/ruby/blob/trunk/lib/rubygems/user_interaction.rb#L680
 # SilentUI is a UI choice that is absolutely silent.
 
 class Gem::SilentUI < Gem::StreamUI
+
+  ##
+  # The SilentUI has no arguments as it does not use any stream.
+
   def initialize
     reader, writer = nil, nil
 
@@ -689,11 +698,11 @@ class Gem::SilentUI < Gem::StreamUI https://github.com/ruby/ruby/blob/trunk/lib/rubygems/user_interaction.rb#L698
     super reader, writer, writer, false
   end
 
-  def download_reporter(*args)
+  def download_reporter(*args) # :nodoc:
     SilentDownloadReporter.new(@outs, *args)
   end
 
-  def progress_reporter(*args)
+  def progress_reporter(*args) # :nodoc:
     SilentProgressReporter.new(@outs, *args)
   end
 end
Index: lib/rubygems/installer.rb
===================================================================
--- lib/rubygems/installer.rb	(revision 43844)
+++ lib/rubygems/installer.rb	(revision 43845)
@@ -57,6 +57,11 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L57
 
   attr_reader :options
 
+  ##
+  # Sets the specification for .gem-less installs.
+
+  attr_writer :spec
+
   @path_warning = false
 
   class << self
Index: lib/rubygems/resolver/installed_specification.rb
===================================================================
--- lib/rubygems/resolver/installed_specification.rb	(revision 43844)
+++ lib/rubygems/resolver/installed_specification.rb	(revision 43845)
@@ -11,16 +11,22 @@ class Gem::Resolver::InstalledSpecificat https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/installed_specification.rb#L11
   end
 
   ##
+  # This is a null install as this specification is already installed.
+  # +options+ are ignored.
+
+  def install options
+    yield nil
+  end
+
+  ##
   # Returns +true+ if this gem is installable for the current platform.
 
   def installable_platform?
     # BACKCOMPAT If the file is coming out of a specified file, then we
     # ignore the platform. This code can be removed in RG 3.0.
-    if @source.kind_of? Gem::Source::SpecificFile
-      return true
-    else
-      Gem::Platform.match @spec.platform
-    end
+    return true if @source.kind_of? Gem::Source::SpecificFile
+
+    super
   end
 
   ##
Index: lib/rubygems/resolver/specification.rb
===================================================================
--- lib/rubygems/resolver/specification.rb	(revision 43844)
+++ lib/rubygems/resolver/specification.rb	(revision 43845)
@@ -56,5 +56,34 @@ class Gem::Resolver::Specification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/specification.rb#L56
     "#{@name}-#{@version}"
   end
 
+  ##
+  # Installs this specification using the Gem::Installer +options+.  The
+  # install method yields a Gem::Installer instance, which indicates the
+  # gem will be installed, or +nil+, which indicates the gem is already
+  # installed.
+
+  def install options
+    require 'rubygems/installer'
+
+    destination = options[:install_dir] || Gem.dir
+
+    Gem.ensure_gem_subdirectories destination
+
+    gem = source.download spec, destination
+
+    installer = Gem::Installer.new gem, options
+
+    yield installer if block_given?
+
+    installer.install
+  end
+
+  ##
+  # Returns true if this specification is installable on this platform.
+
+  def installable_platform?
+    Gem::Platform.match spec.platform
+  end
+
 end
 
Index: lib/rubygems/resolver/git_specification.rb
===================================================================
--- lib/rubygems/resolver/git_specification.rb	(revision 43844)
+++ lib/rubygems/resolver/git_specification.rb	(revision 43845)
@@ -12,5 +12,24 @@ class Gem::Resolver::GitSpecification < https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/git_specification.rb#L12
       @source == other.source
   end
 
+  ##
+  # Installing a git gem only involves building the extensions and generating
+  # the executables.
+
+  def install options
+    require 'rubygems/installer'
+
+    installer = Gem::Installer.new '', options
+    installer.spec = spec
+
+    yield installer if block_given?
+
+    installer.run_pre_install_hooks
+    installer.build_extensions
+    installer.run_post_build_hooks
+    installer.generate_bin
+    installer.run_post_install_hooks
+  end
+
 end
 
Index: lib/rubygems/resolver/dependency_request.rb
===================================================================
--- lib/rubygems/resolver/dependency_request.rb	(revision 43844)
+++ lib/rubygems/resolver/dependency_request.rb	(revision 43845)
@@ -4,16 +4,26 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/dependency_request.rb#L4
 
 class Gem::Resolver::DependencyRequest
 
+  ##
+  # The wrapped Gem::Dependency
+
   attr_reader :dependency
 
+  ##
+  # The request for this dependency.
+
   attr_reader :requester
 
-  def initialize(dep, act)
-    @dependency = dep
-    @requester = act
+  ##
+  # Creates a new DependencyRequest for +dependency+ from +requester+.
+  # +requester may be nil if the request came from a user.
+
+  def initialize dependency, requester
+    @dependency = dependency
+    @requester  = requester
   end
 
-  def ==(other)
+  def == other # :nodoc:
     case other
     when Gem::Dependency
       @dependency == other
@@ -24,26 +34,39 @@ class Gem::Resolver::DependencyRequest https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/dependency_request.rb#L34
     end
   end
 
+  ##
+  # Does this dependency request match +spec+
+
   def matches_spec?(spec)
     @dependency.matches_spec? spec
   end
 
+  ##
+  # The name of the gem this dependency request is requesting.
+
   def name
     @dependency.name
   end
 
+  ##
   # Indicate that the request is for a gem explicitly requested by the user
+
   def explicit?
     @requester.nil?
   end
 
-  # Indicate that the requset is for a gem requested as a dependency of another gem
+  ##
+  # Indicate that the request is for a gem requested as a dependency of
+  # another gem
+
   def implicit?
     !explicit?
   end
 
+  ##
   # Return a String indicating who caused this request to be added (only
   # valid for implicit requests)
+
   def request_context
     @requester ? @requester.request : "(unknown)"
   end
@@ -59,6 +82,9 @@ class Gem::Resolver::DependencyRequest https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/dependency_request.rb#L82
     end
   end
 
+  ##
+  # The version requirement for this dependency request
+
   def requirement
     @dependency.requirement
   end
Index: lib/rubygems/resolver/local_specification.rb
===================================================================
--- lib/rubygems/resolver/local_specification.rb	(revision 0)
+++ lib/rubygems/resolver/local_specification.rb	(revision 43845)
@@ -0,0 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/local_specification.rb#L1
+##
+# A LocalSpecification comes from a .gem file on the local filesystem.
+
+class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification
+
+  ##
+  # Returns +true+ if this gem is installable for the current platform.
+
+  def installable_platform?
+    return true if @source.kind_of? Gem::Source::SpecificFile
+
+    super
+  end
+
+end
+

Property changes on: lib/rubygems/resolver/local_specification.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rubygems/resolver/requirement_list.rb
===================================================================
--- lib/rubygems/resolver/requirement_list.rb	(revision 43844)
+++ lib/rubygems/resolver/requirement_list.rb	(revision 43845)
@@ -1,19 +1,28 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/requirement_list.rb#L1
 ##
-# Used internally to hold the requirements being considered
-# while attempting to find a proper activation set.
+# The RequirementList is used to hold the requirements being considered
+# while resolving a set of gems.
+#
+# The RequirementList acts like a queue where the oldest items are removed
+# first.
 
 class Gem::Resolver::RequirementList
 
   include Enumerable
 
+  ##
+  # Creates a new RequirementList.
+
   def initialize
     @list = []
   end
 
-  def initialize_copy(other)
+  def initialize_copy other # :nodoc:
     @list = @list.dup
   end
 
+  ##
+  # Adds Resolver::DependencyRequest +req+ to this requirements list.
+
   def add(req)
     @list.push req
     req
@@ -30,14 +39,23 @@ class Gem::Resolver::RequirementList https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/requirement_list.rb#L39
     end
   end
 
+  ##
+  # Is the list empty?
+
   def empty?
     @list.empty?
   end
 
+  ##
+  # Remove the oldest DependencyRequest from the list.
+
   def remove
     @list.shift
   end
 
+  ##
+  # Returns the oldest five entries from the list.
+
   def next5
     @list[0,5]
   end
Index: lib/rubygems/resolver/vendor_specification.rb
===================================================================
--- lib/rubygems/resolver/vendor_specification.rb	(revision 43844)
+++ lib/rubygems/resolver/vendor_specification.rb	(revision 43845)
@@ -12,5 +12,13 @@ class Gem::Resolver::VendorSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/vendor_specification.rb#L12
       @source == other.source
   end
 
+  ##
+  # This is a null install as this gem was unpacked into a directory.
+  # +options+ are ignored.
+
+  def install options
+    yield nil
+  end
+
 end
 
Index: lib/rubygems/resolver/conflict.rb
===================================================================
--- lib/rubygems/resolver/conflict.rb	(revision 43844)
+++ lib/rubygems/resolver/conflict.rb	(revision 43845)
@@ -95,7 +95,6 @@ class Gem::Resolver::Conflict https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/conflict.rb#L95
     path = []
 
     while current do
-      spec_name   = current.spec.full_name
       requirement = current.request.dependency.requirement
       path << "#{current.spec.full_name} (#{requirement})"
 
Index: lib/rubygems/resolver/installer_set.rb
===================================================================
--- lib/rubygems/resolver/installer_set.rb	(revision 43844)
+++ lib/rubygems/resolver/installer_set.rb	(revision 43845)
@@ -20,6 +20,9 @@ class Gem::Resolver::InstallerSet < Gem: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/installer_set.rb#L20
 
   attr_accessor :ignore_installed # :nodoc:
 
+  ##
+  # Creates a new InstallerSet that will look for gems in +domain+.
+
   def initialize domain
     @domain = domain
 
Index: lib/rubygems/resolver/vendor_set.rb
===================================================================
--- lib/rubygems/resolver/vendor_set.rb	(revision 43844)
+++ lib/rubygems/resolver/vendor_set.rb	(revision 43845)
@@ -32,6 +32,8 @@ class Gem::Resolver::VendorSet < Gem::Re https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/vendor_set.rb#L32
     raise Gem::GemNotFoundException,
           "unable to find #{gemspec} for gem #{name}" unless spec
 
+    spec.full_gem_path = File.expand_path directory
+
     key = "#{spec.name}-#{spec.version}-#{spec.platform}"
 
     @specs[key]        = spec
Index: lib/rubygems/resolver/api_specification.rb
===================================================================
--- lib/rubygems/resolver/api_specification.rb	(revision 43844)
+++ lib/rubygems/resolver/api_specification.rb	(revision 43845)
@@ -34,6 +34,10 @@ class Gem::Resolver::APISpecification < https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/api_specification.rb#L34
       @dependencies == other.dependencies
   end
 
+  def installable_platform? # :nodoc:
+    Gem::Platform.match @platform
+  end
+
   def pretty_print q # :nodoc:
     q.group 2, '[APISpecification', ']' do
       q.breakable
Index: lib/rubygems/resolver/activation_request.rb
===================================================================
--- lib/rubygem (... truncated)

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

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