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

ruby-changes:39011

From: hsbt <ko1@a...>
Date: Thu, 2 Jul 2015 06:51:02 +0900 (JST)
Subject: [ruby-changes:39011] hsbt:r51092 (trunk): * lib/rubygems: Update to RubyGems HEAD(c202db2).

hsbt	2015-07-02 06:50:14 +0900 (Thu, 02 Jul 2015)

  New Revision: 51092

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

  Log:
    * lib/rubygems: Update to RubyGems HEAD(c202db2).
      this version contains many enhancements see http://git.io/vtNwF
    * test/rubygems: ditto.

  Added directories:
    trunk/lib/rubygems/resolver/molinillo/
    trunk/lib/rubygems/resolver/molinillo/lib/
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/modules/
  Added files:
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo.rb
    trunk/lib/rubygems/resolver/molinillo.rb
  Removed files:
    trunk/lib/rubygems/util/stringio.rb
  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/basic_specification.rb
    trunk/lib/rubygems/commands/dependency_command.rb
    trunk/lib/rubygems/commands/install_command.rb
    trunk/lib/rubygems/commands/list_command.rb
    trunk/lib/rubygems/commands/pristine_command.rb
    trunk/lib/rubygems/commands/query_command.rb
    trunk/lib/rubygems/core_ext/kernel_require.rb
    trunk/lib/rubygems/dependency.rb
    trunk/lib/rubygems/dependency_list.rb
    trunk/lib/rubygems/ext/builder.rb
    trunk/lib/rubygems/ext/ext_conf_builder.rb
    trunk/lib/rubygems/indexer.rb
    trunk/lib/rubygems/installer.rb
    trunk/lib/rubygems/installer_test_case.rb
    trunk/lib/rubygems/package/old.rb
    trunk/lib/rubygems/package/tar_reader/entry.rb
    trunk/lib/rubygems/package/tar_test_case.rb
    trunk/lib/rubygems/package/tar_writer.rb
    trunk/lib/rubygems/package.rb
    trunk/lib/rubygems/platform.rb
    trunk/lib/rubygems/rdoc.rb
    trunk/lib/rubygems/request/connection_pools.rb
    trunk/lib/rubygems/request_set/gem_dependency_api.rb
    trunk/lib/rubygems/request_set/lockfile.rb
    trunk/lib/rubygems/request_set.rb
    trunk/lib/rubygems/resolver/activation_request.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/specification.rb
    trunk/lib/rubygems/resolver.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/stub_specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/lib/rubygems/test_utilities.rb
    trunk/lib/rubygems/uninstaller.rb
    trunk/lib/rubygems/util/list.rb
    trunk/lib/rubygems/util.rb
    trunk/lib/rubygems/version.rb
    trunk/lib/rubygems.rb
    trunk/test/rubygems/simple_gem.rb
    trunk/test/rubygems/test_gem.rb
    trunk/test/rubygems/test_gem_available_set.rb
    trunk/test/rubygems/test_gem_commands_cleanup_command.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_mirror.rb
    trunk/test/rubygems/test_gem_commands_outdated_command.rb
    trunk/test/rubygems/test_gem_commands_pristine_command.rb
    trunk/test/rubygems/test_gem_commands_query_command.rb
    trunk/test/rubygems/test_gem_commands_specification_command.rb
    trunk/test/rubygems/test_gem_commands_stale_command.rb
    trunk/test/rubygems/test_gem_commands_uninstall_command.rb
    trunk/test/rubygems/test_gem_commands_unpack_command.rb
    trunk/test/rubygems/test_gem_commands_update_command.rb
    trunk/test/rubygems/test_gem_commands_which_command.rb
    trunk/test/rubygems/test_gem_dependency.rb
    trunk/test/rubygems/test_gem_dependency_installer.rb
    trunk/test/rubygems/test_gem_doctor.rb
    trunk/test/rubygems/test_gem_ext_configure_builder.rb
    trunk/test/rubygems/test_gem_ext_ext_conf_builder.rb
    trunk/test/rubygems/test_gem_indexer.rb
    trunk/test/rubygems/test_gem_install_update_options.rb
    trunk/test/rubygems/test_gem_installer.rb
    trunk/test/rubygems/test_gem_package.rb
    trunk/test/rubygems/test_gem_package_tar_reader_entry.rb
    trunk/test/rubygems/test_gem_package_tar_writer.rb
    trunk/test/rubygems/test_gem_request_connection_pools.rb
    trunk/test/rubygems/test_gem_request_set.rb
    trunk/test/rubygems/test_gem_request_set_lockfile.rb
    trunk/test/rubygems/test_gem_resolver.rb
    trunk/test/rubygems/test_gem_resolver_installer_set.rb
    trunk/test/rubygems/test_gem_resolver_lock_specification.rb
    trunk/test/rubygems/test_gem_specification.rb
    trunk/test/rubygems/test_gem_stub_specification.rb
    trunk/test/rubygems/test_gem_uninstaller.rb
    trunk/test/rubygems/test_gem_util.rb
    trunk/test/rubygems/test_require.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51091)
