Sha256: 57641ed910cefc432fd66b72b17ba3c879141e91ac963d6f837340578a6e08f2
Contents?: true
Size: 1009 Bytes
Versions: 3
Compression:
Stored size: 1009 Bytes
Contents
module Riserva::Commands class Backup < ApplicationCommand attr_reader :uploaders def initialize super @uploaders = {} end def call create_archives push_to_cloud success? ? broadcast(:ok) : broadcast(:failed) end private def success? @uploaders.values.map { |uploader| uploader.files == archivator.files }.all? end def create_archives Riserva::Config.folders { |folder| archivator.call(folder) } end def archivator @archivator ||= Riserva::Commands::CreateArchive.new end def push_to_cloud Riserva::Config.storages do |storage| archivator.files.each { |file| upload_file(storage, file) } end end def upload_file(storage, file) Riserva.logger.info("Uploading file #{file} to #{storage.title}...") uploader(storage).call(file) end def uploader(storage) @uploaders[storage.title] ||= Riserva::Commands::UploadFile.new(storage) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
riserva-0.1.4 | lib/riserva/commands/backup.rb |
riserva-0.1.3 | lib/riserva/commands/backup.rb |
riserva-0.1.2 | lib/riserva/commands/backup.rb |