Sha256: 60eb8882ef1b338bbc0e59a07d9b02d459d7f871ec13540b723c5aad76d51bad

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

require 'fileutils'

module Uricp::Strategy
  class PipedCacheConvert
    include Uricp::Strategy::Common
    include Uricp::Strategy::CacheCommon

    def appropriate?
      if conversion_required? && supported_source?
        case from.scheme
        when 'pipe'
          validate_cache! if cache_root
          return proposal
        end
        debug "#{self.class.name}: not appropriate"
      else
        debug "#{self.class.name}: no non-stream conversion detected"
      end
      false
    end

    def command
      "cp --sparse=always /dev/stdin #{proposed_path};"
    end

    def proposal
      @proposed_options = options.dup
      if cache_root
        @proposed_options['from_uri'] = temp_cache_uri
        @proposed_options['sweep'] = [temp_cache_file, cache_file]
        @proposed_options.delete('cache')
        @proposed_options.delete('cache_name')
      else
        @proposed_options['from_uri'] = temp_uri
        @proposed_options['clean'] ||= []
        @proposed_options['clean'] << proposed_path
      end
      self
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
uricp-0.0.24 lib/uricp/strategy/piped_cache_convert.rb
uricp-0.0.23 lib/uricp/strategy/piped_cache_convert.rb
uricp-0.0.22 lib/uricp/strategy/piped_cache_convert.rb
uricp-0.0.21 lib/uricp/strategy/piped_cache_convert.rb
uricp-0.0.20 lib/uricp/strategy/piped_cache_convert.rb
uricp-0.0.18 lib/uricp/strategy/piped_cache_convert.rb
uricp-0.0.17 lib/uricp/strategy/piped_cache_convert.rb
uricp-0.0.16 lib/uricp/strategy/piped_cache_convert.rb