Sha256: a92a51a2488fd5abd2291084376a6073e2e2f50ee4470f449b218a18644d52b8
Contents?: true
Size: 907 Bytes
Versions: 2
Compression:
Stored size: 907 Bytes
Contents
module TomatoHarvest class ListLoader FILENAME = 'list.yaml' class << self def from_file local_path = list_path(TomatoHarvest::Config::LOCAL_DIR) if File.exists? local_path List.init_and_load(local_path) else load_old_list || List.init_and_load(global_path) end end def load_old_list old_path = File.join(TomatoHarvest::Config::HOME_DIR, '.toma') if exists_as_file(old_path) old_list = List.init_and_load(old_path) File.delete old_path List.new(global_path, old_list.items).save! end end def exists_as_file(path) File.exists?(path) && !File.directory?(path) end def global_path list_path(TomatoHarvest::Config::GLOBAL_DIR) end def list_path(dir) File.join(dir, FILENAME) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tomatoharvest-0.1.1 | lib/tomatoharvest/list_loader.rb |
tomatoharvest-0.1.0 | lib/tomatoharvest/list_loader.rb |