ruby-changes:27481
From: drbrain <ko1@a...>
Date: Thu, 28 Feb 2013 08:29:44 +0900 (JST)
Subject: [ruby-changes:27481] drbrain:r39533 (trunk): * lib/rubygems/available_set.rb: Undent for style
drbrain 2013-02-28 08:20:57 +0900 (Thu, 28 Feb 2013) New Revision: 39533 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39533 Log: * lib/rubygems/available_set.rb: Undent for style * lib/rubygems/dependency_installer.rb: Pick latest prerelease gem to install. Fixes RubyGems bug #468. * test/rubygems/test_gem_dependency_installer.rb: Test for the above. * lib/rubygems/dependency_installer.rb: Don't display "Done installing documentation" if documentation will not be installed. * lib/rubygems/rdoc.rb: ditto * lib/rubygems/dependency_list.rb: Use Array#concat for Ruby 1.x performance. * lib/rubygems/installer.rb: Use formatted program name when comparing executables. RubyGems pull request #471 * test/rubygems/test_gem_installer.rb: Test for the above. * lib/rubygems/package.rb: Use more explicit feature check to work around JRuby bug #552 * lib/rubygems/ssl_certs/GeoTrust_Global_CA.pem: Added GeoTrust root certificate. * test/rubygems/test_gem_source_list.rb: Use "example" instead of real hostname Added files: trunk/lib/rubygems/ssl_certs/GeoTrust_Global_CA.pem Modified files: trunk/ChangeLog trunk/lib/rubygems/available_set.rb trunk/lib/rubygems/dependency_installer.rb trunk/lib/rubygems/dependency_list.rb trunk/lib/rubygems/installer.rb trunk/lib/rubygems/package.rb trunk/lib/rubygems/rdoc.rb trunk/test/rubygems/test_gem_dependency_installer.rb trunk/test/rubygems/test_gem_installer.rb trunk/test/rubygems/test_gem_source_list.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39532) +++ ChangeLog (revision 39533) @@ -1,3 +1,31 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Feb 28 08:20:33 2013 Eric Hodel <drbrain@s...> + + * lib/rubygems/available_set.rb: Undent for style + + * lib/rubygems/dependency_installer.rb: Pick latest prerelease gem to + install. Fixes RubyGems bug #468. + * test/rubygems/test_gem_dependency_installer.rb: Test for the above. + + * lib/rubygems/dependency_installer.rb: Don't display "Done installing + documentation" if documentation will not be installed. + * lib/rubygems/rdoc.rb: ditto + + * lib/rubygems/dependency_list.rb: Use Array#concat for Ruby 1.x + performance. + + * lib/rubygems/installer.rb: Use formatted program name when comparing + executables. RubyGems pull request #471 + * test/rubygems/test_gem_installer.rb: Test for the above. + + * lib/rubygems/package.rb: Use more explicit feature check to work + around JRuby bug #552 + + * lib/rubygems/ssl_certs/GeoTrust_Global_CA.pem: Added GeoTrust root + certificate. + + * test/rubygems/test_gem_source_list.rb: Use "example" instead of real + hostname + Thu Feb 28 05:57:00 2013 Zachary Scott <zachary@z...> * thread.c: rdoc formatting for Thread, ThreadGroup, and ThreadError Index: lib/rubygems/rdoc.rb =================================================================== --- lib/rubygems/rdoc.rb (revision 39532) +++ lib/rubygems/rdoc.rb (revision 39533) @@ -37,6 +37,7 @@ end https://github.com/ruby/ruby/blob/trunk/lib/rubygems/rdoc.rb#L37 class Gem::RDoc # :nodoc: all include Gem::UserInteraction + extend Gem::UserInteraction @rdoc_version = nil @specs = [] @@ -70,7 +71,8 @@ class Gem::RDoc # :nodoc: all https://github.com/ruby/ruby/blob/trunk/lib/rubygems/rdoc.rb#L71 # +specs+ def self.generation_hook installer, specs - types = installer.document + start = Time.now + types = installer.document generate_rdoc = types.include? 'rdoc' generate_ri = types.include? 'ri' @@ -78,6 +80,13 @@ class Gem::RDoc # :nodoc: all https://github.com/ruby/ruby/blob/trunk/lib/rubygems/rdoc.rb#L80 specs.each do |spec| new(spec, generate_rdoc, generate_ri).generate end + + return unless generate_rdoc or generate_ri + + duration = (Time.now - start).to_i + names = specs.map(&:name).join ', ' + + say "Done installing documentation for #{names} after #{duration} seconds" end ## Index: lib/rubygems/available_set.rb =================================================================== --- lib/rubygems/available_set.rb (revision 39532) +++ lib/rubygems/available_set.rb (revision 39533) @@ -1,95 +1,93 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/available_set.rb#L1 -module Gem - class AvailableSet - Tuple = Struct.new(:spec, :source) - - def initialize - @set = [] - @sorted = nil - end +class Gem::AvailableSet + Tuple = Struct.new(:spec, :source) - attr_reader :set + def initialize + @set = [] + @sorted = nil + end - def add(spec, source) - @set << Tuple.new(spec, source) - @sorted = nil - self - end + attr_reader :set - def <<(o) - case o - when AvailableSet - s = o.set - when Array - s = o.map do |sp,so| - if !sp.kind_of?(Specification) or !so.kind_of?(Source) - raise TypeError, "Array must be in [[spec, source], ...] form" - end + def add(spec, source) + @set << Tuple.new(spec, source) + @sorted = nil + self + end - Tuple.new(sp,so) + def <<(o) + case o + when Gem::AvailableSet + s = o.set + when Array + s = o.map do |sp,so| + if !sp.kind_of?(Gem::Specification) or !so.kind_of?(Gem::Source) + raise TypeError, "Array must be in [[spec, source], ...] form" end - else - raise TypeError, "Must be an AvailableSet" + + Tuple.new(sp,so) end + else + raise TypeError, "must be a Gem::AvailableSet" + end - @set += s - @sorted = nil + @set += s + @sorted = nil - self - end + self + end - def empty? - @set.empty? - end + def empty? + @set.empty? + end - def all_specs - @set.map { |t| t.spec } - end + def all_specs + @set.map { |t| t.spec } + end - def match_platform! - @set.reject! { |t| !Gem::Platform.match(t.spec.platform) } - @sorted = nil - self - end + def match_platform! + @set.reject! { |t| !Gem::Platform.match(t.spec.platform) } + @sorted = nil + self + end - def sorted - @sorted ||= @set.sort do |a,b| - i = b.spec <=> a.spec - i != 0 ? i : (a.source <=> b.source) - end + def sorted + @sorted ||= @set.sort do |a,b| + i = b.spec <=> a.spec + i != 0 ? i : (a.source <=> b.source) end + end - def size - @set.size - end + def size + @set.size + end - def source_for(spec) - f = @set.find { |t| t.spec == spec } - f.source - end + def source_for(spec) + f = @set.find { |t| t.spec == spec } + f.source + end - def pick_best! - return self if empty? + def pick_best! + return self if empty? - @set = [sorted.first] - @sorted = nil - self - end + @set = [sorted.first] + @sorted = nil + self + end - def remove_installed!(dep) - @set.reject! do |t| - # already locally installed - Gem::Specification.any? do |installed_spec| - dep.name == installed_spec.name and - dep.requirement.satisfied_by? installed_spec.version - end + def remove_installed!(dep) + @set.reject! do |t| + # already locally installed + Gem::Specification.any? do |installed_spec| + dep.name == installed_spec.name and + dep.requirement.satisfied_by? installed_spec.version end - - @sorted = nil - self end - def inject_into_list(dep_list) - @set.each { |t| dep_list.add t.spec } - end + @sorted = nil + self + end + + def inject_into_list(dep_list) + @set.each { |t| dep_list.add t.spec } end end Index: lib/rubygems/dependency_installer.rb =================================================================== --- lib/rubygems/dependency_installer.rb (revision 39532) +++ lib/rubygems/dependency_installer.rb (revision 39533) @@ -88,6 +88,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L88 # we absolutely must. @minimal_deps = options[:minimal_deps] + @available = nil @installed_gems = [] @toplevel_specs = nil @@ -101,6 +102,22 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L102 attr_reader :errors ## + # Creates an AvailableSet to install from based on +dep_or_name+ and + # +version+ + + def available_set_for dep_or_name, version # :nodoc: + if String === dep_or_name then + find_spec_by_name_and_version dep_or_name, version, @prerelease + else + dep = dep_or_name.dup + dep.prerelease = @prerelease + @available = find_gems_with_sources dep + end + + @available.pick_best! + end + + ## # Indicated, based on the requested domain, if local # gems should be considered. @@ -302,13 +319,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L319 # separately. def install dep_or_name, version = Gem::Requirement.default - if String === dep_or_name then - find_spec_by_name_and_version dep_or_name, version, @prerelease - else - dep = dep_or_name.dup - dep.prerelease = @prerelease - @available = find_gems_with_sources(dep).pick_best! - end + available_set_for dep_or_name, version @installed_gems = [] @@ -367,12 +378,9 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L378 # it's documentation. Ideally the hook adder could decide whether to be in # the background or not, and what to call it. in_background "Installing documentation" do - start = Time.now Gem.done_installing_hooks.each do |hook| hook.call self, @installed_gems end - finish = Time.now - say "Done installing documentation for #{@installed_gems.map(&:name).join(', ')} (#{(finish-start).to_i} sec)." end unless Gem.done_installing_hooks.empty? @installed_gems Index: lib/rubygems/package.rb =================================================================== --- lib/rubygems/package.rb (revision 39532) +++ lib/rubygems/package.rb (revision 39533) @@ -387,8 +387,8 @@ EOM https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package.rb#L387 @spec = Gem::Specification.from_yaml entry.read when 'metadata.gz' then args = [entry] - args << { :external_encoding => Encoding::UTF_8 } if - Object.const_defined? :Encoding + args << { :external_encoding => Encoding::UTF_8 } unless + Zlib::GzipReader.method(:wrap).arity == 1 Zlib::GzipReader.wrap(*args) do |gzio| @spec = Gem::Specification.from_yaml gzio.read Index: lib/rubygems/installer.rb =================================================================== --- lib/rubygems/installer.rb (revision 39532) +++ lib/rubygems/installer.rb (revision 39533) @@ -132,7 +132,7 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L132 def check_executable_overwrite filename # :nodoc: return if @force - generated_bin = File.join @bin_dir, filename + generated_bin = File.join @bin_dir, formatted_program_filename(filename) return unless File.exist? generated_bin Index: lib/rubygems/ssl_certs/GeoTrust_Global_CA.pem =================================================================== --- lib/rubygems/ssl_certs/GeoTrust_Global_CA.pem (revision 0) +++ lib/rubygems/ssl_certs/GeoTrust_Global_CA.pem (revision 39533) @@ -0,0 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ssl_certs/GeoTrust_Global_CA.pem#L1 +-----BEGIN CERTIFICATE----- +MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT +MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i +YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG +EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg +R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9 +9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq +fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv +iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU +1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+ +bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW +MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA +ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l +uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn +Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS +tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF +PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un +hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV +5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw== +-----END CERTIFICATE----- \ No newline at end of file Index: lib/rubygems/dependency_list.rb =================================================================== --- lib/rubygems/dependency_list.rb (revision 39532) +++ lib/rubygems/dependency_list.rb (revision 39533) @@ -49,7 +49,7 @@ class Gem::DependencyList https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_list.rb#L49 # Adds +gemspecs+ to the dependency list. def add(*gemspecs) - @specs.push(*gemspecs) + @specs.concat gemspecs end def clear Index: test/rubygems/test_gem_source_list.rb =================================================================== --- test/rubygems/test_gem_source_list.rb (revision 39532) +++ test/rubygems/test_gem_source_list.rb (revision 39533) @@ -5,7 +5,7 @@ class TestGemSourceList < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_source_list.rb#L5 def setup super - @uri = "http://blah.com" + @uri = "http://example" @source = Gem::Source.new(@uri) @sl = Gem::SourceList.new Index: test/rubygems/test_gem_dependency_installer.rb =================================================================== --- test/rubygems/test_gem_dependency_installer.rb (revision 39532) +++ test/rubygems/test_gem_dependency_installer.rb (revision 39533) @@ -35,6 +35,61 @@ class TestGemDependencyInstaller < Gem:: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_dependency_installer.rb#L35 util_reset_gems end + def test_available_set_for_name + util_setup_gems + p1a, gem = util_gem 'a', '10.a' + util_setup_spec_fetcher p1a, @a1, @a1_pre + + inst = Gem::DependencyInstaller.new + + available = inst.available_set_for 'a', Gem::Requirement.default + + assert_equal %w[a-1], available.set.map { |s| s.spec.full_name } + end + + def test_available_set_for_name_prerelease + util_setup_gems + p1a, gem = util_gem 'a', '10.a' + util_setup_spec_fetcher p1a, @a1, @a1_pre + + inst = Gem::DependencyInstaller.new :prerelease => true + + available = inst.available_set_for 'a', Gem::Requirement.default + + assert_equal %w[a-10.a], + available.sorted.map { |s| s.spec.full_name } + end + + def test_available_set_for_dep + util_setup_gems + p1a, gem = util_gem 'a', '10.a' + util_setup_spec_fetcher p1a, @a1, @a1_pre + + inst = Gem::DependencyInstaller.new + + dep = Gem::Dependency.new 'a', Gem::Requirement.default + + available = inst.available_set_for dep, Gem::Requirement.default + + assert_equal %w[a-1], available.set.map { |s| s.spec.full_name } + end + + def test_available_set_for_dep_prerelease + util_setup_gems + p1a, gem = util_gem 'a', '10.a' + util_setup_spec_fetcher p1a, @a1, @a1_pre + + inst = Gem::DependencyInstaller.new :prerelease => true + + dep = Gem::Dependency.new 'a', Gem::Requirement.default + dep.prerelease = true + + available = inst.available_set_for dep, Gem::Requirement.default + + assert_equal %w[a-10.a], + available.sorted.map { |s| s.spec.full_name } + end + def test_install util_setup_gems Index: test/rubygems/test_gem_installer.rb =================================================================== --- test/rubygems/test_gem_installer.rb (revision 39532) +++ test/rubygems/test_gem_installer.rb (revision 39533) @@ -190,6 +190,43 @@ load Gem.bin_path('a', 'executable', ver https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L190 Gem::ConfigMap[:bindir] = orig_bindir end + def test_check_executable_overwrite_format_executable + @installer.generate_bin + + @spec = Gem::Specification.new do |s| + s.files = ['lib/code.rb'] + s.name = "a" + s.version = "3" + s.summary = "summary" + s.description = "desc" + s.require_path = 'lib' + end + + open File.join(util_inst_bindir, 'executable'), 'w' do |io| + io.write <<-EXEC +#!/usr/local/bin/ruby +# +# This file was generated by RubyGems + +gem 'other', version + EXEC + end + + util_make_exec + Gem::Installer.exec_format = 'foo-%s-bar' + @installer.gem_dir = @spec.gem_dir + @installer.wrappers = true + @installer.format_executable = true + + @installer.generate_bin # should not raise + + installed_exec = File.join util_inst_bindir, 'foo-executable-bar' + assert File.exist? installed_exec + + wrapper = File.read installed_exec + assert_match %r|generated by RubyGems|, wrapper + end + def test_check_executable_overwrite_other_gem util_conflict_executable true -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/