Class: DeployGate::Commands::Config
- Inherits:
-
Object
- Object
- DeployGate::Commands::Config
- Defined in:
- lib/deploygate/commands/config.rb
Class Method Summary collapse
- .login(name, token, json_format) ⇒ void
- .print_json(data) ⇒ void
- .print_login_failed(json_format, data = {}) ⇒ void
- .print_login_success(login_user, json_format) ⇒ void
- .print_login_user(login_user, json_format, data = {}) ⇒ void
- .print_not_login(json_format, data = {}) ⇒ void
- .run(args, options) ⇒ Object
Class Method Details
.login(name, token, json_format) ⇒ void
This method returns an undefined value.
29 30 31 32 33 34 35 36 37 |
# File 'lib/deploygate/commands/config.rb', line 29 def login(name, token, json_format) if API::V1::Session.check(name, token) DeployGate::Session.save(name, token) login_user = DeployGate::Session.new().show_login_user print_login_success(login_user, json_format) else print_login_failed(json_format) end end |
.print_json(data) ⇒ void
This method returns an undefined value.
105 106 107 |
# File 'lib/deploygate/commands/config.rb', line 105 def print_json(data) puts data.to_json end |
.print_login_failed(json_format, data = {}) ⇒ void
This method returns an undefined value.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/deploygate/commands/config.rb', line 57 def print_login_failed(json_format, data = {}) = I18n.t('commands.config.print_login_failed.message') data[:error] = true data[:message] = if json_format print_json(data) else puts HighLine.color(, HighLine::RED) puts '' puts I18n.t('commands.config.print_login_failed.note') end end |
.print_login_success(login_user, json_format) ⇒ void
This method returns an undefined value.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/deploygate/commands/config.rb', line 42 def print_login_success(login_user, json_format) = 'Login success' data = {:message => , :error => false} unless json_format puts HighLine.color(, HighLine::GREEN) puts '' end print_login_user(login_user, json_format, data) end |
.print_login_user(login_user, json_format, data = {}) ⇒ void
This method returns an undefined value.
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/deploygate/commands/config.rb', line 92 def print_login_user(login_user, json_format, data = {}) data[:error] = data[:error].nil? ? false : data[:error] data[:name] = login_user['name'] if json_format print_json(data) else puts I18n.t('commands.config.print_login_user', name: data[:name]) end end |
.print_not_login(json_format, data = {}) ⇒ void
This method returns an undefined value.
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/deploygate/commands/config.rb', line 74 def print_not_login(json_format, data = {}) = I18n.t('commands.config.print_not_login.message') data[:error] = true data[:message] = if json_format print_json(data) else puts HighLine.color(, HighLine::YELLOW) puts '' puts I18n.t('commands.config.print_not_login.note') end end |
.run(args, options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/deploygate/commands/config.rb', line 8 def run(args, ) json_format = .json name = .name token = .token if name.nil? || token.nil? login_user = DeployGate::Session.new().show_login_user if login_user.nil? print_not_login(json_format) else print_login_user(login_user, json_format) end else login(name, token, json_format) end end |