Sha256: bc96f1591eb040e79234d56e6511538f597d77ff578d1550da392615d815bb89

Contents?: true

Size: 845 Bytes

Versions: 12

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

module Uricp::Strategy
  class RemotePut
    include Uricp::Strategy::Common

    def appropriate?
      if compression_required? || conversion_required?
        debug "#{self.class.name}: not ready to upload"
        return false
      end
      case to.scheme
      when 'http', 'https'
        case from.scheme
        when 'file', 'pipe'
          return proposal if http_authentication?

          unsupported_transfer
        end
      end
      debug "#{self.class.name}: not appropriate"
      false
    end

    def command
      curl_upload_from(curl_source)
    end

    def proposal
      @proposed_options = options.dup
      @proposed_options['from_uri'] = to
      self
    end

    def curl_source
      if from.scheme == 'pipe'
        '-'
      else
        from.path
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
uricp-0.0.37 lib/uricp/strategy/remote_put.rb
uricp-0.0.36 lib/uricp/strategy/remote_put.rb
uricp-0.0.35 lib/uricp/strategy/remote_put.rb
uricp-0.0.34 lib/uricp/strategy/remote_put.rb
uricp-0.0.32 lib/uricp/strategy/remote_put.rb
uricp-0.0.31 lib/uricp/strategy/remote_put.rb
uricp-0.0.30 lib/uricp/strategy/remote_put.rb
uricp-0.0.29 lib/uricp/strategy/remote_put.rb
uricp-0.0.28 lib/uricp/strategy/remote_put.rb
uricp-0.0.27 lib/uricp/strategy/remote_put.rb
uricp-0.0.26 lib/uricp/strategy/remote_put.rb
uricp-0.0.25 lib/uricp/strategy/remote_put.rb