mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Import rubygems 1.5.0 (released version @ 1fb59d0)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f4234c9b8f
commit
ec84bfc9e3
17 changed files with 201 additions and 46 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Feb 1 11:03:47 2011 Ryan Davis <ryan@lust.local>
|
||||||
|
|
||||||
|
* lib/rubygems*: Import rubygems 1.5.0 (released version @ 1fb59d0)
|
||||||
|
* test/rubygems: Ditto
|
||||||
|
|
||||||
Tue Feb 1 08:01:39 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Feb 1 08:01:39 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/io/console/console.c (console_set_winsize): new method to set
|
* ext/io/console/console.c (console_set_winsize): new method to set
|
||||||
|
|
|
@ -10,13 +10,9 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
require 'rubygems/user_interaction'
|
require 'rubygems/user_interaction'
|
||||||
|
|
||||||
begin
|
|
||||||
require 'psych'
|
|
||||||
rescue LoadError
|
|
||||||
end
|
|
||||||
|
|
||||||
Gem.load_yaml
|
Gem.load_yaml
|
||||||
|
|
||||||
require 'rubygems/package'
|
require 'rubygems/package'
|
||||||
|
|
|
@ -342,8 +342,10 @@ abort "#{deprecation_message}"
|
||||||
require 'rdoc/rdoc'
|
require 'rdoc/rdoc'
|
||||||
|
|
||||||
args << '--quiet'
|
args << '--quiet'
|
||||||
args << '--main' << 'README'
|
args << '--main' << 'README.rdoc'
|
||||||
args << '.' << 'README' << 'LICENSE.txt' << 'GPL.txt'
|
args << '.'
|
||||||
|
args << 'README.rdoc' << 'UPGRADING.rdoc'
|
||||||
|
args << 'LICENSE.txt' << 'GPL.txt' << 'History.txt'
|
||||||
|
|
||||||
r = RDoc::RDoc.new
|
r = RDoc::RDoc.new
|
||||||
r.document args
|
r.document args
|
||||||
|
|
|
@ -71,6 +71,22 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
#
|
||||||
|
# Find cached filename in Gem.path. Returns nil if the file cannot be found.
|
||||||
|
#
|
||||||
|
#--
|
||||||
|
# TODO: see comments in get_path() about general service.
|
||||||
|
|
||||||
|
def find_in_cache(filename)
|
||||||
|
Gem.path.each do |gem_dir|
|
||||||
|
this_path = File.join gem_dir, 'cache', filename
|
||||||
|
return this_path if File.exist? this_path
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Return the full path to the cached gem file matching the given
|
# Return the full path to the cached gem file matching the given
|
||||||
# name and version requirement. Returns 'nil' if no match.
|
# name and version requirement. Returns 'nil' if no match.
|
||||||
|
@ -101,13 +117,9 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
||||||
|
|
||||||
# We expect to find (basename).gem in the 'cache' directory. Furthermore,
|
# We expect to find (basename).gem in the 'cache' directory. Furthermore,
|
||||||
# the name match must be exact (ignoring case).
|
# the name match must be exact (ignoring case).
|
||||||
filename = selected.file_name
|
|
||||||
path = nil
|
path = find_in_cache(selected.file_name)
|
||||||
|
return download(dependency) unless path
|
||||||
Gem.path.find do |gem_dir|
|
|
||||||
path = File.join gem_dir, 'cache', filename
|
|
||||||
File.exist? path
|
|
||||||
end
|
|
||||||
|
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,8 +47,13 @@ class Gem::Format
|
||||||
|
|
||||||
Gem::OldFormat.from_file_by_path file_path
|
Gem::OldFormat.from_file_by_path file_path
|
||||||
else
|
else
|
||||||
open file_path, Gem.binary_mode do |io|
|
begin
|
||||||
from_io io, file_path, security_policy
|
open file_path, Gem.binary_mode do |io|
|
||||||
|
from_io io, file_path, security_policy
|
||||||
|
end
|
||||||
|
rescue Gem::Package::TarInvalidError => e
|
||||||
|
message = "corrupt gem (#{e.class}: #{e.message})"
|
||||||
|
raise Gem::Package::FormatError.new(message, file_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -395,19 +395,19 @@ class Gem::Installer
|
||||||
:force => false,
|
:force => false,
|
||||||
:install_dir => Gem.dir,
|
:install_dir => Gem.dir,
|
||||||
:source_index => Gem.source_index,
|
:source_index => Gem.source_index,
|
||||||
}.merge @options
|
}.merge options
|
||||||
|
|
||||||
@env_shebang = @options[:env_shebang]
|
@env_shebang = options[:env_shebang]
|
||||||
@force = @options[:force]
|
@force = options[:force]
|
||||||
gem_home = @options[:install_dir]
|
gem_home = options[:install_dir]
|
||||||
@gem_home = File.expand_path(gem_home)
|
@gem_home = File.expand_path(gem_home)
|
||||||
@ignore_dependencies = @options[:ignore_dependencies]
|
@ignore_dependencies = options[:ignore_dependencies]
|
||||||
@format_executable = @options[:format_executable]
|
@format_executable = options[:format_executable]
|
||||||
@security_policy = @options[:security_policy]
|
@security_policy = options[:security_policy]
|
||||||
@wrappers = @options[:wrappers]
|
@wrappers = options[:wrappers]
|
||||||
@bin_dir = @options[:bin_dir]
|
@bin_dir = options[:bin_dir]
|
||||||
@development = @options[:development]
|
@development = options[:development]
|
||||||
@source_index = @options[:source_index]
|
@source_index = options[:source_index]
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_gem_file
|
def load_gem_file
|
||||||
|
@ -508,7 +508,7 @@ TEXT
|
||||||
rescue TypeError # extension == nil
|
rescue TypeError # extension == nil
|
||||||
@gem_dir
|
@gem_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Dir.chdir extension_dir do
|
Dir.chdir extension_dir do
|
||||||
|
|
|
@ -45,7 +45,23 @@ module Gem::Package
|
||||||
class ClosedIO < Error; end
|
class ClosedIO < Error; end
|
||||||
class BadCheckSum < Error; end
|
class BadCheckSum < Error; end
|
||||||
class TooLongFileName < Error; end
|
class TooLongFileName < Error; end
|
||||||
class FormatError < Error; end
|
class FormatError < Error
|
||||||
|
attr_reader :path
|
||||||
|
|
||||||
|
def initialize message, path = nil
|
||||||
|
@path = path
|
||||||
|
|
||||||
|
message << " in #{path}" if path
|
||||||
|
|
||||||
|
super message
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Raised when a tar file is corrupt
|
||||||
|
|
||||||
|
class TarInvalidError < Error; end
|
||||||
|
|
||||||
def self.open(io, mode = "r", signer = nil, &block)
|
def self.open(io, mode = "r", signer = nil, &block)
|
||||||
tar_type = case mode
|
tar_type = case mode
|
||||||
|
|
|
@ -117,7 +117,11 @@ class Gem::Package::TarInput
|
||||||
@tarreader.rewind
|
@tarreader.rewind
|
||||||
@fileops = Gem::FileOperations.new
|
@fileops = Gem::FileOperations.new
|
||||||
|
|
||||||
raise Gem::Package::FormatError, "No metadata found!" unless has_meta
|
unless has_meta then
|
||||||
|
path = io.path if io.respond_to? :path
|
||||||
|
error = Gem::Package::FormatError.new 'no metadata found', path
|
||||||
|
raise error
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
|
|
|
@ -73,6 +73,10 @@ class Gem::Package::TarReader::Entry
|
||||||
else
|
else
|
||||||
@header.name
|
@header.name
|
||||||
end
|
end
|
||||||
|
rescue ArgumentError => e
|
||||||
|
raise unless e.message == 'string contains null byte'
|
||||||
|
raise Gem::Package::TarInvalidError,
|
||||||
|
'tar is corrupt, name contains null byte'
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Gem::PackageTask < Rake::PackageTask
|
||||||
# Initialization tasks without the "yield self" or define operations.
|
# Initialization tasks without the "yield self" or define operations.
|
||||||
|
|
||||||
def init(gem)
|
def init(gem)
|
||||||
super gem.name, gem.version
|
super gem.full_name, :noversion
|
||||||
@gem_spec = gem
|
@gem_spec = gem
|
||||||
@package_files += gem_spec.files if gem_spec.files
|
@package_files += gem_spec.files if gem_spec.files
|
||||||
end
|
end
|
||||||
|
@ -120,11 +120,13 @@ class Gem::PackageTask < Rake::PackageTask
|
||||||
chdir(gem_dir) do
|
chdir(gem_dir) do
|
||||||
when_writing "Creating #{gem_spec.file_name}" do
|
when_writing "Creating #{gem_spec.file_name}" do
|
||||||
Gem::Builder.new(gem_spec).build
|
Gem::Builder.new(gem_spec).build
|
||||||
verbose(true) {
|
verbose trace do
|
||||||
mv gem_file, ".."
|
mv gem_file, '..'
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -530,9 +530,21 @@ end
|
||||||
##
|
##
|
||||||
# SilentUI is a UI choice that is absolutely silent.
|
# SilentUI is a UI choice that is absolutely silent.
|
||||||
|
|
||||||
class Gem::SilentUI
|
class Gem::SilentUI < Gem::StreamUI
|
||||||
def method_missing(sym, *args, &block)
|
|
||||||
self
|
def initialize
|
||||||
|
|
||||||
|
reader, writer = nil, nil
|
||||||
|
|
||||||
|
if Gem.win_platform?
|
||||||
|
reader = File.open('nul', 'r')
|
||||||
|
writer = File.open('nul', 'w')
|
||||||
|
else
|
||||||
|
reader = File.open('/dev/null', 'r')
|
||||||
|
writer = File.open('/dev/null', 'w')
|
||||||
|
end
|
||||||
|
|
||||||
|
super reader, writer, writer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,46 @@ class TestGemCommandsUnpackCommand < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_find_in_cache
|
||||||
|
util_make_gems
|
||||||
|
|
||||||
|
assert_equal(
|
||||||
|
@cmd.find_in_cache(@a1.file_name),
|
||||||
|
File.join(@gemhome, 'cache', @a1.file_name),
|
||||||
|
'found a-1.gem in the cache'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_path
|
||||||
|
util_make_gems
|
||||||
|
util_setup_fake_fetcher
|
||||||
|
util_setup_spec_fetcher @a1
|
||||||
|
|
||||||
|
a1_data = nil
|
||||||
|
|
||||||
|
open File.join(@gemhome, 'cache', @a1.file_name), 'rb' do |fp|
|
||||||
|
a1_data = fp.read
|
||||||
|
end
|
||||||
|
|
||||||
|
Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-1.gem'] =
|
||||||
|
a1_data
|
||||||
|
|
||||||
|
dep = Gem::Dependency.new(@a1.name, @a1.version)
|
||||||
|
assert_equal(
|
||||||
|
@cmd.get_path(dep),
|
||||||
|
File.join(@gemhome, 'cache', @a1.file_name),
|
||||||
|
'fetches a-1 and returns the cache path'
|
||||||
|
)
|
||||||
|
|
||||||
|
FileUtils.rm File.join(@gemhome, 'cache', @a1.file_name)
|
||||||
|
|
||||||
|
assert_equal(
|
||||||
|
@cmd.get_path(dep),
|
||||||
|
File.join(@gemhome, 'cache', @a1.file_name),
|
||||||
|
'when removed from cache, refetches a-1'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
util_make_gems
|
util_make_gems
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
|
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
require 'rubygems/test_case'
|
require 'rubygems/package/tar_test_case'
|
||||||
require "test/rubygems/simple_gem"
|
require 'test/rubygems/simple_gem'
|
||||||
require 'rubygems/format'
|
require 'rubygems/format'
|
||||||
|
|
||||||
class TestGemFormat < Gem::TestCase
|
class TestGemFormat < Gem::Package::TarTestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
@ -16,6 +16,7 @@ class TestGemFormat < Gem::TestCase
|
||||||
@simple_gem = SIMPLE_GEM
|
@simple_gem = SIMPLE_GEM
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# HACK this test should do less
|
||||||
def test_class_from_file_by_path
|
def test_class_from_file_by_path
|
||||||
util_make_gems
|
util_make_gems
|
||||||
|
|
||||||
|
@ -34,6 +35,23 @@ class TestGemFormat < Gem::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_class_from_file_by_path_corrupt
|
||||||
|
Tempfile.open 'corrupt' do |io|
|
||||||
|
data = Gem.gzip 'a' * 10
|
||||||
|
io.write tar_file_header('metadata.gz', "\000x", 0644, data.length)
|
||||||
|
io.write data
|
||||||
|
io.rewind
|
||||||
|
|
||||||
|
e = assert_raises Gem::Package::FormatError do
|
||||||
|
Gem::Format.from_file_by_path io.path
|
||||||
|
end
|
||||||
|
|
||||||
|
sub_message = 'Gem::Package::TarInvalidError: tar is corrupt, name contains null byte'
|
||||||
|
assert_equal "corrupt gem (#{sub_message}) in #{io.path}", e.message
|
||||||
|
assert_equal io.path, e.path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_class_from_file_by_path_empty
|
def test_class_from_file_by_path_empty
|
||||||
util_make_gems
|
util_make_gems
|
||||||
|
|
||||||
|
@ -55,21 +73,21 @@ class TestGemFormat < Gem::TestCase
|
||||||
Gem::Format.from_io(StringIO.new(@simple_gem.upcase))
|
Gem::Format.from_io(StringIO.new(@simple_gem.upcase))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'No metadata found!', e.message
|
assert_equal 'no metadata found', e.message
|
||||||
|
|
||||||
e = assert_raises Gem::Package::FormatError do
|
e = assert_raises Gem::Package::FormatError do
|
||||||
# Totally bogus input
|
# Totally bogus input
|
||||||
Gem::Format.from_io(StringIO.new(@simple_gem.reverse))
|
Gem::Format.from_io(StringIO.new(@simple_gem.reverse))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'No metadata found!', e.message
|
assert_equal 'no metadata found', e.message
|
||||||
|
|
||||||
e = assert_raises Gem::Package::FormatError do
|
e = assert_raises Gem::Package::FormatError do
|
||||||
# This was intentionally screws up YAML parsing.
|
# This was intentionally screws up YAML parsing.
|
||||||
Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
|
Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'No metadata found!', e.message
|
assert_equal 'no metadata found', e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,7 +59,24 @@ class TestGemPackageTarInput < Gem::Package::TarTestCase
|
||||||
@entry_contents = %w[0123456789 01234]
|
@entry_contents = %w[0123456789 01234]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_each_works
|
def test_initialize_no_metadata_file
|
||||||
|
Tempfile.open 'no_meta' do |io|
|
||||||
|
io.write tar_file_header('a', '', 0644, 1)
|
||||||
|
io.write 'a'
|
||||||
|
io.rewind
|
||||||
|
|
||||||
|
e = assert_raises Gem::Package::FormatError do
|
||||||
|
open io.path, Gem.binary_mode do |file|
|
||||||
|
Gem::Package::TarInput.open file do end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "no metadata found in #{io.path}", e.message
|
||||||
|
assert_equal io.path, e.path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_each
|
||||||
open @file, 'rb' do |io|
|
open @file, 'rb' do |io|
|
||||||
Gem::Package::TarInput.open io do |tar_input|
|
Gem::Package::TarInput.open io do |tar_input|
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -79,7 +96,7 @@ class TestGemPackageTarInput < Gem::Package::TarTestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_extract_entry_works
|
def test_extract_entry
|
||||||
open @file, 'rb' do |io|
|
open @file, 'rb' do |io|
|
||||||
Gem::Package::TarInput.open io do |tar_input|
|
Gem::Package::TarInput.open io do |tar_input|
|
||||||
assert_equal @spec, tar_input.metadata
|
assert_equal @spec, tar_input.metadata
|
||||||
|
|
|
@ -67,6 +67,16 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
|
||||||
assert_equal 'lib/foo', @entry.full_name
|
assert_equal 'lib/foo', @entry.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_full_name_null
|
||||||
|
@entry.header.prefix << "\000"
|
||||||
|
|
||||||
|
e = assert_raises Gem::Package::TarInvalidError do
|
||||||
|
@entry.full_name
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal 'tar is corrupt, name contains null byte', e.message
|
||||||
|
end
|
||||||
|
|
||||||
def test_getc
|
def test_getc
|
||||||
assert_equal ?a, @entry.getc
|
assert_equal ?a, @entry.getc
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,5 +48,18 @@ class TestGemPackageTask < Gem::TestCase
|
||||||
assert_equal ["x", "y"], pkg.package_files
|
assert_equal ["x", "y"], pkg.package_files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_package_dir_path
|
||||||
|
gem = Gem::Specification.new do |g|
|
||||||
|
g.name = 'nokogiri'
|
||||||
|
g.version = '1.5.0'
|
||||||
|
g.platform = 'java'
|
||||||
|
end
|
||||||
|
|
||||||
|
pkg = Gem::PackageTask.new gem
|
||||||
|
pkg.define
|
||||||
|
|
||||||
|
assert_equal 'pkg/nokogiri-1.5.0-java', pkg.package_dir_path
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -93,4 +93,3 @@ class TestGemSecurity < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
end if defined?(OpenSSL)
|
end if defined?(OpenSSL)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue