Class: DeployGate::Commands::Login
- Inherits:
-
Object
- Object
- DeployGate::Commands::Login
- Defined in:
- lib/deploygate/commands/login.rb
Class Method Summary collapse
- .create_account(email) ⇒ void
- .input_new_account_name ⇒ String
- .input_new_account_password ⇒ String
- .input_password(message) ⇒ String
- .login_success ⇒ Object
- .print_deploygate_aa ⇒ Object
- .run(args, options) ⇒ void
- .start(email, password) ⇒ void
- .start_login_or_create_account ⇒ void
- .welcome ⇒ Object
Class Method Details
.create_account(email) ⇒ void
This method returns an undefined value.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/deploygate/commands/login.rb', line 61 def create_account(email) puts I18n.t('commands.login.create_account.prompt') puts '' name = input_new_account_name() puts '' password = input_new_account_password() puts '' print I18n.t('commands.login.create_account.creating') if DeployGate::User.create(name, email, password).nil? puts HighLine.color(I18n.t('commands.login.create_account.error'), HighLine::RED) raise 'User create error' else puts HighLine.color(I18n.t('commands.login.create_account.success'), HighLine::GREEN) start(email, password) end end |
.input_new_account_name ⇒ String
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/deploygate/commands/login.rb', line 82 def input_new_account_name user_name = ask(I18n.t('commands.login.input_new_account_name.input_user_name')) print I18n.t('commands.login.input_new_account_name.checking') if DeployGate::User.registered?(user_name, '') puts HighLine.color(I18n.t('commands.login.input_new_account_name.already_used_user_name', user_name: user_name), HighLine::RED) return input_new_account_name() else puts HighLine.color(I18n.t('commands.login.input_new_account_name.success', user_name: user_name), HighLine::GREEN) return user_name end end |
.input_new_account_password ⇒ String
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/deploygate/commands/login.rb', line 96 def input_new_account_password password = input_password(I18n.t('commands.login.input_new_account_password.input_password')) secound_password = input_password(I18n.t('commands.login.input_new_account_password.input_same_password')) if password == secound_password return password else puts HighLine.color(I18n.t('commands.login.input_new_account_password.error'), HighLine::RED) return input_new_account_password() end end |
.input_password(message) ⇒ String
109 110 111 |
# File 'lib/deploygate/commands/login.rb', line 109 def input_password() ask() { |q| q.echo = "*" } end |
.login_success ⇒ Object
54 55 56 57 |
# File 'lib/deploygate/commands/login.rb', line 54 def login_success session = Session.new puts HighLine.color(I18n.t('commands.login.start.success', name: session.name), HighLine::GREEN) end |
.print_deploygate_aa ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/deploygate/commands/login.rb', line 113 def print_deploygate_aa puts <<'EOF' _ _ _ | | | | | | __| | ___ ___ | | ___ _ ,____ ___ | |_ ___ / _` |/ _ \' _ \| |/ _ \ \ / / _ \ / _ `| __/ _ \ | (_| | __/ |_) | | (_) \ v / (_| | (_| | |_' __/ \___, \___| .__/|_|\___/ ` / \__, |\__,_|\__\___` |_| /_/ |___/ EOF end |
.run(args, options) ⇒ void
This method returns an undefined value.
7 8 9 10 11 12 13 14 15 |
# File 'lib/deploygate/commands/login.rb', line 7 def run(args, ) welcome() if .terminal start_login_or_create_account() else DeployGate::BrowserLogin.new().start() end end |
.start(email, password) ⇒ void
This method returns an undefined value.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/deploygate/commands/login.rb', line 42 def start(email, password) begin Session.login(email, password) rescue Session::LoginError => e # login failed puts HighLine.color(I18n.t('commands.login.start.login_error'), HighLine::RED) raise e end login_success() end |
.start_login_or_create_account ⇒ void
This method returns an undefined value.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/deploygate/commands/login.rb', line 23 def start_login_or_create_account puts '' email = ask(I18n.t('commands.login.start_login_or_create_account.email')) puts '' puts I18n.t('commands.login.start_login_or_create_account.check_account') if DeployGate::User.registered?('', email) puts '' password = input_password(I18n.t('commands.login.start_login_or_create_account.input_password')) puts '' start(email, password) else create_account(email) end end |
.welcome ⇒ Object
17 18 19 20 |
# File 'lib/deploygate/commands/login.rb', line 17 def welcome puts I18n.t('commands.login.start_login_or_create_account.welcome') print_deploygate_aa() end |