+++ ChangeLog	(revision 51092)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jul  2 06:49:44 2015  SHIBATA Hiroshi  <hsbt@r...>
+
+	* lib/rubygems: Update to RubyGems HEAD(c202db2).
+	  this version contains many enhancements see http://git.io/vtNwF
+	* test/rubygems: ditto.
+
 Wed Jul  1 23:50:34 2015  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* test/net/http/test_httpresponse.rb
Index: lib/rubygems/basic_specification.rb
===================================================================
--- lib/rubygems/basic_specification.rb	(revision 51091)
+++ lib/rubygems/basic_specification.rb	(revision 51092)
@@ -22,13 +22,17 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L22
   ##
   # The path this gemspec was loaded from.  This attribute is not persisted.
 
-  attr_reader :loaded_from
+  attr_accessor :loaded_from
 
   ##
   # Allows correct activation of git: and path: gems.
 
   attr_writer :full_gem_path # :nodoc:
 
+  def initialize
+    internal_init
+  end
+
   def self.default_specifications_dir
     File.join(Gem.default_dir, "specifications", "default")
   end
@@ -141,7 +145,7 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L145
     @full_require_paths ||=
     begin
       full_paths = raw_require_paths.map do |path|
-        File.join full_gem_path, path
+        File.join full_gem_path, path.untaint
       end
 
       full_paths << extension_dir unless @extensions.nil? || @extensions.empty?
@@ -189,13 +193,7 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L193
     @gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
   end
 
-  ##
-  # Set the path the Specification was loaded from. +path+ is converted to a
-  # String.
-
-  def loaded_from= path
-    @loaded_from   = path && path.to_s
-
+  def internal_init # :nodoc:
     @extension_dir = nil
     @extensions_dir = nil
     @full_gem_path         = nil
@@ -264,6 +262,30 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L262
   end
 
   ##
+  # Return all files in this gem that match for +glob+.
+
+  def matches_for_glob glob # TODO: rename?
+    # TODO: do we need these?? Kill it
+    glob = File.join(self.lib_dirs_glob, glob)
+
+    Dir[glob].map { |f| f.untaint } # FIX our tests are broken, run w/ SAFE=1
+  end
+
+  ##
+  # Returns a string usable in Dir.glob to match all requirable paths
+  # for this spec.
+
+  def lib_dirs_glob
+    dirs = if self.require_paths.size > 1 then
+             "{#{self.require_paths.join(',')}}"
+           else
+             self.require_paths.first
+           end
+
+    "#{self.full_gem_path}/#{dirs}"
+  end
+
+  ##
   # Return a Gem::Specification from this gem
 
   def to_spec
