mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-27 07:33:05 +00:00
fix bug update item
This commit is contained in:
parent
aa8207c459
commit
7d2abd65b8
2 changed files with 15 additions and 28 deletions
|
@ -145,7 +145,7 @@ class Cli
|
||||||
puts "ERROR: #{@m.error_msg}"
|
puts "ERROR: #{@m.error_msg}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Nothing item has been updated!"
|
puts "ERROR: #{@m.error_msg}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Nothing result!"
|
puts "Nothing result!"
|
||||||
|
|
41
lib/MPW.rb
41
lib/MPW.rb
|
@ -184,10 +184,6 @@ class MPW
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if group.nil? || group.empty?
|
|
||||||
group = 'No Group'
|
|
||||||
end
|
|
||||||
|
|
||||||
if port.to_i <= 0
|
if port.to_i <= 0
|
||||||
port = nil
|
port = nil
|
||||||
end
|
end
|
||||||
|
@ -202,12 +198,12 @@ class MPW
|
||||||
row[ID] = id
|
row[ID] = id
|
||||||
row[PORT] = port
|
row[PORT] = port
|
||||||
row[NAME] = name.force_encoding('ASCII-8BIT')
|
row[NAME] = name.force_encoding('ASCII-8BIT')
|
||||||
row[GROUP] = group.force_encoding('ASCII-8BIT')
|
group.nil? || group.empty? ? (row[GROUP] = nil) : (row[GROUP] = group.force_encoding('ASCII-8BIT'))
|
||||||
server.nil? ? (row[SERVER] = nil) : (row[SERVER] = server.force_encoding('ASCII-8BIT'))
|
server.nil? || server.empty? ? (row[SERVER] = nil) : (row[SERVER] = server.force_encoding('ASCII-8BIT'))
|
||||||
protocol.nil? ? (row[PROTOCOL] = nil) : (row[PROTOCOL] = protocol.force_encoding('ASCII-8BIT'))
|
protocol.nil? || protocol.empty? ? (row[PROTOCOL] = nil) : (row[PROTOCOL] = protocol.force_encoding('ASCII-8BIT'))
|
||||||
login.nil? ? (row[LOGIN] = nil) : (row[LOGIN] = login.force_encoding('ASCII-8BIT'))
|
login.nil? || login.empty? ? (row[LOGIN] = nil) : (row[LOGIN] = login.force_encoding('ASCII-8BIT'))
|
||||||
passwd.nil? ? (row[PASSWORD] = nil) : (row[PASSWORD] = passwd.force_encoding('ASCII-8BIT'))
|
passwd.nil? || passwd.empty? ? (row[PASSWORD] = nil) : (row[PASSWORD] = passwd.force_encoding('ASCII-8BIT'))
|
||||||
comment.nil? ? (row[COMMENT] = nil) : (row[COMMENT] = comment.force_encoding('ASCII-8BIT'))
|
comment.nil? || comment.empty? ? (row[COMMENT] = nil) : (row[COMMENT] = comment.force_encoding('ASCII-8BIT'))
|
||||||
|
|
||||||
@data[id] = row
|
@data[id] = row
|
||||||
|
|
||||||
|
@ -230,15 +226,6 @@ class MPW
|
||||||
|
|
||||||
if not @data[id].nil?
|
if not @data[id].nil?
|
||||||
|
|
||||||
if name.nil? || name.empty?
|
|
||||||
@error_msg = "You must define a name!"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
if group.nil? || group.empty?
|
|
||||||
group = 'No Group'
|
|
||||||
end
|
|
||||||
|
|
||||||
if port.to_i <= 0
|
if port.to_i <= 0
|
||||||
port = nil
|
port = nil
|
||||||
end
|
end
|
||||||
|
@ -246,14 +233,14 @@ class MPW
|
||||||
row = @data[id]
|
row = @data[id]
|
||||||
row_update = Array.new()
|
row_update = Array.new()
|
||||||
|
|
||||||
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.empty? ? (row_update[GROUP] = row[GROUP]) : (row_update[GROUP] = group)
|
group.nil? || group.empty? ? (row_update[GROUP] = row[GROUP]) : (row_update[GROUP] = group)
|
||||||
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.empty? ? (row_update[PROTOCOL] = row[PROTOCOL]) : (row_update[PROTOCOL] = protocol)
|
protocol.nil? || protocol.empty? ? (row_update[PROTOCOL] = row[PROTOCOL]) : (row_update[PROTOCOL] = protocol)
|
||||||
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.empty? ? (row_update[PASSWORD] = row[PASSWORD]) : (row_update[PASSWORD] = passwd)
|
passwd.nil? || passwd.empty? ? (row_update[PASSWORD] = row[PASSWORD]) : (row_update[PASSWORD] = passwd)
|
||||||
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.empty? ? (row_update[COMMENT] = row[COMMENT]) : (row_update[COMMENT] = comment)
|
comment.nil? || comment.empty? ? (row_update[COMMENT] = row[COMMENT]) : (row_update[COMMENT] = comment)
|
||||||
|
|
||||||
@data[id] = row_update
|
@data[id] = row_update
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue