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

ruby-changes:31564

From: drbrain <ko1@a...>
Date: Mon, 11 Nov 2013 02:52:00 +0900 (JST)
Subject: [ruby-changes:31564] drbrain:r43643 (trunk): * lib/rubygems: Update to RubyGems master 4bdc4f2. Important changes

drbrain	2013-11-11 02:51:40 +0900 (Mon, 11 Nov 2013)

  New Revision: 43643

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

  Log:
    * lib/rubygems: Update to RubyGems master 4bdc4f2.  Important changes
      in this commit:
    
      RubyGems now chooses the test server port reliably.  Patch by akr.
    
      Partial implementation of bundler's Gemfile format.
    
      Refactorings to improve the new resolver.
    
      Fixes bugs in the resolver.
    
    * test/rubygems:  Tests for the above.

  Added files:
    trunk/lib/rubygems/dependency_resolver/best_set.rb
    trunk/lib/rubygems/dependency_resolver/lock_set.rb
    trunk/lib/rubygems/dependency_resolver/set.rb
    trunk/lib/rubygems/dependency_resolver/spec_specification.rb
    trunk/lib/rubygems/dependency_resolver/specification.rb
    trunk/lib/rubygems/request_set/lockfile.rb
    trunk/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem
    trunk/test/rubygems/test_gem_dependency_resolution_error.rb
    trunk/test/rubygems/test_gem_dependency_resolver_activation_request.rb
    trunk/test/rubygems/test_gem_dependency_resolver_best_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_dependency_request.rb
    trunk/test/rubygems/test_gem_dependency_resolver_lock_set.rb
    trunk/test/rubygems/test_gem_request_set_lockfile.rb
    trunk/test/rubygems/test_gem_source_vendor.rb
  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/basic_specification.rb
    trunk/lib/rubygems/commands/install_command.rb
    trunk/lib/rubygems/commands/update_command.rb
    trunk/lib/rubygems/dependency_installer.rb
    trunk/lib/rubygems/dependency_resolver/activation_request.rb
    trunk/lib/rubygems/dependency_resolver/api_set.rb
    trunk/lib/rubygems/dependency_resolver/api_specification.rb
    trunk/lib/rubygems/dependency_resolver/composed_set.rb
    trunk/lib/rubygems/dependency_resolver/current_set.rb
    trunk/lib/rubygems/dependency_resolver/dependency_conflict.rb
    trunk/lib/rubygems/dependency_resolver/dependency_request.rb
    trunk/lib/rubygems/dependency_resolver/index_set.rb
    trunk/lib/rubygems/dependency_resolver/index_specification.rb
    trunk/lib/rubygems/dependency_resolver/installed_specification.rb
    trunk/lib/rubygems/dependency_resolver/installer_set.rb
    trunk/lib/rubygems/dependency_resolver/vendor_set.rb
    trunk/lib/rubygems/dependency_resolver/vendor_specification.rb
    trunk/lib/rubygems/dependency_resolver.rb
    trunk/lib/rubygems/errors.rb
    trunk/lib/rubygems/exceptions.rb
    trunk/lib/rubygems/platform.rb
    trunk/lib/rubygems/remote_fetcher.rb
    trunk/lib/rubygems/request_set/gem_dependency_api.rb
    trunk/lib/rubygems/request_set.rb
    trunk/lib/rubygems/requirement.rb
    trunk/lib/rubygems/server.rb
    trunk/lib/rubygems/source/vendor.rb
    trunk/lib/rubygems/source.rb
    trunk/lib/rubygems/source_list.rb
    trunk/lib/rubygems/spec_fetcher.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/lib/rubygems/version.rb
    trunk/lib/rubygems.rb
    trunk/test/rubygems/test_bundled_ca.rb
    trunk/test/rubygems/test_gem.rb
    trunk/test/rubygems/test_gem_commands_dependency_command.rb
    trunk/test/rubygems/test_gem_commands_install_command.rb
    trunk/test/rubygems/test_gem_commands_outdated_command.rb
    trunk/test/rubygems/test_gem_commands_specification_command.rb
    trunk/test/rubygems/test_gem_dependency_installer.rb
    trunk/test/rubygems/test_gem_dependency_resolver.rb
    trunk/test/rubygems/test_gem_dependency_resolver_api_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb
    trunk/test/rubygems/test_gem_dependency_resolver_index_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_index_specification.rb
    trunk/test/rubygems/test_gem_dependency_resolver_installer_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_vendor_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb
    trunk/test/rubygems/test_gem_remote_fetcher.rb
    trunk/test/rubygems/test_gem_request_set.rb
    trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb
    trunk/test/rubygems/test_gem_requirement.rb
    trunk/test/rubygems/test_gem_server.rb
    trunk/test/rubygems/test_gem_source.rb
    trunk/test/rubygems/test_gem_source_list.rb
    trunk/test/rubygems/test_gem_source_local.rb
    trunk/test/rubygems/test_gem_spec_fetcher.rb
    trunk/test/rubygems/test_gem_specification.rb
    trunk/test/rubygems/test_gem_stub_specification.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43642)
