1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-10-27 10:43:20 +00:00

fix import

This commit is contained in:
nishiki 2015-01-29 22:09:42 +01:00
parent 7f7d8c862d
commit 25a8455658

View file

@ -191,16 +191,36 @@ module MPW
case type
when :csv
CSV.foreach(file, {headers: true}) do |row|
if not update(row['name'], row['group'], row['host'], row['protocol'], row['login'], row['password'], row['port'], row['comment'])
return false
end
item = Item.new(name: row['name'],
group: row['group'],
host: row['host'],
protocol: row['protocol'],
login: row['login'],
password: row['password'],
port: row['port'],
comment: row['comment'],
)
return false if item.empty?
@data.push(item)
end
when :yaml
YAML::load_file(file).each_value do |row|
if not update(row['name'], row['group'], row['host'], row['protocol'], row['login'], row['password'], row['port'], row['comment'])
return false
end
item = Item.new(name: row['name'],
group: row['group'],
host: row['host'],
protocol: row['protocol'],
login: row['login'],
password: row['password'],
port: row['port'],
comment: row['comment'],
)
return false if item.empty?
@data.push(item)
end
else