Class: BigKeeper::CacheOperator

Inherits:
Object
  • Object
show all
Defined in:
lib/big_keeper/util/cache_operator.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ CacheOperator

Returns a new instance of CacheOperator.



6
7
8
9
# File 'lib/big_keeper/util/cache_operator.rb', line 6

def initialize(path)
  @path = File.expand_path(path)
  @cache_path = File.expand_path("#{path}/.bigkeeper")
end

Instance Method Details

#cleanObject



21
22
23
# File 'lib/big_keeper/util/cache_operator.rb', line 21

def clean
  FileUtils.rm_r(@cache_path)
end

#load(file) ⇒ Object



17
18
19
# File 'lib/big_keeper/util/cache_operator.rb', line 17

def load(file)
  FileUtils.cp("#{@cache_path}/#{file}", "#{@path}/#{file}");
end

#save(file) ⇒ Object



11
12
13
14
15
# File 'lib/big_keeper/util/cache_operator.rb', line 11

def save(file)
  dest_path = File.dirname("#{@cache_path}/#{file}")
  FileUtils.mkdir_p(dest_path) unless File.exist?(dest_path)
  FileUtils.cp("#{@path}/#{file}", "#{@cache_path}/#{file}");
end