Sha256: feb37e7de59110e89d118562a0f304b868395f9e22b353a126bbee27a593a37c

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

#!/usr/bin/ruby -w
# -*- ruby -*-

# require 'command/cacheable/command'
require 'command/cacheable/filename'
require 'command/cacheable/gzpathname'

module Command::Cacheable
  # A file that has a pathname and output
  #$$$ todo: cache error
  class CacheFile
    attr_reader :output
    attr_reader :pathname
    
    def initialize cache_dir, args
      @args     = args
      basename  = FileName.new(args).name
      fullname  = Pathname(cache_dir) + basename
      @pathname = GzipPathname.new fullname
      @output   = nil
    end
    
    def read
      @output = @pathname.exist? && @pathname.read_file
    end

    def save output
      @pathname.save_file output
    end

    def to_s
      @pathname.to_s
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
command-cacheable-0.2.1 lib/command/cacheable/cachefile.rb
command-cacheable-0.2.0 lib/command/cacheable/cachefile.rb
command-cacheable-0.1.0 lib/command/cacheable/cachefile.rb