Class: Shhh::App::Input::Handler
- Inherits:
-
Object
- Object
- Shhh::App::Input::Handler
- Defined in:
- lib/shhh/app/input/handler.rb
Instance Method Summary collapse
Instance Method Details
#ask ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/shhh/app/input/handler.rb', line 8 def ask retries ||= 0 prompt('Password: ', :green) rescue ::OpenSSL::Cipher::CipherError STDERR.puts 'Invalid password. Please try again.' retry if (retries += 1) < 3 nil end |
#new_password ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/shhh/app/input/handler.rb', line 25 def new_password password = prompt('New Password : ', :blue) raise Shhh::Errors::PasswordTooShort.new( 'Minimum length is 7 characters.') if password.length < 7 password_confirm = prompt('Confirm Password : ', :blue) raise Shhh::Errors::PasswordsDontMatch.new( 'The passwords you entered do not match.') if password != password_confirm password end |
#prompt(message, color) ⇒ Object
21 22 23 |
# File 'lib/shhh/app/input/handler.rb', line 21 def prompt(, color) HighLine.new(STDIN, STDERR).ask(.bold) { |q| q.echo = '•'.send(color) } end |
#puts(*args) ⇒ Object
17 18 19 |
# File 'lib/shhh/app/input/handler.rb', line 17 def puts(*args) STDERR.puts args end |