Class: Imap::Backup::Setup::Asker

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/setup/asker.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(highline) ⇒ Asker

Returns a new instance of Asker.



7
8
9
# File 'lib/imap/backup/setup/asker.rb', line 7

def initialize(highline)
  @highline = highline
end

Class Method Details

.email(default = "") ⇒ Object



32
33
34
# File 'lib/imap/backup/setup/asker.rb', line 32

def self.email(default = "")
  new(Setup.highline).email(default)
end

.passwordObject



36
37
38
# File 'lib/imap/backup/setup/asker.rb', line 36

def self.password
  new(Setup.highline).password
end

Instance Method Details

#email(default = "") ⇒ Object



11
12
13
14
15
16
17
# File 'lib/imap/backup/setup/asker.rb', line 11

def email(default = "")
  highline.ask("email address: ") do |q|
    q.default               = default
    q.validate              = EMAIL_MATCHER
    q.responses[:not_valid] = "Enter a valid email address "
  end
end

#passwordObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/imap/backup/setup/asker.rb', line 19

def password
  password     = highline.ask("password: ")        { |q| q.echo = false }
  confirmation = highline.ask("repeat password: ") { |q| q.echo = false }
  if password != confirmation
    return nil if !highline.agree(
      "the password and confirmation did not match.\nContinue? (y/n) "
    )

    return self.password
  end
  password
end