+++ ChangeLog	(revision 43643)
@@ -1,3 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Nov 11 02:51:17 2013  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems: Update to RubyGems master 4bdc4f2.  Important changes
+	  in this commit:
+
+	  RubyGems now chooses the test server port reliably.  Patch by akr.
+
+	  Partial implementation of bundler's Gemfile format.
+
+	  Refactorings to improve the new resolver.
+
+	  Fixes bugs in the resolver.
+
+	* test/rubygems:  Tests for the above.
+
 Mon Nov 11 01:02:06 2013  Zachary Scott  <e@z...>
 
 	* lib/timeout.rb: [DOC] Add note about change from #8730 [Fixes GH-440]
Index: lib/rubygems/basic_specification.rb
===================================================================
--- lib/rubygems/basic_specification.rb	(revision 43642)
+++ lib/rubygems/basic_specification.rb	(revision 43643)
@@ -196,5 +196,13 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L196
     raise NotImplementedError
   end
 
+  ##
+  # Whether this specification is stubbed - i.e. we have information
+  # about the gem from a stub line, without having to evaluate the
+  # entire gemspec file.
+  def stubbed?
+    raise NotImplementedError
+  end
+
 end
 
Index: lib/rubygems/spec_fetcher.rb
===================================================================
--- lib/rubygems/spec_fetcher.rb	(revision 43642)
+++ lib/rubygems/spec_fetcher.rb	(revision 43643)
@@ -18,6 +18,11 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L18
   attr_reader :latest_specs # :nodoc:
 
   ##
+  # Sources for this SpecFetcher
+
+  attr_reader :sources # :nodoc:
+
+  ##
   # Cache of all released specs
 
   attr_reader :specs # :nodoc:
@@ -37,7 +42,16 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L42
     @fetcher = fetcher
   end
 
-  def initialize
+  ##
+  # Creates a new SpecFetcher.  Ordinarily you want to use
+  # Gem::SpecFetcher::fetcher which uses the Gem.sources.
+  #
+  # If you need to retrieve specifications from a different +source+, you can
+  # send it as an argument.
+
+  def initialize sources = nil
+    @sources = sources || Gem.sources
+
     @update_cache =
       begin
         File.stat(Gem.user_home).uid == Process.uid
@@ -197,7 +211,7 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L211
     errors = []
     list = {}
 
-    Gem.sources.each_source do |source|
+    @sources.each_source do |source|
       begin
         names = case type
                 when :latest
