diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-25 19:14:49 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-25 19:14:49 +0000 |
commit | 04817ae6d3e1d898d6fbf09ad146850d26d2b404 () | |
tree | 7e5482d13830cacf363d21a087b490588a960095 | |
parent | c107372597586e1ad0fea03c00a14bdd7205b5d8 (diff) |
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
38 files changed, 586 insertions, 87 deletions
@@ -1,3 +1,14 @@ Mon Nov 25 22:23:03 2013 Zachary Scott <[email protected]> * lib/xmlrpc.rb: [DOC] Fix link to xmlrpc4r site [Bug #9148] @@ -1005,30 +1005,18 @@ module Gem def self.use_gemdeps return unless path = ENV['RUBYGEMS_GEMDEPS'] - path = path.dup.untaint - if path == "-" - here = Dir.pwd.untaint - start = here - begin - while true - path = GEM_DEP_FILES.find { |f| File.file?(f) } - - if path - path = File.join here, path - break - end - Dir.chdir ".." - # If we're at a toplevel, stop. - return if Dir.pwd == here - - here = Dir.pwd - end - ensure - Dir.chdir start end end @@ -1047,6 +1035,9 @@ module Gem end class << self alias detect_gemdeps use_gemdeps # :nodoc: end @@ -1218,4 +1209,5 @@ Gem::Specification.load_defaults require 'rubygems/core_ext/kernel_gem' require 'rubygems/core_ext/kernel_require' -Gem.detect_gemdeps @@ -127,7 +127,7 @@ class Gem::AvailableSet end match.map do |t| - Gem::Resolver::InstalledSpecification.new(self, t.spec, t.source) end end @@ -9,6 +9,11 @@ class Gem::BasicSpecification attr_reader :loaded_from def self.default_specifications_dir File.join(Gem.default_dir, "specifications", "default") end @@ -57,6 +57,11 @@ class Gem::Installer attr_reader :options @path_warning = false class << self @@ -56,11 +56,6 @@ class Gem::Installer ## # Available through requiring rubygems/installer_test_case - attr_writer :spec - - ## - # Available through requiring rubygems/installer_test_case - attr_writer :wrappers end @@ -166,29 +166,22 @@ class Gem::RequestSet 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 - path = req.download(dir) - unless path then # already installed - yield req, 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 - installed << req end installed @@ -15,12 +15,25 @@ require 'net/http' class Gem::Resolver ## # Contains all the conflicts encountered while doing resolution attr_reader :conflicts attr_accessor :development attr_reader :missing ## @@ -57,8 +70,8 @@ class Gem::Resolver end ## - # Provide a Resolver that queries only against the already - # installed gems. def self.for_current_gems needed new needed, Gem::Resolver::CurrentSet.new @@ -82,16 +95,14 @@ class Gem::Resolver @soft_missing = false end - DEBUG_RESOLVER = !ENV['DEBUG_RESOLVER'].nil? - - def explain(stage, *data) if DEBUG_RESOLVER d = data.map { |x| x.inspect }.join(", ") STDOUT.printf "%20s %s\n", stage.to_s.upcase, d end end - def explain_list(stage, data) if DEBUG_RESOLVER STDOUT.printf "%20s (%d entries)\n", stage.to_s.upcase, data.size data.each do |d| @@ -117,7 +128,7 @@ class Gem::Resolver return spec, activation_request end - def requests s, act, reqs=nil s.dependencies.reverse_each do |d| next if d.type == :development and not @development reqs.add Gem::Resolver::DependencyRequest.new(d, act) @@ -182,7 +193,7 @@ class Gem::Resolver return matching_platform, all end - def handle_conflict(dep, existing) # There is a conflict! We return the conflict object which will be seen by # the caller and be handled at the right level. @@ -252,7 +263,7 @@ class Gem::Resolver # +specs+ being a list to ActivationRequest, calculate a new list of # ActivationRequest objects. - def resolve_for needed, specs # The State objects that are used to attempt the activation tree. states = [] @@ -411,5 +422,6 @@ require 'rubygems/resolver/api_specification' require 'rubygems/resolver/git_specification' require 'rubygems/resolver/index_specification' require 'rubygems/resolver/installed_specification' require 'rubygems/resolver/vendor_specification' @@ -1,21 +1,33 @@ ## -# Specifies a Specification object that should be activated. -# Also contains a dependency that was used to introduce this -# activation. class Gem::Resolver::ActivationRequest attr_reader :request attr_reader :spec - def initialize spec, req, others_possible = true @spec = spec - @request = req @others_possible = others_possible end - def == other case other when Gem::Specification @spec == other @@ -26,6 +38,9 @@ class Gem::Resolver::ActivationRequest end end def download path if @spec.respond_to? :source source = @spec.source @@ -38,10 +53,16 @@ class Gem::Resolver::ActivationRequest source.download full_spec, path end def full_name @spec.full_name end def full_spec Gem::Specification === @spec ? @spec : @spec.spec end @@ -66,7 +87,7 @@ class Gem::Resolver::ActivationRequest end ## - # Indicates if the requested gem has already been installed. def installed? case @spec @@ -81,6 +102,9 @@ class Gem::Resolver::ActivationRequest end end def name @spec.name end @@ -130,6 +154,9 @@ class Gem::Resolver::ActivationRequest end end def version @spec.version end @@ -34,6 +34,10 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification @dependencies == other.dependencies end def pretty_print q # :nodoc: q.group 2, '[APISpecification', ']' do q.breakable @@ -95,7 +95,6 @@ class Gem::Resolver::Conflict path = [] while current do - spec_name = current.spec.full_name requirement = current.request.dependency.requirement path << "#{current.spec.full_name} (#{requirement})" @@ -4,16 +4,26 @@ class Gem::Resolver::DependencyRequest attr_reader :dependency attr_reader :requester - def initialize(dep, act) - @dependency = dep - @requester = act end - def ==(other) case other when Gem::Dependency @dependency == other @@ -24,26 +34,39 @@ class Gem::Resolver::DependencyRequest end end def matches_spec?(spec) @dependency.matches_spec? spec end 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 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 end end def requirement @dependency.requirement end @@ -12,5 +12,24 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification @source == other.source end end @@ -11,16 +11,22 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification 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 end ## @@ -20,6 +20,9 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set attr_accessor :ignore_installed # :nodoc: def initialize domain @domain = domain @@ -0,0 +1,16 @@ @@ -1,19 +1,28 @@ ## -# Used internally to hold the requirements being considered -# while attempting to find a proper activation set. class Gem::Resolver::RequirementList include Enumerable def initialize @list = [] end - def initialize_copy(other) @list = @list.dup end def add(req) @list.push req req @@ -30,14 +39,23 @@ class Gem::Resolver::RequirementList end end def empty? @list.empty? end def remove @list.shift end def next5 @list[0,5] end @@ -56,5 +56,34 @@ class Gem::Resolver::Specification "#{@name}-#{@version}" end end @@ -32,6 +32,8 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set raise Gem::GemNotFoundException, "unable to find #{gemspec} for gem #{name}" unless spec key = "#{spec.name}-#{spec.version}-#{spec.platform}" @specs[key] = spec @@ -12,5 +12,13 @@ class Gem::Resolver::VendorSpecification < Gem::Resolver::SpecSpecification @source == other.source end end @@ -1,10 +1,26 @@ class Gem::Security::TrustDir DEFAULT_PERMISSIONS = { :trust_dir => 0700, :trusted_cert => 0600, } def initialize dir, permissions = DEFAULT_PERMISSIONS @dir = dir @permissions = permissions @@ -12,8 +28,6 @@ class Gem::Security::TrustDir @digester = Gem::Security::DIGEST_ALGORITHM end - attr_reader :dir - ## # Returns the path to the trusted +certificate+ @@ -91,8 +91,8 @@ class Gem::Source::Git < Gem::Source success = system @git, 'reset', '--quiet', '--hard', @reference success &&= - system @git, 'submodule', 'update', - '--quiet', '--init', '--recursive', out: IO::NULL if @need_submodules success end @@ -161,7 +161,9 @@ class Gem::Source::Git < Gem::Source file = File.basename spec_file Dir.chdir directory do - Gem::Specification.load file end end.compact end @@ -205,6 +205,10 @@ class Gem::TestCase::SpecFetcherSetup @operations << [:clear] end def created_specs created = {} @@ -271,7 +275,7 @@ class Gem::TestCase::SpecFetcherSetup end end - def setup_fetcher # :nodoc; require 'zlib' require 'socket' require 'rubygems/remote_fetcher' @@ -666,6 +666,11 @@ end # STDOUT, and STDERR. class Gem::ConsoleUI < Gem::StreamUI def initialize super STDIN, STDOUT, STDERR, true end @@ -675,6 +680,10 @@ end # SilentUI is a UI choice that is absolutely silent. class Gem::SilentUI < Gem::StreamUI def initialize reader, writer = nil, nil @@ -689,11 +698,11 @@ class Gem::SilentUI < Gem::StreamUI super reader, writer, writer, false end - def download_reporter(*args) SilentDownloadReporter.new(@outs, *args) end - def progress_reporter(*args) SilentProgressReporter.new(@outs, *args) end end @@ -1,4 +1,10 @@ module Gem::Util ## # Zlib::GzipReader wrapper that unzips +data+. @@ -60,4 +66,56 @@ module Gem::Util end end end @@ -22,6 +22,25 @@ class TestGemAvailableSet < Gem::TestCase assert_equal [a1], set.all_specs end def test_match_platform a1, _ = util_gem 'a', '1' do |g| g.platform = "something-weird-yep" @@ -719,6 +719,9 @@ class TestGemDependencyInstaller < Gem::TestCase inst.install 'a' end ENV['GEM_HOME'] = @gemhome ENV['GEM_PATH'] = [@gemhome, gemhome2].join File::PATH_SEPARATOR Gem.clear_paths @@ -151,6 +151,7 @@ class TestGemResolver < Gem::TestCase a2_p1 = a3_p2 = nil spec_fetcher do |fetcher| a2_p1 = fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end a3_p2 = fetcher.spec 'a', 3 do |s| s.platform = unknown end end @@ -28,6 +28,42 @@ class TestGemResolverAPISpecification < Gem::TestCase assert_equal expected, spec.dependencies end def test_source set = Gem::Resolver::APISet.new data = { @@ -32,5 +32,19 @@ class TestGemResolverGitSpecification < Gem::TestCase refute_equal g_spec_a, i_spec end end @@ -29,6 +29,28 @@ class TestGemResolverIndexSpecification < Gem::TestCase assert_equal Gem::Platform.local.to_s, spec.platform end def test_spec specs = spec_fetcher do |fetcher| fetcher.spec 'a', 2 @@ -2,17 +2,48 @@ require 'rubygems/test_case' class TestGemResolverInstalledSpecification < Gem::TestCase - def test_initialize - set = Gem::Resolver::CurrentSet.new source_spec = util_spec 'a' - spec = Gem::Resolver::InstalledSpecification.new set, source_spec assert_equal 'a', spec.name assert_equal Gem::Version.new(2), spec.version assert_equal Gem::Platform::RUBY, spec.platform end end @@ -0,0 +1,45 @@ @@ -0,0 +1,32 @@ @@ -16,6 +16,8 @@ class TestGemResolverVendorSet < Gem::TestCase spec = @set.load_spec name, version, Gem::Platform::RUBY, nil assert_equal "#{name}-#{version}", spec.full_name end def test_add_vendor_gem_missing @@ -47,6 +47,18 @@ class TestGemResolverVendorSpecification < Gem::TestCase assert_equal 'a-1', v_spec.full_name end def test_name v_spec = Gem::Resolver::VendorSpecification.new @set, @spec @@ -25,7 +25,8 @@ class TestGemSourceGit < Gem::TestCase git_gem 'b' Dir.chdir 'git/a' do - system @git, 'submodule', '--quiet', 'add', File.expand_path('../b'), 'b', out: IO::NULL system @git, 'commit', '--quiet', '-m', 'add submodule b' end @@ -161,6 +162,14 @@ class TestGemSourceGit < Gem::TestCase end assert_equal %w[a-1 b-1], specs.map { |spec| spec.full_name } end def test_uri_hash @@ -7,9 +7,25 @@ class TestGemUtil < Gem::TestCase assert_equal "0\n", Gem::Util.popen(Gem.ruby, '-e', 'p 0') assert_raises Errno::ECHILD do - Process.wait -1 end end end |