diff --git a/lib/mpw/item.rb b/lib/mpw/item.rb index 2e2459b..4beb49f 100644 --- a/lib/mpw/item.rb +++ b/lib/mpw/item.rb @@ -27,6 +27,7 @@ class Item attr_accessor :protocol attr_accessor :user attr_accessor :port + attr_accessor :otp attr_accessor :comment attr_accessor :last_edit attr_accessor :last_sync @@ -66,6 +67,7 @@ class Item @protocol = options[:protocol] if options.has_key?(:protocol) @user = options[:user] if options.has_key?(:user) @port = options[:port].to_i if options.has_key?(:port) and not options[:port].to_s.empty? + @otp = options[:otp] if options.has_key?(:otp) @comment = options[:comment] if options.has_key?(:comment) @last_edit = Time.now.to_i if not options.has_key?(:no_update_last_edit) end @@ -83,6 +85,7 @@ class Item @protocol = nil @user = nil @port = nil + @otp = nil @comment = nil @created = nil @last_edit = nil diff --git a/lib/mpw/mpw.rb b/lib/mpw/mpw.rb index 872c1aa..1572923 100644 --- a/lib/mpw/mpw.rb +++ b/lib/mpw/mpw.rb @@ -88,6 +88,7 @@ class MPW protocol: d['protocol'], user: d['user'], port: d['port'], + otp: @otp_keys.has_key?(d['id']), comment: d['comment'], last_edit: d['last_edit'], created: d['created'], @@ -277,19 +278,23 @@ class MPW # @args: file -> file where you export the data def export(file) data = {} + i = 1 + @data.each do |item| - data.merge!("#{item.login}@#{item.host}" => {'group' => item.group, - 'host' => item.host, - 'protocol' => item.protocol, - 'user' => item.user, - 'password' => get_password(item.id), - 'port' => item.port, - 'comment' => item.comment, - 'otp_key' => get_otp_code(item.id), - 'last_edit' => item.last_edit, - 'created' => item.created, - } + data.merge!(i => { 'group' => item.group, + 'host' => item.host, + 'protocol' => item.protocol, + 'user' => item.user, + 'password' => get_password(item.id), + 'port' => item.port, + 'comment' => item.comment, + 'otp_key' => get_otp_code(item.id), + 'last_edit' => item.last_edit, + 'created' => item.created, + } ) + + i += 1 end File.open(file, 'w') {|f| f << data.to_yaml}