Module: Uricp::CurlPrimitives
- Included in:
- Segmenter, Strategy::Common
- Defined in:
- lib/uricp/curl_primitives.rb
Constant Summary collapse
- ORBIT_HOSTS =
%w[orbit.brightbox.com orbit.gb1s.brightbox.com]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #authentication ⇒ Object
- #curl_command ⇒ Object
- #curl_download_to_pipe ⇒ Object
- #curl_manifest(object_manifest, destination = to) ⇒ Object
- #curl_upload_from(source, destination = to) ⇒ Object
- #from ⇒ Object
- #from=(target) ⇒ Object
- #http_authentication? ⇒ Boolean
- #orbit?(source) ⇒ Boolean
- #temp_url? ⇒ Boolean
- #to ⇒ Object
- #to=(target) ⇒ Object
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/uricp/curl_primitives.rb', line 5 def @options end |
Instance Method Details
#authentication ⇒ Object
27 28 29 |
# File 'lib/uricp/curl_primitives.rb', line 27 def authentication "-H 'X-Auth-Token:#{['authenticator'].call}'" if http_authentication? end |
#curl_command ⇒ Object
23 24 25 |
# File 'lib/uricp/curl_primitives.rb', line 23 def curl_command 'curl --fail --silent --location ' end |
#curl_download_to_pipe ⇒ Object
48 49 50 |
# File 'lib/uricp/curl_primitives.rb', line 48 def curl_download_to_pipe "#{curl_command} #{authentication if orbit?(from) && !temp_url?} '#{from}' |" end |
#curl_manifest(object_manifest, destination = to) ⇒ Object
52 53 54 |
# File 'lib/uricp/curl_primitives.rb', line 52 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 |
#curl_upload_from(source, destination = to) ⇒ Object
44 45 46 |
# File 'lib/uricp/curl_primitives.rb', line 44 def curl_upload_from(source, destination = to) "#{curl_command} #{authentication} -H 'Content-Type: application/octet-stream' -T '#{source}' '#{destination}';" end |
#from ⇒ Object
7 8 9 |
# File 'lib/uricp/curl_primitives.rb', line 7 def from ['from_uri'] end |
#from=(target) ⇒ Object
11 12 13 |
# File 'lib/uricp/curl_primitives.rb', line 11 def from=(target) ['from_uri'] = target end |
#http_authentication? ⇒ Boolean
31 32 33 |
# File 'lib/uricp/curl_primitives.rb', line 31 def http_authentication? ['authenticator'] end |
#orbit?(source) ⇒ Boolean
35 36 37 38 |
# File 'lib/uricp/curl_primitives.rb', line 35 def orbit?(source) return unless source.respond_to?(:host) ORBIT_HOSTS.include?(source.host) end |
#temp_url? ⇒ Boolean
40 41 42 |
# File 'lib/uricp/curl_primitives.rb', line 40 def temp_url? from && from.query.to_s.include?('temp_url') end |
#to ⇒ Object
15 16 17 |
# File 'lib/uricp/curl_primitives.rb', line 15 def to ['to_uri'] end |
#to=(target) ⇒ Object
19 20 21 |
# File 'lib/uricp/curl_primitives.rb', line 19 def to=(target) ['to_uri'] = target end |