Class: Command::Cacheable::CachingCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/command/cacheable/caching.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args, debug: false, dir: nil) ⇒ CachingCommand

caches its input and values.



11
12
13
14
# File 'lib/command/cacheable/caching.rb', line 11

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

Instance Method Details

#cache_dirObject



16
17
18
# File 'lib/command/cacheable/caching.rb', line 16

def cache_dir
  @dir
end

#cache_fileObject



20
21
22
# File 'lib/command/cacheable/caching.rb', line 20

def cache_file
  CacheFile.new cache_dir, @args
end

#executeObject



24
25
26
27
# File 'lib/command/cacheable/caching.rb', line 24

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