Sha256: 707e140eb96d1c06598bae7001ca31b4c775eae613aeb54c552b137d082cfd36

Contents?: true

Size: 953 Bytes

Versions: 3

Compression:

Stored size: 953 Bytes

Contents

require 'open-uri'
module Uricp::Strategy
  
  class PipedRemoteGet

    include Uricp::Strategy::Common

    def appropriate?
      case from.scheme
      when 'http', 'https'
        return proposal unless sequence_complete?
      else
	debug "#{self.class.name}: not appropriate"
	false
      end
    end

    alias :command :curl_download_to_pipe

    def proposal
      @proposed_options = options.dup
      @proposed_options['from_uri'] = PIPE_URI
      if options['target-format']
	@proposed_options['source-format'] = 
	  options['from_uri'].open(headers) { |u| encoding(u) }
	if @proposed_options['source-format'] == @proposed_options['target-format']
	  @proposed_options.delete('source-format')
	  @proposed_options.delete('target-format')
	end
      end
      self
    end

    def headers
      headers={'Range' => 'bytes=0-7'}
      headers['X-Auth-Token'] = options['auth-token'] if http_authentication?
      headers
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uricp-0.0.5 lib/uricp/strategy/piped_remote_get.rb
uricp-0.0.4 lib/uricp/strategy/piped_remote_get.rb
uricp-0.0.3 lib/uricp/strategy/piped_remote_get.rb