Sha256: 0f7e2a026f5f7499af96c71e8a0e0720c77be469fa24dae812c1f9f6a9aaa2e2

Contents?: true

Size: 999 Bytes

Versions: 1

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

module Uricp::CurlPrimitives
  attr_reader :options

  def from
    options['from_uri']
  end

  def from=(target)
    options['from_uri'] = target
  end

  def to
    options['to_uri']
  end

  def to=(target)
    options['to_uri'] = target
  end

  def curl_command
    'curl --fail --silent'
  end

  def authentication
    "-H 'X-Auth-Token:#{options['authenticator'].call}'" if http_authentication?
  end

  def http_authentication?
    options['authenticator']
  end

  def temp_url?
    from && from.query.to_s.include?('temp_url')
  end

  def curl_upload_from(source, destination = to)
    "#{curl_command} #{authentication} -T '#{source}' '#{destination}';"
  end

  def curl_download_to_pipe
    "#{curl_command} #{authentication unless temp_url?} '#{from}' |"
  end

  def curl_manifest(object_manifest, destination = to)
    "#{curl_command} #{authentication} -X PUT -H 'X-Object-Manifest: #{object_manifest}' '#{destination}' --data-binary ''"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uricp-0.0.31 lib/uricp/curl_primitives.rb