diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-25 19:14:49 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-25 19:14:49 +0000 |
commit | 04817ae6d3e1d898d6fbf09ad146850d26d2b404 (patch) | |
tree | 7e5482d13830cacf363d21a087b490588a960095 /lib/rubygems/util.rb | |
parent | c107372597586e1ad0fea03c00a14bdd7205b5d8 (diff) | |
download | ruby-04817ae6d3e1d898d6fbf09ad146850d26d2b404.tar.gz |
* 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
Diffstat (limited to 'lib/rubygems/util.rb')
-rw-r--r-- | lib/rubygems/util.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb index 42663974a5..408942d398 100644 --- a/lib/rubygems/util.rb +++ b/lib/rubygems/util.rb @@ -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 |