mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-23 13:57:52 +00:00
factorize the code
This commit is contained in:
parent
47ee15adb9
commit
7a50c4cf1c
3 changed files with 9 additions and 9 deletions
10
lib/Cli.rb
10
lib/Cli.rb
|
@ -79,10 +79,10 @@ class Cli
|
|||
end
|
||||
I18n.locale = language.to_sym
|
||||
|
||||
sync_host.empty? ? (sync_host = nil) : (sync_host = sync_host)
|
||||
sync_port.empty? ? (sync_port = nil) : (sync_port = sync_port.to_i)
|
||||
sync_pwd.empty? ? (sync_pwd = nil) : (sync_pwd = sync_pwd)
|
||||
sync_suffix.empty? ? (sync_suffix = nil) : (sync_suffix = sync_suffix)
|
||||
sync_host = sync_host.empty? ? nil : sync_host
|
||||
sync_port = sync_port.empty? ? nil : sync_port.to_i
|
||||
sync_pwd = sync_pwd.empty? ? nil : sync_pwd
|
||||
sync_suffix = sync_suffix.empty? ? nil : sync_suffix
|
||||
|
||||
if @config.setup(key, language, file_gpg, timeout_pwd, sync_host, sync_port, sync_pwd, sync_suffix)
|
||||
puts I18n.t('form.setup.valid')
|
||||
|
@ -146,7 +146,7 @@ class Cli
|
|||
# Display an item in the alternative format
|
||||
# @args: item -> an array with the item information
|
||||
def displayFormatAlt(item)
|
||||
item[MPW::PORT].nil? ? (port = '') : (port = ":#{item[MPW::PORT]}")
|
||||
port = item[MPW::PORT].nil? ? '' : ":#{item[MPW::PORT]}"
|
||||
|
||||
if item[MPW::PASSWORD].nil? || item[MPW::PASSWORD].empty?
|
||||
if item[MPW::LOGIN].include('@')
|
||||
|
|
|
@ -16,9 +16,9 @@ class CliSSH < Cli
|
|||
|
||||
if result.length > 0
|
||||
result.each do |r|
|
||||
@server.nil? ? (server = r[MPW::SERVER]) : (server = @server)
|
||||
@port.nil? ? (port = r[MPW::PORT]) : (port = @port)
|
||||
@login.nil? ? (login = r[MPW::LOGIN]) : (login = @login)
|
||||
server = @server.nil? ? r[MPW::SERVER] : @server
|
||||
port = @port.nil? ? r[MPW::PORT] : @port
|
||||
login = @login.nil? ? r[MPW::LOGIN] : @login
|
||||
|
||||
passwd = r[MPW::PASSWORD]
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class MPWConfig
|
|||
file_gpg = "#{Dir.home()}/.mpw.gpg"
|
||||
end
|
||||
|
||||
timeout_pwd.empty? ? (timeout_pwd = 60) : (timeout_pwd = timeout_pwd.to_i)
|
||||
timeout_pwd = timeout_pwd.empty? ? 60 : timeout_pwd.to_i
|
||||
|
||||
config = {'config' => {'key' => key,
|
||||
'lang' => lang,
|
||||
|
|
Loading…
Reference in a new issue