1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 13:57:52 +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 case type
when :csv when :csv
CSV.foreach(file, {headers: true}) do |row| 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']) item = Item.new(name: row['name'],
return false group: row['group'],
end 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 end
when :yaml when :yaml
YAML::load_file(file).each_value do |row| 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']) item = Item.new(name: row['name'],
return false group: row['group'],
end 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 end
else else