Sha256: cf99cfd8d7bfa9e8efd9dee05c04221017c1a05b0edadb81711a1d9e5fbb388d

Contents?: true

Size: 546 Bytes

Versions: 3

Compression:

Stored size: 546 Bytes

Contents

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

require 'command/cacheable/command'
require 'command/cacheable/cachefile'

module Command::Cacheable
  class CachingCommand < Command
    # caches its input and values.

    def initialize *args, debug: false, dir: nil
      @args = args.dup
      @dir = dir || '/tmp' + Pathname.new($0).expand_path.to_s
    end

    def cache_dir
      @dir
    end

    def cache_file
      CacheFile.new cache_dir, @args
    end

    def execute
      cachefile = cache_file
      @output = cachefile.read
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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