Index: lib/rubygems/dependency_installer.rb
===================================================================
--- lib/rubygems/dependency_installer.rb	(revision 43642)
+++ lib/rubygems/dependency_installer.rb	(revision 43643)
@@ -250,6 +250,14 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L250
       if gem_name =~ /\.gem$/ and File.file? gem_name then
         src = Gem::Source::SpecificFile.new(gem_name)
         set.add src.spec, src
+      elsif gem_name =~ /\.gem$/ then
+        Dir[gem_name].each do |name|
+          begin
+            src = Gem::Source::SpecificFile.new name
+            set.add src.spec, src
+          rescue Gem::Package::FormatError
+          end
+        end
       else
         local = Gem::Source::Local.new
 
Index: lib/rubygems/dependency_resolver/installed_specification.rb
===================================================================
--- lib/rubygems/dependency_resolver/installed_specification.rb	(revision 43642)
+++ lib/rubygems/dependency_resolver/installed_specification.rb	(revision 43643)
@@ -1,12 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/installed_specification.rb#L1
-class Gem::DependencyResolver::InstalledSpecification
+##
+# An InstalledSpecification represents a gem that is already installed
+# locally.
 
-  attr_reader :spec
-
-  def initialize set, spec, source=nil
-    @set    = set
-    @source = source
-    @spec   = spec
-  end
+class Gem::DependencyResolver::InstalledSpecification < Gem::DependencyResolver::SpecSpecification
 
   def == other # :nodoc:
     self.class === other and
@@ -14,29 +10,25 @@ class Gem::DependencyResolver::Installed https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/installed_specification.rb#L10
       @spec == other.spec
   end
 
-  def dependencies
-    @spec.dependencies
-  end
-
-  def full_name
-    "#{@spec.name}-#{@spec.version}"
-  end
+  ##
+  # Returns +true+ if this gem is installable for the current platform.
 
-  def name
-    @spec.name
+  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
   end
 
-  def platform
-    @spec.platform
-  end
+  ##
+  # The source for this specification
 
   def source
     @source ||= Gem::Source::Installed.new
   end
 
-  def version
-    @spec.version
-  end
-
 end
 
Index: lib/rubygems/dependency_resolver/specification.rb
===================================================================
--- lib/rubygems/dependency_resolver/specification.rb	(revision 0)
+++ lib/rubygems/dependency_resolver/specification.rb	(revision 43643)
@@ -0,0 +1,60 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/specification.rb#L1
+##
+# A DependencyResolver::Specification contains a subset of the information
+# contained in a Gem::Specification.  Only the information necessary for
+# dependency resolution in the resolver is included.
+
+class Gem::DependencyResolver::Specification
+
+  ##
+  # The dependencies of the gem for this specification
+
+  attr_reader :dependencies
+
+  ##
+  # The name of the gem for this specification
+
+  attr_reader :name
+
+  ##
+  # The platform this gem works on.
+
+  attr_reader :platform
+
+  ##
+  # The set this specification came from.
+
+  attr_reader :set
+
+  ##
+  # The source for this specification
+
+  attr_reader :source
+
+  ##
+  # The version of the gem for this specification.
+
+  attr_reader :version
+
+  ##
+  # Sets default instance variables for the specification.
+
+  def initialize
+    @dependencies = nil
+    @name         = nil
+    @platform     = nil
+    @set          = nil
+    @source       = nil
+    @version      = nil
+  end
+
+  ##
+  # The name and version of the specification.
+  #
+  # Unlike Gem::Specification#full_name, the platform is not included.
+
+  def full_name
+    "#{@name}-#{@version}"
+  end
+
+end
+

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

Index: lib/rubygems/dependency_resolver/index_set.rb
===================================================================
--- lib/rubygems/dependency_resolver/index_set.rb	(revision 43642)
+++ lib/rubygems/dependency_resolver/index_set.rb	(revision 43643)
@@ -2,10 +2,17 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/index_set.rb#L2
 # The global rubygems pool represented via the traditional
 # source index.
 
-class Gem::DependencyResolver::IndexSet
+class Gem::DependencyResolver::IndexSet < Gem::DependencyResolver::Set
 
