Sha256: 8a7b0245c69be08f5abbd4d488e3563f1db02783b66e0d1fa1cc8efedce1139e

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require_relative 'performers/base_git'
require_relative 'backup_github'
require_relative 'backup_bitbucket'

module BackupRepos
  class Backup
    attr_reader :errors

    def initialize
      @errors = []

      validate!
    end

    def process
      return unless valid?

      BackupGithub.process
      BackupBitbucket.process
    end

    def valid?
      errors.blank?
    end

    private

    def validate!
      validate_backup_dir!
      inform_about_error! unless valid?
    end

    def validate_backup_dir!
      backup_root = BackupRepos.config.backup_root

      if backup_root.blank?
        errors.push('Backup directory is not specified.') && return
      end

      unless File.exist?(backup_root)
        errors << 'Backup directory is not exists.'
      end
    end

    def inform_about_error!
      puts errors.first.red
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backup_repos-0.1.0 lib/backup_repos/backup.rb