Module: Ghaki::Account::Password
Constant Summary collapse
- ASK_PASSWORD_RETRY_MAX =
CONSTANTS
3
Instance Method Summary collapse
- #ask_password(opts = {}) ⇒ Object
- #fail_password ⇒ Object
- #failed_passwords? ⇒ Boolean
-
#opt_password(opts) ⇒ Object
overrides autogenerated.
-
#password ⇒ Object
OBJECT METHODS.
- #passwords ⇒ Object
- #passwords=(pass) ⇒ Object (also: #password=)
- #reset_passwords ⇒ Object
- #retry_password? ⇒ Boolean
- #valid_password? ⇒ Boolean
Methods included from SynOpts
Instance Method Details
#ask_password(opts = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ghaki/account/password.rb', line 66 def ask_password opts={} f_ques,r_ques = _password_prompt( opts ), nil (1..(opts[:retry_max] || ASK_PASSWORD_RETRY_MAX)).each do self.password = HighLine.new.ask( r_ques || f_ques ) do |q| q.echo = '*' end return self.password if valid_password? r_ques ||= '* TRY AGAIN * ' + f_ques end raise InvalidPasswordError, 'Invalid Password Specified' end |
#fail_password ⇒ Object
51 52 53 |
# File 'lib/ghaki/account/password.rb', line 51 def fail_password _bad_passwords.push _try_passwords.shift unless _try_passwords.empty? end |
#failed_passwords? ⇒ Boolean
62 63 64 |
# File 'lib/ghaki/account/password.rb', line 62 def failed_passwords? !_bad_passwords.empty? end |
#opt_password(opts) ⇒ Object
overrides autogenerated
19 20 21 22 |
# File 'lib/ghaki/account/password.rb', line 19 def opt_password opts val = Password.parse_opts( opts ) self.passwords = val end |
#password ⇒ Object
OBJECT METHODS
33 34 35 |
# File 'lib/ghaki/account/password.rb', line 33 def password @cur_password ||= _try_passwords.first end |
#passwords ⇒ Object
36 37 38 |
# File 'lib/ghaki/account/password.rb', line 36 def passwords @all_passwords ||= [] end |
#passwords=(pass) ⇒ Object Also known as: password=
40 41 42 43 |
# File 'lib/ghaki/account/password.rb', line 40 def passwords= pass @cur_passwords = nil @all_passwords = if pass.nil? then [] else [pass].flatten end end |
#reset_passwords ⇒ Object
46 47 48 49 50 |
# File 'lib/ghaki/account/password.rb', line 46 def reset_passwords @try_passwords = nil @bad_passwords = nil @cur_password = nil end |
#retry_password? ⇒ Boolean
54 55 56 |
# File 'lib/ghaki/account/password.rb', line 54 def retry_password? !_try_passwords.empty? end |
#valid_password? ⇒ Boolean
58 59 60 |
# File 'lib/ghaki/account/password.rb', line 58 def valid_password? !passwords.empty? end |