-  def initialize
-    @f = Gem::SpecFetcher.fetcher
+  def initialize source = nil # :nodoc:
+    @f =
+      if source then
+        sources = Gem::SourceList.from [source]
+
+        Gem::SpecFetcher.new sources
+      else
+        Gem::SpecFetcher.fetcher
+      end
 
     @all = Hash.new { |h,k| h[k] = [] }
 
@@ -39,26 +46,5 @@ class Gem::DependencyResolver::IndexSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/index_set.rb#L46
     res
   end
 
-  ##
-  # Called from IndexSpecification to get a true Specification
-  # object.
-
-  def load_spec name, ver, platform, source
-    key = "#{name}-#{ver}-#{platform}"
-
-    @specs.fetch key do
-      tuple = Gem::NameTuple.new name, ver, platform
-
-      @specs[key] = source.fetch_spec tuple
-    end
-  end
-
-  ##
-  # No prefetching needed since we load the whole index in
-  # initially.
-
-  def prefetch gems
-  end
-
 end
 
Index: lib/rubygems/dependency_resolver/api_set.rb
===================================================================
--- lib/rubygems/dependency_resolver/api_set.rb	(revision 43642)
+++ lib/rubygems/dependency_resolver/api_set.rb	(revision 43643)
@@ -2,11 +2,21 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/api_set.rb#L2
 # The global rubygems pool, available via the rubygems.org API.
 # Returns instances of APISpecification.
 
-class Gem::DependencyResolver::APISet
+class Gem::DependencyResolver::APISet < Gem::DependencyResolver::Set
 
-  def initialize
+  ##
+  # The URI for the dependency API this APISet uses.
+
+  attr_reader :dep_uri # :nodoc:
+
+  ##
+  # Creates a new APISet that will retrieve gems from +uri+ using the RubyGems
+  # API described at http://guides.rubygems.org/rubygems-org-api
+
+  def initialize uri = 'https://rubygems.org/api/v1/dependencies'
+    uri = URI uri unless URI === uri # for ruby 1.8
     @data = Hash.new { |h,k| h[k] = [] }
-    @dep_uri = URI 'https://rubygems.org/api/v1/dependencies'
+    @dep_uri = uri
   end
 
   ##
@@ -46,7 +56,7 @@ class Gem::DependencyResolver::APISet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/api_set.rb#L56
   ##
   # Return data for all versions of the gem +name+.
 
-  def versions name
+  def versions name # :nodoc:
     if @data.key?(name)
       return @data[name]
     end
Index: lib/rubygems/dependency_resolver/composed_set.rb
===================================================================
--- lib/rubygems/dependency_resolver/composed_set.rb	(revision 43642)
+++ lib/rubygems/dependency_resolver/composed_set.rb	(revision 43643)
@@ -1,4 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/composed_set.rb#L1
-class Gem::DependencyResolver::ComposedSet
+class Gem::DependencyResolver::ComposedSet < Gem::DependencyResolver::Set
+
+  attr_reader :sets # :nodoc:
 
   def initialize *sets
     @sets = sets
Index: lib/rubygems/dependency_resolver/dependency_request.rb
===================================================================
--- lib/rubygems/dependency_resolver/dependency_request.rb	(revision 43642)
+++ lib/rubygems/dependency_resolver/dependency_request.rb	(revision 43643)
@@ -32,6 +32,22 @@ class Gem::DependencyResolver::Dependenc https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/dependency_request.rb#L32
     @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
+  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
+
   def pretty_print q # :nodoc:
     q.group 2, '[Dependency request ', ']' do
       q.breakable
@@ -43,6 +59,10 @@ class Gem::DependencyResolver::Dependenc https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/dependency_request.rb#L59
     end
   end
 
+  def requirement
+    @dependency.requirement
+  end
+
   def to_s # :nodoc:
     @dependency.to_s
   end
