Sha256: dda1147b46320ce4558da774529a2db756aeb9e27ec29e2b8bb266f646afac66
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Uricp::CurlPrimitives ORBIT_HOSTS = %w[orbit.brightbox.com orbit.gb1s.brightbox.com] 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 --location ' end def authentication "-H 'X-Auth-Token:#{options['authenticator'].call}'" if http_authentication? end def http_authentication? options['authenticator'] end def orbit?(source) return unless source.respond_to?(:host) ORBIT_HOSTS.include?(source.host) end def temp_url? from && from.query.to_s.include?('temp_url') end def curl_upload_from(source, destination = to) "#{curl_command} #{authentication} -H 'Content-Type: application/octet-stream' -T '#{source}' '#{destination}';" end def curl_download_to_pipe "#{curl_command} #{authentication if orbit?(from) && !temp_url?} '#{from}' |" end def curl_manifest(object_manifest, destination = to) "#{curl_command} #{authentication} -X PUT -H 'Content-Type: application/octet-stream' -H 'X-Object-Manifest: #{object_manifest}' '#{destination}' --data-binary ''" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uricp-0.0.37 | lib/uricp/curl_primitives.rb |
uricp-0.0.36 | lib/uricp/curl_primitives.rb |