Sha256: 46ccf3536860ef7d5bbb3fb6215739201ad8d29d890d92ce7021929f93690421

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

module Uricp::Strategy
  
  class SegmentedRemotePut

    include Uricp::Strategy::Common

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

    def command
      "segment_upload --segment-size '#{options['segment-size']}' #{source_details} #{to.to_s};"
    end

    def proposal
      @proposed_options = options.dup
      @proposed_options['from_uri'] = to
      @proposed_options['segment-size'] = nil
      self
    end

    def source_details
      "--from #{from.path}" unless from.scheme == 'pipe'
    end

    def segmented?
      options['segment-size']
    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
uricp-0.0.15 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.14 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.13 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.12 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.11 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.10 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.9 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.8 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.7 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.6 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.5 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.4 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.3 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.2 lib/uricp/strategy/segmented_remote_put.rb
uricp-0.0.1 lib/uricp/strategy/segmented_remote_put.rb