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

* lib/rubygems: Update to RubyGems master ddac51f. Changes:

* Allow override for the shared gem installation directory for
    rubygems packagers.

  * Lock gem cache files for read and write to improve thread safety.

  * Use io/console when available.

  * Minor cleanup.

* test/rubygems:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-12-13 00:51:04 +00:00
parent c2dcb947aa
commit 8fadbe5f3e
12 changed files with 115 additions and 67 deletions

View file

@ -1,3 +1,18 @@
Fri Dec 13 09:50:49 2013 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems master ddac51f. Changes:
* Allow override for the shared gem installation directory for
rubygems packagers.
* Lock gem cache files for read and write to improve thread safety.
* Use io/console when available.
* Minor cleanup.
* test/rubygems: ditto.
Fri Dec 13 08:15:31 2013 Aman Gupta <ruby@tmm1.net>
* class.c (include_modules_at): use RCLASS_M_TBL_WRAPPER for

View file

@ -764,7 +764,10 @@ module Gem
# Safely read a file in binary mode on all platforms.
def self.read_binary(path)
File.open path, binary_mode do |f| f.read end
File.open path, binary_mode do |f|
f.flock(File::LOCK_EX)
f.read
end
end
##
@ -1163,17 +1166,18 @@ module Gem
autoload :ConfigFile, 'rubygems/config_file'
autoload :Dependency, 'rubygems/dependency'
autoload :DependencyList, 'rubygems/dependency_list'
autoload :Resolver, 'rubygems/resolver'
autoload :DependencyResolver, 'rubygems/resolver'
autoload :Installer, 'rubygems/installer'
autoload :PathSupport, 'rubygems/path_support'
autoload :Platform, 'rubygems/platform'
autoload :RequestSet, 'rubygems/request_set'
autoload :Requirement, 'rubygems/requirement'
autoload :Resolver, 'rubygems/resolver'
autoload :Source, 'rubygems/source'
autoload :SourceList, 'rubygems/source_list'
autoload :SpecFetcher, 'rubygems/spec_fetcher'
autoload :Specification, 'rubygems/specification'
autoload :Version, 'rubygems/version'
autoload :Source, 'rubygems/source'
require "rubygems/specification"
end

View file

@ -72,9 +72,16 @@ class Gem::BasicSpecification
# Returns full path to the directory where gem's extensions are installed.
def extension_dir
@extension_dir ||=
File.join base_dir, 'extensions', Gem::Platform.local.to_s,
Gem.extension_api_version, full_name
@extension_dir ||= File.expand_path File.join(extensions_dir, full_name)
end
##
# Returns path to the extensions directory.
def extensions_dir
@extensions_dir ||= Gem.default_ext_dir_for(base_dir) ||
File.join(base_dir, 'extensions', Gem::Platform.local.to_s,
Gem.extension_api_version)
end
def find_full_gem_path # :nodoc:
@ -147,7 +154,9 @@ class Gem::BasicSpecification
@loaded_from = path && path.to_s
@extension_dir = nil
@extensions_dir = nil
@full_gem_path = nil
@gem_dir = nil
@gems_dir = nil
@base_dir = nil
end

View file

@ -51,6 +51,17 @@ module Gem
@default_dir ||= File.join(*path)
end
##
# Returns binary extensions dir for specified RubyGems base dir or nil
# if such directory cannot be determined.
#
# By default, the binary extensions are located side by side with their
# Ruby counterparts, therefore nil is returned
def self.default_ext_dir_for base_dir
nil
end
##
# Paths where RubyGems' .rb files and bin files are installed

View file

@ -292,6 +292,7 @@ class Gem::RemoteFetcher
if update and path then
open(path, 'wb') do |io|
io.flock(File::LOCK_EX)
io.write data
end
end

View file

@ -1,8 +1,4 @@
require 'rubygems'
require 'rubygems/dependency'
require 'rubygems/dependency_list'
require 'rubygems/installer'
require 'rubygems/resolver'
require 'tsort'
##

View file

@ -9,9 +9,7 @@ require 'rubygems/util'
# source =
# Gem::Source::Git.new 'rake', 'git@example:rake.git', 'rake-10.1.0', false
#
# spec = source.load_spec 'rake'
#
# source.checkout
# source.specs
class Gem::Source::Git < Gem::Source
@ -187,15 +185,13 @@ class Gem::Source::Git < Gem::Source
Dir.chdir directory do
spec = Gem::Specification.load file
if spec then
loaded_from = File.expand_path file
spec.loaded_from = loaded_from
spec.base_dir = base_dir
spec.extension_dir =
File.join base_dir, 'extensions', Gem::Platform.local.to_s,
Gem.extension_api_version, "#{name}-#{dir_shortref}"
spec.full_gem_path = File.dirname loaded_from if spec
spec.full_gem_path = File.dirname spec.loaded_from if spec
end
spec
end

