Class: DeployGate::Commands::Login

Inherits:
Object
  • Object
show all
Defined in:
lib/deploygate/commands/login.rb

Defined Under Namespace

Classes: AccountNotFoundError

Class Method Summary collapse

Class Method Details

.input_password(message) ⇒ String

Returns:

  • (String)


63
64
65
# File 'lib/deploygate/commands/login.rb', line 63

def input_password(message)
  ask(message) { |q| q.echo = "*" }
end

.login_successObject



57
58
59
60
# File 'lib/deploygate/commands/login.rb', line 57

def 
  session = Session.new
  puts HighLine.color(I18n.t('commands.login.start.success', name: session.name), HighLine::GREEN)
end


67
68
69
70
71
72
73
74
75
76
77
# File 'lib/deploygate/commands/login.rb', line 67

def print_deploygate_aa
  puts <<'EOF'
 _            _                       _
| |          | |                     | |
      __| | ___  ___ | | ___ _   ,____   ___ | |_ ___
     / _` |/ _ \' _ \| |/ _ \ \ / / _ \ / _ `| __/ _ \
    | (_| |  __/ |_) | | (_) \ v / (_| | (_| | |_' __/
     \___, \___| .__/|_|\___/ ` / \__, |\__,_|\__\___`
       |_|           /_/  |___/
EOF
end

.run(args, options) ⇒ void

This method returns an undefined value.



9
10
11
12
13
14
15
16
17
# File 'lib/deploygate/commands/login.rb', line 9

def run(args, options)
  welcome()

  if options.terminal
    ()
  else
    DeployGate::BrowserLogin.new().start()
  end
end

.start(email, password) ⇒ void

This method returns an undefined value.

Parameters:

  • email (String)
  • password (String)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/deploygate/commands/login.rb', line 45

def start(email, password)
  begin
    Session.(email, password)
  rescue Session::LoginError => e
    # login failed
    puts HighLine.color(I18n.t('commands.login.start.login_error'), HighLine::RED)
    raise e
  end

  ()
end

.start_loginvoid

This method returns an undefined value.

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/deploygate/commands/login.rb', line 26

def 
  puts ''
  email = ask(I18n.t('commands.login.start_login.email'))

  puts ''
  puts I18n.t('commands.login.start_login.check_account')
  if DeployGate::User.registered?('', email)
    puts ''
    password = input_password(I18n.t('commands.login.start_login.input_password'))
    puts ''
    start(email, password)
  else
    raise AccountNotFoundError, HighLine.color(I18n.t('errors.account_not_found_error'))
  end
end

.welcomeObject



19
20
21
22
# File 'lib/deploygate/commands/login.rb', line 19

def welcome
  puts I18n.t('commands.login.start_login.welcome')
  print_deploygate_aa()
end