Class: BigKeeper::CacheOperator
- Inherits:
-
Object
- Object
- BigKeeper::CacheOperator
- Defined in:
- lib/big_keeper/util/cache_operator.rb
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(path) ⇒ CacheOperator
constructor
A new instance of CacheOperator.
- #load(file) ⇒ Object
- #save(file) ⇒ Object
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.(path) @cache_path = File.("#{path}/.bigkeeper") end |
Instance Method Details
#clean ⇒ Object
21 22 23 24 25 |
# File 'lib/big_keeper/util/cache_operator.rb', line 21 def clean if File.exist?(@cache_path) FileUtils.rm_r(@cache_path) end 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 |