Index: lib/rubygems/dependency_resolver/spec_specification.rb
===================================================================
--- lib/rubygems/dependency_resolver/spec_specification.rb	(revision 0)
+++ lib/rubygems/dependency_resolver/spec_specification.rb	(revision 43643)
@@ -0,0 +1,58 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/spec_specification.rb#L1
+##
+# The DependencyResolver::SpecSpecification contains common functionality for
+# DependencyResolver specifications that are backed by a Gem::Specification.
+
+class Gem::DependencyResolver::SpecSpecification < Gem::DependencyResolver::Specification
+
+  attr_reader :spec # :nodoc:
+
+  ##
+  # A SpecSpecification is created for a +set+ for a Gem::Specification in
+  # +spec+.  The +source+ is either where the +spec+ came from, or should be
+  # loaded from.
+
+  def initialize set, spec, source = nil
+    @set    = set
+    @source = source
+    @spec   = spec
+  end
+
+  ##
+  # The dependencies of the gem for this specification
+
+  def dependencies
+    spec.dependencies
+  end
+
+  ##
+  # The name and version of the specification.
+  #
+  # Unlike Gem::Specification#full_name, the platform is not included.
+
+  def full_name
+    "#{spec.name}-#{spec.version}"
+  end
+
+  ##
+  # The name of the gem for this specification
+
+  def name
+    spec.name
+  end
+
+  ##
+  # The platform this gem works on.
+
+  def platform
+    spec.platform
+  end
+
+  ##
+  # The version of the gem for this specification.
+
+  def version
+    spec.version
+  end
+
+end
+

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

Index: lib/rubygems/dependency_resolver/set.rb
===================================================================
--- lib/rubygems/dependency_resolver/set.rb	(revision 0)
+++ lib/rubygems/dependency_resolver/set.rb	(revision 43643)
@@ -0,0 +1,28 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/set.rb#L1
+##
+# DependencyResolver sets are used to look up specifications (and their
+# dependencies) used in resolution.  This set is abstract.
+
+class Gem::DependencyResolver::Set
+
+  ##
+  # The find_all method must be implemented.  It returns all
+  # DependencyResolver Specification objects matching the given
+  # DependencyRequest +req+.
+
+  def find_all req
+    raise NotImplementedError
+  end
+
+  ##
+  # The #prefetch method may be overridden, but this is not necessary.  This
+  # default implementation does nothing, which is suitable for sets where
+  # looking up a specification is cheap (such as installed gems).
+  #
+  # When overridden, the #prefetch method should look up specifications
+  # matching +reqs+.
+
+  def prefetch reqs
+  end
+
+end
+

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

Index: lib/rubygems/dependency_resolver/vendor_specification.rb
===================================================================
--- lib/rubygems/dependency_resolver/vendor_specification.rb	(revision 43642)
+++ lib/rubygems/dependency_resolver/vendor_specification.rb	(revision 43643)
@@ -1,43 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/vendor_specification.rb#L1
-class Gem::DependencyResolver::VendorSpecification
+##
+# A VendorSpecification represents a gem that has been unpacked into a project
+# and is being loaded through a gem dependencies file through the +path:+
+# option.
 
-  attr_reader :spec
-
-  attr_reader :set
-
-  def initialize set, spec, source=nil
-    @set    = set
-    @source = source
-    @spec   = spec
-  end
+class Gem::DependencyResolver::VendorSpecification < Gem::DependencyResolver::SpecSpecification
 
   def == other # :nodoc:
     self.class === other and
       @set  == other.set and
-      @spec == other.spec
-  end
-
-  def dependencies
-    @spec.dependencies
-  end
-
-  def full_name
-    "#{@spec.name}-#{@spec.version}"
-  end
-
-  def name
-    @spec.name
-  end
-
-  def platform
-    @spec.platform
-  end
-
-  def source
-    @source ||= Gem::Source::Vendor.new
-  end
-
-  def version
-    @spec.version
+      @spec == other.spec and
+      @source == other.source
   end
 
 end
