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 1.3.6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-02-22 02:52:35 +00:00
parent 65544f575b
commit b551e8c8b3
119 changed files with 2735 additions and 2613 deletions

View file

@ -112,6 +112,7 @@ module Gem::UserInteraction
:alert_error,
:alert_warning,
:ask,
:ask_for_password,
:ask_yes_no,
:choose_from_list,
:say,
@ -217,6 +218,50 @@ class Gem::StreamUI
result
end
##
# Ask for a password. Does not echo response to terminal.
def ask_for_password(question)
return nil if not @ins.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
require "Win32API"
char = nil
password = ''
while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
break if char == 10 || char == 13 # received carriage return or newline
if char == 127 || char == 8 # backspace and delete
password.slice!(-1, 1)
else
password << char.chr
end
end
puts
password
end
##
# Asks for a password that works on unix
def ask_for_password_on_unix
system "stty -echo"
password = @ins.gets
password.chomp! if password
system "stty echo"
password
end
##
# Display a statement.