Index: lib/rubygems/installer_test_case.rb
===================================================================
--- lib/rubygems/installer_test_case.rb	(revision 51091)
+++ lib/rubygems/installer_test_case.rb	(revision 51092)
@@ -176,7 +176,7 @@ class Gem::InstallerTestCase < Gem::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer_test_case.rb#L176
       end
     end
 
-    @installer = Gem::Installer.new @gem
+    @installer = Gem::Installer.at @gem
   end
 
   ##
@@ -184,7 +184,7 @@ class Gem::InstallerTestCase < Gem::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer_test_case.rb#L184
   # +user+ is true a user-install will be performed.
 
   def util_installer(spec, gem_home, user=false)
-    Gem::Installer.new(spec.cache_file,
+    Gem::Installer.at(spec.cache_file,
                        :install_dir => gem_home,
                        :user_install => user)
   end
Index: lib/rubygems/rdoc.rb
===================================================================
--- lib/rubygems/rdoc.rb	(revision 51091)
+++ lib/rubygems/rdoc.rb	(revision 51092)
@@ -20,7 +20,7 @@ begin https://github.com/ruby/ruby/blob/trunk/lib/rubygems/rdoc.rb#L20
   require 'rdoc/rubygems_hook'
   loaded_hook = true
   module Gem
-    RDoc = RDoc::RubygemsHook
+    RDoc = ::RDoc::RubygemsHook
   end
 rescue LoadError
 end
@@ -332,4 +332,3 @@ class Gem::RDoc # :nodoc: all https://github.com/ruby/ruby/blob/trunk/lib/rubygems/rdoc.rb#L332
 end unless loaded_hook
 
 Gem.done_installing(&Gem::RDoc.method(:generation_hook))
-
Index: lib/rubygems/ext/builder.rb
===================================================================
--- lib/rubygems/ext/builder.rb	(revision 51091)
+++ lib/rubygems/ext/builder.rb	(revision 51092)
@@ -66,9 +66,11 @@ class Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L66
       # TODO use Process.spawn when ruby 1.8 support is dropped.
       rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil
       if verbose
+        puts("current directory: #{Dir.pwd}")
         puts(command)
         system(command)
       else
+        results << "current directory: #{Dir.pwd}"
         results << command
         results << `#{command} #{redirector}`
       end
Index: lib/rubygems/ext/ext_conf_builder.rb
===================================================================
--- lib/rubygems/ext/ext_conf_builder.rb	(revision 51091)
+++ lib/rubygems/ext/ext_conf_builder.rb	(revision 51092)
@@ -35,7 +35,12 @@ class Gem::Ext::ExtConfBuilder < Gem::Ex https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/ext_conf_builder.rb#L35
         begin
           run cmd, results
         ensure
-          FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log'
+          if File.exist? 'mkmf.log'
+            results << "To see why this extension failed to compile, please check" \
+              " the mkmf.log which can be found here:\n"
+            results << "  " + File.join(dest_path, 'mkmf.log') + "\n"
+            FileUtils.mv 'mkmf.log', dest_path
+          end
           siteconf.unlink
         end
 
Index: lib/rubygems/request_set.rb
===================================================================
--- lib/rubygems/request_set.rb	(revision 51091)
+++ lib/rubygems/request_set.rb	(revision 51092)
@@ -159,16 +159,13 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L159
 
       path = req.download cache_dir
 
-      inst = Gem::Installer.new path, options
+      inst = Gem::Installer.at path, options
 
       yield req, inst if block_given?
 
       requests << inst.install
     end
 
-    requests
-  ensure
-    raise if $!
     return requests if options[:gemdeps]
 
     specs = requests.map do |request|
@@ -187,6 +184,8 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L184
     Gem.done_installing_hooks.each do |hook|
       hook.call inst, specs
     end unless Gem.done_installing_hooks.empty?
+
+    requests
   end
 
   ##
Index: lib/rubygems/specification.rb
===================================================================
--- lib/rubygems/specification.rb	(revision 51091)
+++ lib/rubygems/specification.rb	(revision 51092)
@@ -12,7 +12,8 @@ require 'rubygems/platform' https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L12
 require 'rubygems/deprecate'
 require 'rubygems/basic_specification'
 require 'rubygems/stub_specification'
-require 'rubygems/util/stringio'
+require 'rubygems/util/list'
+require 'stringio'
 
 ##
 # The Specification class contains the information for a Gem.  Typically
@@ -172,6 +173,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L173
     @@default_value[k].nil?
   }
 