Index: lib/rubygems/dependency_resolver/current_set.rb
===================================================================
--- lib/rubygems/dependency_resolver/current_set.rb	(revision 43642)
+++ lib/rubygems/dependency_resolver/current_set.rb	(revision 43643)
@@ -3,14 +3,11 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/current_set.rb#L3
 # all the normal settings that control where to look
 # for installed gems.
 
-class Gem::DependencyResolver::CurrentSet
+class Gem::DependencyResolver::CurrentSet < Gem::DependencyResolver::Set
 
   def find_all req
     req.dependency.matching_specs
   end
 
-  def prefetch gems
-  end
-
 end
 
Index: lib/rubygems/dependency_resolver/dependency_conflict.rb
===================================================================
--- lib/rubygems/dependency_resolver/dependency_conflict.rb	(revision 43642)
+++ lib/rubygems/dependency_resolver/dependency_conflict.rb	(revision 43643)
@@ -8,12 +8,21 @@ class Gem::DependencyResolver::Dependenc https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/dependency_conflict.rb#L8
 
   attr_reader :dependency
 
+  attr_reader :failed_dep # :nodoc:
+
   def initialize(dependency, activated, failed_dep=dependency)
     @dependency = dependency
     @activated = activated
     @failed_dep = failed_dep
   end
 
+  def == other
+    self.class === other and
+      @dependency == other.dependency and
+      @activated  == other.activated  and
+      @failed_dep == other.failed_dep
+  end
+
   ##
   # Return the 2 dependency objects that conflicted
 
@@ -71,6 +80,8 @@ class Gem::DependencyResolver::Dependenc https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/dependency_conflict.rb#L80
       current = current.request.requester
     end
 
+    path = ['user request (gem command or Gemfile)'] if path.empty?
+
     path
   end
 
Index: lib/rubygems/dependency_resolver/lock_set.rb
===================================================================
--- lib/rubygems/dependency_resolver/lock_set.rb	(revision 0)
+++ lib/rubygems/dependency_resolver/lock_set.rb	(revision 43643)
@@ -0,0 +1,60 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/lock_set.rb#L1
+##
+# A set of gems from a gem dependencies lockfile.
+
+class Gem::DependencyResolver::LockSet < Gem::DependencyResolver::Set
+
+  attr_reader :specs # :nodoc:
+
+  ##
+  # Creates a new LockSet from the given +source+
+
+  def initialize source
+    @source = source
+    @specs  = []
+  end
+
+  ##
+  # Creates a new IndexSpecification in this set using the given +name+,
+  # +version+ and +platform+.
+  #
+  # The specification's set will be the current set, and the source will be
+  # the current set's source.
+
+  def add name, version, platform # :nodoc:
+    version = Gem::Version.new version
+
+    spec =
+      Gem::DependencyResolver::IndexSpecification.new self, name, version,
+                                                      @source, platform
+
+    @specs << spec
+  end
+
+  ##
+  # Returns an Array of IndexSpecification objects matching the
+  # DependencyRequest +req+.
+
+  def find_all req
+    @specs.select do |spec|
+      req.matches_spec? spec
+    end
+  end
+
+  ##
+  # Loads a Gem::Specification with the given +name+, +version+ and
+  # +platform+.  +source+ is ignored.
+
+  def load_spec name, version, platform, source # :nodoc:
+    dep = Gem::Dependency.new name, version
+
+    found = @specs.find do |spec|
+      dep.matches_spec? spec and spec.platform == platform
+    end
+
+    tuple = Gem::NameTuple.new found.name, found.version, found.platform
+
+    found.source.fetch_spec tuple
+  end
+
+end
+

Property changes on: lib/rubygems/dependency_resolver/lock_se (... truncated)

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

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