1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-02-27 23:20:57 +00:00
parent 4e040aa6ac
commit a6c92a85e4
11 changed files with 250 additions and 95 deletions

View file

@ -1,3 +1,31 @@
Thu Feb 28 08:20:33 2013 Eric Hodel <drbrain@segment7.net>
* 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@zacharyscott.net>
* thread.c: rdoc formatting for Thread, ThreadGroup, and ThreadError

View file

@ -1,95 +1,93 @@
module Gem
class AvailableSet
Tuple = Struct.new(:spec, :source)
class Gem::AvailableSet
Tuple = Struct.new(:spec, :source)
def initialize
@set = []
@sorted = nil
end
def initialize
@set = []
@sorted = nil
end
attr_reader :set
attr_reader :set
def add(spec, source)
@set << Tuple.new(spec, source)
@sorted = nil
self
end
def add(spec, source)
@set << Tuple.new(spec, source)
@sorted = nil
self
end
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
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
@set += s
@sorted = nil
self
else
raise TypeError, "must be a Gem::AvailableSet"
end
def empty?
@set.empty?
end
@set += s
@sorted = nil
def all_specs
@set.map { |t| t.spec }
end
self
end
def match_platform!
@set.reject! { |t| !Gem::Platform.match(t.spec.platform) }
@sorted = nil
self
end
def empty?
@set.empty?
end
def sorted
@sorted ||= @set.sort do |a,b|
i = b.spec <=> a.spec
i != 0 ? i : (a.source <=> b.source)
end
end
def all_specs
@set.map { |t| t.spec }
end
def size
@set.size
end
def match_platform!
@set.reject! { |t| !Gem::Platform.match(t.spec.platform) }
@sorted = nil
self
end
def source_for(spec)
f = @set.find { |t| t.spec == spec }
f.source
end
def pick_best!
return self if empty?
@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
end
@sorted = nil
self
end
def inject_into_list(dep_list)
@set.each { |t| dep_list.add t.spec }
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 source_for(spec)
f = @set.find { |t| t.spec == spec }
f.source
end
def pick_best!
return self if empty?
@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
end
@sorted = nil
self
end
def inject_into_list(dep_list)
@set.each { |t| dep_list.add t.spec }
end
end

View file

@ -88,6 +88,7 @@ class Gem::DependencyInstaller
# we absolutely must.
@minimal_deps = options[:minimal_deps]
@available = nil
@installed_gems = []
@toplevel_specs = nil
@ -100,6 +101,22 @@ class Gem::DependencyInstaller
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
# 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
# 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

View file

@ -49,7 +49,7 @@ class Gem::DependencyList
# Adds +gemspecs+ to the dependency list.
def add(*gemspecs)
@specs.push(*gemspecs)
@specs.concat gemspecs
end
def clear

View file

@ -132,7 +132,7 @@ class Gem::Installer
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

View file

@ -387,8 +387,8 @@ EOM
@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

View file

@ -37,6 +37,7 @@ end
class Gem::RDoc # :nodoc: all
include Gem::UserInteraction
extend Gem::UserInteraction
@rdoc_version = nil
@specs = []
@ -70,7 +71,8 @@ class Gem::RDoc # :nodoc: all
# +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
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
##

View file

@ -0,0 +1,20 @@
-----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-----

View file

@ -35,6 +35,61 @@ class TestGemDependencyInstaller < Gem::TestCase
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

View file

@ -190,6 +190,43 @@ load Gem.bin_path('a', 'executable', version)
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

View file

@ -5,7 +5,7 @@ class TestGemSourceList < Gem::TestCase
def setup
super
@uri = "http://blah.com"
@uri = "http://example"
@source = Gem::Source.new(@uri)
@sl = Gem::SourceList.new