+  @@stubs_by_name = {}
+
   ######################################################################
   # :section: Required gemspec attributes
 
@@ -345,7 +348,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L348
               add_bindir(@executables),
               @extra_rdoc_files,
               @extensions,
-             ].flatten.uniq.compact.sort
+             ].flatten.compact.uniq.sort
   end
 
   ######################################################################
@@ -729,12 +732,57 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L732
     end
   end
 
-  def self.each_stub(dirs) # :nodoc:
-    each_gemspec(dirs) do |path|
-      stub = Gem::StubSpecification.new(path)
-      yield stub if stub.valid?
+  def self.gemspec_stubs_in dir, pattern
+    Dir[File.join(dir, pattern)].map { |path|
+      if dir == default_specifications_dir
+        Gem::StubSpecification.default_gemspec_stub(path)
+      else
+        Gem::StubSpecification.gemspec_stub(path)
+      end
+    }.select(&:valid?)
+  end
+  private_class_method :gemspec_stubs_in
+
+  if [].respond_to? :flat_map
+    def self.map_stubs(dirs, pattern) # :nodoc:
+      dirs.flat_map { |dir| gemspec_stubs_in(dir, pattern) }
+    end
+  else # FIXME: remove when 1.8 is dropped
+    def self.map_stubs(dirs, pattern) # :nodoc:
+      dirs.map { |dir| gemspec_stubs_in(dir, pattern) }.flatten 1
     end
   end
+  private_class_method :map_stubs
+
+  uniq_takes_a_block = false
+  [1,2].uniq { uniq_takes_a_block = true }
+
+  if uniq_takes_a_block
+    def self.uniq_by(list, &block) # :nodoc:
+      list.uniq(&block)
+    end
+  else # FIXME: remove when 1.8 is dropped
+    def self.uniq_by(list) # :nodoc:
+      values = {}
+      list.each { |item|
+        value = yield item
+        values[value] ||= item
+      }
+      values.values
+    end
+  end
+  private_class_method :uniq_by
+
+  if [].respond_to? :sort_by!
+    def self.sort_by! list, &block
+      list.sort_by!(&block)
+    end
+  else # FIXME: remove when 1.8 is dropped
+    def self.sort_by! list, &block
+      list.replace list.sort_by(&block)
+    end
+  end
+  private_class_method :sort_by!
 
   def self.each_spec(dirs) # :nodoc:
     each_gemspec(dirs) do |path|
@@ -748,17 +796,33 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L796
 
   def self.stubs
     @@stubs ||= begin
-      stubs = {}
-      each_stub([default_specifications_dir] + dirs) do |stub|
-        stubs[stub.full_name] ||= stub
-      end
+      stubs = map_stubs([default_specifications_dir] + dirs, "*.gemspec")
+      stubs = uniq_by(stubs) { |stub| stub.full_name }
 
-      stubs = stubs.values
       _resort!(stubs)
+      @@stubs_by_name = stubs.group_by(&:name)
       stubs
     end
   end
 
