Sha256: abf407bba14b415245f262f8c499e1370ae604d93fac60856ae0db2a299c6364

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

require_relative 'action'

module Arli
  module Actions
    class Backup < Action

      def act(**options)
        return false unless exists?

        if backup_action.abort
          raise Arli::Errors::LibraryAlreadyExists, path
        elsif backup_action.backup
          FileUtils.mv(path, backup_library_path)
        elsif backup_action.overwrite
          library.rm_rf!
        end
      end

      def backup_action
        config.install.if_exists
      end

      private

      def backup_library_path
        path + ".#{Time.now.strftime('%Y%m%d%H%M%S')}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arli-0.6.1 lib/arli/actions/backup.rb