mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-27 07:33:05 +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
|
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
|
||||||
|
|
Loading…
Reference in a new issue