View file

@ -1916,7 +1916,6 @@ class Gem::Specification < Gem::BasicSpecification
@cache_dir = nil
@cache_file = nil
@doc_dir = nil
@gem_dir = nil
@ri_dir = nil
@spec_dir = nil
@spec_file = nil

View file

@ -24,16 +24,19 @@ unless Gem::Dependency.new('rdoc', '>= 3.10').matching_specs.empty?
gem 'json'
end
require 'rubygems/deprecate'
require 'minitest/autorun'
require 'rubygems/deprecate'
require 'fileutils'
require 'pathname'
require 'pp'
require 'rubygems/package'
require 'shellwords'
require 'tmpdir'
require 'uri'
require 'rubygems/package'
require 'pp'
require 'zlib'
require 'pathname'
require 'shellwords'
Gem.load_yaml
require 'rubygems/mock_gem_ui'

View file

@ -4,6 +4,11 @@
# See LICENSE.txt for permissions.
#++
begin
require 'io/console'
rescue LoadError
end
##
# Module that defines the default UserInteraction. Any class including this
# module will have access to the +ui+ method that returns the default UI.
@ -283,41 +288,27 @@ class Gem::StreamUI
result
end
if RUBY_VERSION > '1.9.2' then
##
# Ask for a password. Does not echo response to terminal.
##
# Ask for a password. Does not echo response to terminal.
def ask_for_password(question)
return nil if not tty?
def ask_for_password(question)
return nil if not tty?
require 'io/console'
@outs.print(question, " ")
@outs.flush
@outs.print(question + " ")
@outs.flush
password = _gets_noecho
@outs.puts
password.chomp! if password
password
end
password = @ins.noecho {@ins.gets}
password.chomp! if password
password
if IO.method_defined?(:noecho) then
def _gets_noecho
@ins.noecho {@ins.gets}
end
else
##
# Ask for a password. Does not echo response to terminal.
def ask_for_password(question)
return nil if not tty?
@outs.print(question + " ")
@outs.flush
Gem.win_platform? ? ask_for_password_on_windows : ask_for_password_on_unix
end
##
# Asks for a password that works on windows. Ripped from the Heroku gem.
def ask_for_password_on_windows
return nil if not tty?
elsif Gem.win_platform?
def _gets_noecho
require "Win32API"
char = nil
password = ''
@ -330,22 +321,16 @@ class Gem::StreamUI
password << char.chr
end
end
puts
password
end
##
# Asks for a password that works on unix
def ask_for_password_on_unix
return nil if not tty?
else
def _gets_noecho
system "stty -echo"
password = @ins.gets
password.chomp! if password
system "stty echo"
password
begin
@ins.gets
ensure
system "stty echo"
end
end
end

View file

@ -108,7 +108,7 @@ Added '/CN=alternate/DC=example'
@cmd.execute
end
output = @build_ui.output.split "\n"
output = @build_ui.output.squeeze("\n").split "\n"
assert_equal "Passphrase for your Private Key: ",
output.shift
@ -142,7 +142,7 @@ Added '/CN=alternate/DC=example'
@cmd.execute
end
output = @build_ui.output.split "\n"
output = @build_ui.output.squeeze("\n").split "\n"
assert_equal "Passphrase for your Private Key: ",
output.shift

View file

@ -1461,6 +1461,35 @@ dependencies: []
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
end
def test_extension_dir_override
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
RbConfig::CONFIG['ENABLE_SHARED'], 'no'
class << Gem
alias orig_default_ext_dir_for default_ext_dir_for
def Gem.default_ext_dir_for(base_dir)
'elsewhere'
end
end
ext_spec
refute_empty @ext.extensions
expected = File.join @tempdir, 'elsewhere', @ext.full_name
assert_equal expected, @ext.extension_dir
ensure
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
class << Gem
remove_method :default_ext_dir_for
alias default_ext_dir_for orig_default_ext_dir_for
end
end
def test_files
@a1.files = %w(files bin/common)
@a1.test_files = %w(test_files bin/common)