Sha256: 06eb874cc5504fade23c879039ad08f968818fc809dc15d606ea40d9130390a3

Contents?: true

Size: 965 Bytes

Versions: 3

Compression:

Stored size: 965 Bytes

Contents

module Uricp::Strategy

  class PipedLocalDecompress
    
    include Uricp::Strategy::Common

    def appropriate?
      case from.scheme
      when 'pipe'
	if raw_target? && lz4_source? && to.scheme == 'file'
	  if always_write_sparse?
	    return proposal
	  else
	    debug "#{self.class.name}: using safe sparse expansion via stream"
	  end
	end
      end
      debug "#{self.class.name}: not appropriate"
      false
    end

    def command
      "lz4 -qdf - #{to.path};"
    end

    def proposal
      @proposed_options = options.dup
      @proposed_options.delete('source-format')
      if @proposed_options['target-format']
	@proposed_options['source-format'] = :raw
        if @proposed_options['source-format'] == @proposed_options['target-format'] 
	  @proposed_options.delete('source-format')
	  @proposed_options.delete('target-format')
	end
      end
      @proposed_options['from_uri'] = @proposed_options['to_uri']
      self
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uricp-0.0.15 lib/uricp/strategy/piped_local_decompress.rb
uricp-0.0.14 lib/uricp/strategy/piped_local_decompress.rb
uricp-0.0.13 lib/uricp/strategy/piped_local_decompress.rb