Sha256: d69c8c728034d0dea91c4717659372aa8b963e117e463eee5310ae477a6f22d4

Contents?: true

Size: 940 Bytes

Versions: 20

Compression:

Stored size: 940 Bytes

Contents

module Imap; end

module Imap::Backup
  class Setup; end

  class Setup::BackupPath
    attr_reader :account
    attr_reader :config

    def initialize(account:, config:)
      @account = account
      @config = config
    end

    def run
      account.local_path = highline.ask("backup directory: ") do |q|
        q.default  = account.local_path
        q.readline = true
        q.validate = ->(path) { path_modification_validator(path) }
        q.responses[:not_valid] = "Choose a different directory "
      end
    end

    private

    def highline
      Setup.highline
    end

    def path_modification_validator(path)
      same = config.accounts.find do |a|
        a.username != account.username && a.local_path == path
      end
      if same
        Kernel.puts "The path '#{path}' is used to backup " \
                    "the account '#{same.username}'"
        false
      else
        true
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
imap-backup-14.4.1 lib/imap/backup/setup/backup_path.rb
imap-backup-14.4.0 lib/imap/backup/setup/backup_path.rb
imap-backup-14.3.0 lib/imap/backup/setup/backup_path.rb
imap-backup-14.2.0 lib/imap/backup/setup/backup_path.rb
imap-backup-14.1.1 lib/imap/backup/setup/backup_path.rb
imap-backup-14.1.0 lib/imap/backup/setup/backup_path.rb
imap-backup-14.0.0 lib/imap/backup/setup/backup_path.rb
imap-backup-13.4.0 lib/imap/backup/setup/backup_path.rb
imap-backup-13.3.0 lib/imap/backup/setup/backup_path.rb
imap-backup-13.2.0 lib/imap/backup/setup/backup_path.rb
imap-backup-13.1.0 lib/imap/backup/setup/backup_path.rb
imap-backup-13.0.0 lib/imap/backup/setup/backup_path.rb
imap-backup-12.1.0 lib/imap/backup/setup/backup_path.rb
imap-backup-12.0.0 lib/imap/backup/setup/backup_path.rb
imap-backup-11.1.0 lib/imap/backup/setup/backup_path.rb
imap-backup-11.1.0.rc1 lib/imap/backup/setup/backup_path.rb
imap-backup-11.0.1 lib/imap/backup/setup/backup_path.rb
imap-backup-11.0.0 lib/imap/backup/setup/backup_path.rb
imap-backup-11.0.0.rc1 lib/imap/backup/setup/backup_path.rb
imap-backup-10.0.1 lib/imap/backup/setup/backup_path.rb