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:
parent
7f7d8c862d
commit
25a8455658
1 changed files with 26 additions and 6 deletions
32
lib/MPW.rb
32
lib/MPW.rb
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue