mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
c107372597
commit
04817ae6d3
38 changed files with 587 additions and 88 deletions
|
@ -1,4 +1,10 @@
|
|||
##
|
||||
# This module contains various utility methods as module methods.
|
||||
|
||||
module Gem::Util
|
||||
|
||||
@silent_mutex = nil
|
||||
|
||||
##
|
||||
# Zlib::GzipReader wrapper that unzips +data+.
|
||||
|
||||
|
@ -60,4 +66,56 @@ module Gem::Util
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Invokes system, but silences all output.
|
||||
|
||||
def self.silent_system *command
|
||||
require 'thread'
|
||||
|
||||
@silent_mutex ||= Mutex.new
|
||||
|
||||
null_device = Gem.win_platform? ? 'NUL' : '/dev/null'
|
||||
|
||||
@silent_mutex.synchronize do
|
||||
begin
|
||||
stdout = STDOUT.dup
|
||||
stderr = STDERR.dup
|
||||
|
||||
STDOUT.reopen null_device, 'w'
|
||||
STDERR.reopen null_device, 'w'
|
||||
|
||||
return system(*command)
|
||||
ensure
|
||||
STDOUT.reopen stdout
|
||||
STDERR.reopen stderr
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Enumerates the parents of +directory+.
|
||||
|
||||
def self.traverse_parents directory
|
||||
return enum_for __method__, directory unless block_given?
|
||||
|
||||
here = File.expand_path directory
|
||||
start = here
|
||||
|
||||
Dir.chdir start
|
||||
|
||||
begin
|
||||
loop do
|
||||
yield here
|
||||
|
||||
Dir.chdir '..'
|
||||
|
||||
return if Dir.pwd == here # toplevel
|
||||
|
||||
here = Dir.pwd
|
||||
end
|
||||
ensure
|
||||
Dir.chdir start
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue