1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-27 07:33:05 +00:00

factorize the code

This commit is contained in:
nishiki 2014-01-29 19:18:36 +01:00
parent 47ee15adb9
commit 7a50c4cf1c
3 changed files with 9 additions and 9 deletions

View file

@ -79,10 +79,10 @@ class Cli
end end
I18n.locale = language.to_sym I18n.locale = language.to_sym
sync_host.empty? ? (sync_host = nil) : (sync_host = sync_host) sync_host = sync_host.empty? ? nil : sync_host
sync_port.empty? ? (sync_port = nil) : (sync_port = sync_port.to_i) sync_port = sync_port.empty? ? nil : sync_port.to_i
sync_pwd.empty? ? (sync_pwd = nil) : (sync_pwd = sync_pwd) sync_pwd = sync_pwd.empty? ? nil : sync_pwd
sync_suffix.empty? ? (sync_suffix = nil) : (sync_suffix = sync_suffix) 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) if @config.setup(key, language, file_gpg, timeout_pwd, sync_host, sync_port, sync_pwd, sync_suffix)
puts I18n.t('form.setup.valid') puts I18n.t('form.setup.valid')
@ -146,7 +146,7 @@ class Cli
# Display an item in the alternative format # Display an item in the alternative format
# @args: item -> an array with the item information # @args: item -> an array with the item information
def displayFormatAlt(item) 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::PASSWORD].nil? || item[MPW::PASSWORD].empty?
if item[MPW::LOGIN].include('@') if item[MPW::LOGIN].include('@')

View file

@ -16,9 +16,9 @@ class CliSSH < Cli
if result.length > 0 if result.length > 0
result.each do |r| result.each do |r|
@server.nil? ? (server = r[MPW::SERVER]) : (server = @server) server = @server.nil? ? r[MPW::SERVER] : @server
@port.nil? ? (port = r[MPW::PORT]) : (port = @port) port = @port.nil? ? r[MPW::PORT] : @port
@login.nil? ? (login = r[MPW::LOGIN]) : (login = @login) login = @login.nil? ? r[MPW::LOGIN] : @login
passwd = r[MPW::PASSWORD] passwd = r[MPW::PASSWORD]

View file

@ -54,7 +54,7 @@ class MPWConfig
file_gpg = "#{Dir.home()}/.mpw.gpg" file_gpg = "#{Dir.home()}/.mpw.gpg"
end 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, config = {'config' => {'key' => key,
'lang' => lang, 'lang' => lang,