class Photish::Cache::DbFile
Attributes
file[R]
Public Class Methods
new(file)
click to toggle source
# File lib/photish/cache/db_file.rb, line 30 def initialize(file) @file = file end
new_master(output_dir)
click to toggle source
# File lib/photish/cache/db_file.rb, line 4 def self.new_master(output_dir) new(path(output_dir, '.changes.yml')) end
new_worker(output_dir, index)
click to toggle source
# File lib/photish/cache/db_file.rb, line 8 def self.new_worker(output_dir, index) new(path(output_dir, ".changes.#{index}.yml")) end
Private Class Methods
path(output_dir, filename)
click to toggle source
# File lib/photish/cache/db_file.rb, line 34 def self.path(output_dir, filename) FileUtils.mkdir_p(output_dir) File.join(output_dir, filename) end
Public Instance Methods
clear()
click to toggle source
# File lib/photish/cache/db_file.rb, line 22 def clear FileUtils.rm_rf(file) end
read()
click to toggle source
# File lib/photish/cache/db_file.rb, line 18 def read File.exist?(file) ? YAML.load_file(file) : {} end
write(hash)
click to toggle source
# File lib/photish/cache/db_file.rb, line 12 def write(hash) File.open(file, 'w') do |f| f.write(hash.to_yaml) end end