1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-20 01:50:04 +00:00

rename function

This commit is contained in:
nishiki 2014-01-27 20:19:38 +01:00
parent e026beafa7
commit 76c5ab07c7
4 changed files with 13 additions and 14 deletions

View file

@ -54,7 +54,7 @@ class Cli
end end
end end
rescue Exception => e rescue Exception => e
puts "#{I18n.t('display.error')}: #{I18n.t('sync.error')}\n#{e}" puts "#{I18n.t('display.error')}: #{e}"
end end
return false return false

View file

@ -147,15 +147,15 @@ class MPW
row_update = Array.new() row_update = Array.new()
row_update[DATE] = Time.now.to_i row_update[DATE] = Time.now.to_i
id.nil? || id.empty? ? (row_update[ID] = MPW.generatePassword(16)) : (row_update[ID] = id) id.nil? || id.empty? ? (row_update[ID] = MPW.password(16)) : (row_update[ID] = id)
name.nil? || name.empty? ? (row_update[NAME] = row[NAME]) : (row_update[NAME] = name) name.nil? || name.empty? ? (row_update[NAME] = row[NAME]) : (row_update[NAME] = name)
group.nil? || group.empty? ? (row_update[GROUP] = row[GROUP]) : (row_update[GROUP] = group) group.nil? || group.empty? ? (row_update[GROUP] = row[GROUP]) : (row_update[GROUP] = group)
server.nil? || server.empty? ? (row_update[SERVER] = row[SERVER]) : (row_update[SERVER] = server) server.nil? || server.empty? ? (row_update[SERVER] = row[SERVER]) : (row_update[SERVER] = server)
protocol.nil? || protocol.empty? ? (row_update[PROTOCOL] = row[PROTOCOL]) : (row_update[PROTOCOL] = protocol) protocol.nil? || protocol.empty? ? (row_update[PROTOCOL] = row[PROTOCOL]) : (row_update[PROTOCOL] = protocol)
login.nil? || login.empty? ? (row_update[LOGIN] = row[LOGIN]) : (row_update[LOGIN] = login) login.nil? || login.empty? ? (row_update[LOGIN] = row[LOGIN]) : (row_update[LOGIN] = login)
passwd.nil? || passwd.empty? ? (row_update[PASSWORD] = row[PASSWORD]) : (row_update[PASSWORD] = passwd) passwd.nil? || passwd.empty? ? (row_update[PASSWORD] = row[PASSWORD]) : (row_update[PASSWORD] = passwd)
port.nil? || port.empty? ? (row_update[PORT] = row[PORT]) : (row_update[PORT] = port) port.nil? || port.empty? ? (row_update[PORT] = row[PORT]) : (row_update[PORT] = port)
comment.nil? || comment.empty? ? (row_update[COMMENT] = row[COMMENT]) : (row_update[COMMENT] = comment) comment.nil? || comment.empty? ? (row_update[COMMENT] = row[COMMENT]) : (row_update[COMMENT] = comment)
row_update[NAME].nil? ? (row_update[NAME] = row_update[NAME]) : (row_update[NAME] = row_update[NAME].force_encoding('ASCII-8BIT')) row_update[NAME].nil? ? (row_update[NAME] = row_update[NAME]) : (row_update[NAME] = row_update[NAME].force_encoding('ASCII-8BIT'))
row_update[GROUP].nil? ? (row_update[GROUP] = row_update[GROUP]) : (row_update[GROUP] = row_update[GROUP].force_encoding('ASCII-8BIT')) row_update[GROUP].nil? ? (row_update[GROUP] = row_update[GROUP]) : (row_update[GROUP] = row_update[GROUP].force_encoding('ASCII-8BIT'))
@ -312,7 +312,7 @@ class MPW
# Generate a random password # Generate a random password
# @args: length -> the length password # @args: length -> the length password
# @rtrn: a random string # @rtrn: a random string
def self.generatePassword(length=8) def self.password(length=8)
if length.to_i <= 0 if length.to_i <= 0
length = 8 length = 8
else else
@ -328,5 +328,4 @@ class MPW
return result return result
end end
end end

View file

@ -64,7 +64,7 @@ class Sync
@error_msg = I18n.t('error.sync.communication') @error_msg = I18n.t('error.sync.communication')
return nil return nil
elsif msg['error'].nil? elsif msg['error'].nil?
tmp_file = "/tmp/mpw-#{MPW.generatePassword()}.gpg" tmp_file = "/tmp/mpw-#{MPW.password()}.gpg"
File.open(tmp_file, 'w') do |file| File.open(tmp_file, 'w') do |file|
file << msg['data'] file << msg['data']
end end

2
mpw
View file

@ -83,7 +83,7 @@ OptionParser.new do |opts|
end end
opts.on('-G', '--generate-password [LENGTH]', I18n.t('option.generate_password')) do |length| opts.on('-G', '--generate-password [LENGTH]', I18n.t('option.generate_password')) do |length|
puts MPW::generatePassword(length) puts MPW::password(length)
exit 0 exit 0
end end