lib/imap/backup/configuration/account.rb in imap-backup-1.3.0 vs lib/imap/backup/configuration/account.rb in imap-backup-1.4.0
- old
+ new
@@ -31,25 +31,26 @@
menu.hidden("quit") { throw :done }
end
end
def header(menu)
- menu.header = <<-EOT
-Account:
- email: #{account[:username]}
- server: #{account[:server]}
- path: #{account[:local_path]}
- folders: #{folders.map { |f| f[:name] }.join(', ')}
- password: #{masked_password}
- EOT
+ menu.header = <<-HEADER.gsub(/^\s{8}/m, "")
+ Account:
+ email: #{account[:username]}
+ server: #{account[:server]}
+ path: #{account[:local_path]}
+ folders: #{folders.map { |f| f[:name] }.join(', ')}
+ password: #{masked_password}
+ HEADER
end
def modify_email(menu)
menu.choice("modify email") do
username = Configuration::Asker.email(username)
puts "username: #{username}"
- others = store.accounts.select { |a| a != account }.map { |a| a[:username] }
+ other_accounts = store.accounts.reject { |a| a == account }
+ others = other_accounts.map { |a| a[:username] }
puts "others: #{others.inspect}"
if others.include?(username)
puts "There is already an account set up with that email address"
else
account[:username] = username
@@ -81,22 +82,24 @@
end
end
def modify_backup_path(menu)
menu.choice("modify backup path") do
- validator = lambda do |p|
+ validator = ->(p) do
same = store.accounts.find do |a|
a[:username] != account[:username] && a[:local_path] == p
end
if same
- puts "The path '#{p}' is used to backup the account '#{same[:username]}'"
+ puts "The path '#{p}' is used to backup " \
+ "the account '#{same[:username]}'"
false
else
true
end
end
existing = account[:local_path].clone
- account[:local_path] = Configuration::Asker.backup_path(account[:local_path], validator)
+ account[:local_path] =
+ Configuration::Asker.backup_path(account[:local_path], validator)
account[:modified] = true if existing != account[:local_path]
end
end
def choose_folders(menu)