+  EMPTY = [].freeze # :nodoc:
+
+  ##
+  # Returns a Gem::StubSpecification for installed gem named +name+
+
+  def self.stubs_for name
+    if @@stubs || @@stubs_by_name[name]
+      @@stubs_by_name[name] || []
+    else
+      stubs = map_stubs([default_specifications_dir] + dirs, "#{name}-*.gemspec")
+      stubs = uniq_by(stubs) { |stub| stub.full_name }.group_by(&:name)
+      stubs.each_value { |v| sort_by!(v) { |i| i.version } }
+
+      @@stubs_by_name.merge! stubs
+      @@stubs_by_name[name] ||= EMPTY
+    end
+  end
+
   def self._resort!(specs) # :nodoc:
     specs.sort! { |a, b|
       names = a.name <=> b.name
@@ -783,6 +847,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L847
   # properly sorted.
 
   def self.add_spec spec
+    warn "Gem::Specification.add_spec is deprecated and will be removed in Rubygems 3.0" unless Gem::Deprecate.skip
     # TODO: find all extraneous adds
     # puts
     # p :add_spec => [spec.full_name, caller.reject { |s| s =~ /minitest/ }]
@@ -797,6 +862,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L862
 
     _all << spec
     stubs << spec
+    (@@stubs_by_name[spec.name] ||= []) << spec
+    sort_by!(@@stubs_by_name[spec.name]) { |s| s.version }
     _resort!(_all)
     _resort!(stubs)
   end
@@ -805,14 +872,18 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L872
   # Adds multiple specs to the known specifications.
 
   def self.add_specs *specs
+    warn "Gem::Specification.add_specs is deprecated and will be removed in Rubygems 3.0" unless Gem::Deprecate.skip
+
     raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
 
     # TODO: this is much more efficient, but we need the extra checks for now
     # _all.concat specs
     # _resort!
 
-    specs.each do |spec| # TODO: slow
-      add_spec spec
+    Gem::Deprecate.skip_during do
+      specs.each do |spec| # TODO: slow
+        add_spec spec
+      end
     end
   end
 
@@ -839,6 +910,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L910
   # -- wilsonb
 
   def self.all= specs
+    @@stubs_by_name = specs.group_by(&:name)
     @@all = @@stubs = specs
   end
 
@@ -927,9 +999,10 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L999
   # Return the best specification that contains the file matching +path+.
 
   def self.find_by_path path
-    self.find { |spec|
+    stub = stubs.find { |spec|
       spec.contains_requirable_file? path
     }
+    stub && stub.to_spec
   end
 
   ##
@@ -961,15 +1034,13 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1034
     specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
 
     specs.reverse_each do |spec|
-      trails = []
       spec.traverse do |from_spec, dep, to_spec, trail|
-        next unless to_spec.conflicts.empty?
-        trails << trail if to_spec.contains_requirable_file? path
+        if to_spec.has_conflicts? || to_spec.conficts_when_loaded_with?(trail)
+          :next
+        else
+          return trail.reverse if to_spec.contains_requirable_file? path
+        end
       end
-
-      next if trails.empty?
-
-      return trails.map(&:reverse).sort.first.reverse
     end
 
     []
@@ -1008,10 +1079,14 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1079
   # +prerelease+ is true.
 
   def self.latest_specs prerelease = false
+    _latest_specs Gem::Specification._all, prerelease
+  end
+
+  def self._latest_specs specs, prerelease = false # :nodoc:
     result = Hash.new { |h,k| h[k] = {} }
     native = {}
 
-    Gem::Specification.reverse_each do |spec|
+    specs.reverse_each do |spec|
       next if spec.version.prerelease? unless prerelease
 
       native[spec.name] = spec.version if spec.platform == Gem::Platform::RUBY
@@ -1029,12 +1104,13 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1104
 
   def self.load file
     return unless file
-    file = file.dup.untaint
-    return unless File.file?(file)
 
     _spec = LOAD_CACHE[file]
     return _spec if _spec
 
+    file = file.dup.untaint
+    return unless File.file?(file)
+
     code = if defined? Encoding
              File.read file, :mode => 'r:UTF-8:-'
            else
@@ -1126,8 +1202,11 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1202
   # Removes +spec+ from the known specs.
 
   def self.remove_spec spec
+    warn "Gem::Specification.remove_spec is deprecated and will be removed in Rubygems 3.0" unless Gem::Deprecate.skip
     _all.delete spec
     stubs.delete_if { |s| s.full_name == spec.full_name }
+    (@@stubs_by_name[spec.name] || []).delete_if { |s| s.full_name == spec.full_name }
+    reset
   end
 
   ##
@@ -1153,6 +1232,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1232
     Gem.pre_reset_hooks.each { |hook| hook.call }
     @@all = nil
     @@stubs = nil
+    @@stubs_by_name = {}
     _clear_load_cache
     unresolved = unresolved_deps
     unless unresolved.empty? then
@@ -1564,6 +1644,30 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1644
   end
 
   ##
+  # return true if there will be conflict when spec if loaded together with the list of specs.
+
+  def conficts_when_loaded_with?(list_of_specs) # :nodoc:
+    result = list_of_specs.any? { |spec|
+      spec.dependencies.any? { |dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }
+    }
+    result
+  end
+
+  ##
+  # Return true if there are possible conflicts against the currently loaded specs.
+
+  def has_conflicts?
+    self.dependencies.any? { |dep|
+      if dep.runtime? then
+        spec = Gem.loaded_specs[dep.name]
+        spec and not spec.satisfies_requirement? dep
+      else
+        false
+      end
+    }
+  end
+
+  ##
   # The date this gem was created.  Lazily defaults to the current UTC date.
   #
   # There is no need to set this in your gem specification.
@@ -1883,9 +1987,10 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1987
   # +version+.
 
   def initialize name = nil, version = nil
+    super()
     @loaded = false
     @activated = false
-    self.loaded_from = nil
+    @loaded_from = nil
     @original_platform = nil
     @installed_by_version = nil
 
@@ -1952,20 +2057,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2057
   end
 
   ##
-  # Returns a string usable in Dir.glob to match all requirable paths
-  # for this spec.
-
-  def lib_dirs_glob
-    dirs = if self.require_paths.size > 1 then
-             "{#{self.require_paths.join(',')}}"
-           else
-             self.require_paths.first
-           end
-
-    "#{self.full_gem_path}/#{dirs}"
-  end
-
-  ##
   # Files in the Gem under one of the require_paths
 
   def lib_files
@@ -1992,9 +2083,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2083
     @licenses ||= []
   end
 
-  def loaded_from= path # :nodoc:
+  def internal_init # :nodoc:
     super
-
     @bin_dir       = nil
     @cache_dir     = nil
     @cache_file    = nil
@@ -2012,16 +2102,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2102
   end
 
   ##
-  # Return all files in this gem that match for +glob+.
-
-  def matches_for_glob glob # TODO: rename?
-    # TODO: do we need these?? Kill it
-    glob = File.join(self.lib_dirs_glob, glob)
-
-    Dir[glob].map { |f| f.untaint } # FIX our tests are broken, run w/ SAFE=1
-  end
-
-  ##
   # Warn about unknown attributes while loading a spec.
 
   def method_missing(sym, *a, &b) # :nodoc:
@@ -2154,10 +2234,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2234
   # Check the spec for possible conflicts and freak out if there are any.
 
   def raise_if_conflicts # :nodoc:
-    conf = self.conflicts
-
-    unless conf.empty? then
-      raise Gem::ConflictError.new self, conf
+    if has_conflicts? then
+      raise Gem::ConflictError.new self, conflicts
     end
   end
 
@@ -2234,7 +2312,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2312
   # List of dependencies that will automatically be activated at runtime.
 
   def runtime_dependencies
-    dependencies.select { |d| d.type == :runtime }
+    dependencies.select(&:runtime?)
   end
 
   ##
@@ -2461,7 +2539,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ (... truncated)

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

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