Sha256: 636813c6ee04a1a70d351dc4ba3daf4905358e1954553c543c6e8de71bce0b9f

Contents?: true

Size: 492 Bytes

Versions: 7

Compression:

Stored size: 492 Bytes

Contents

module Riserva::Commands
  class UploadFile < ApplicationCommand
    def initialize(storage)
      super()
      @storage = storage
    end

    def call(path)
      return broadcast(:invalid) unless super

      success? ? broadcast(:ok, @path) : broadcast(:failed, @path)
    end

    private

    def success?
      upload && verify
    end

    def upload
      @storage.upload(@path, @path.basename)
    end

    def verify
      @storage.verify(@path.basename, @path)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
riserva-0.1.6 lib/riserva/commands/upload_file.rb
riserva-0.1.5 lib/riserva/commands/upload_file.rb
riserva-0.1.4 lib/riserva/commands/upload_file.rb
riserva-0.1.3 lib/riserva/commands/upload_file.rb
riserva-0.1.2 lib/riserva/commands/upload_file.rb
riserva-0.1.1 lib/riserva/commands/upload_file.rb
riserva-0.1.0 lib/riserva/commands/upload_file.rb