Module: Machines::Questions

Defined in:
lib/machines/questions.rb

Instance Method Summary collapse

Instance Method Details

#enter_password(type, confirm = true) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/machines/questions.rb', line 3

def enter_password(type, confirm = true)
  begin
    password = ask("Enter #{type} password: ") { |question| question.echo = false }
    break unless confirm
    password_confirmation = ask('Confirm the password: ') { |question| question.echo = false }
    say "Passwords do not match, please re-enter" unless password == password_confirmation
  end while password != password_confirmation
  $conf.passwords << password if $conf.passwords && password.size > 4 && password != 'password'
  password
end