Class: Renuo::Cli::Services::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/renuo/cli/services/cache.rb

Constant Summary collapse

CACHE_DIR =
"#{Dir.home}/.renuo-cli/cache".freeze

Class Method Summary collapse

Class Method Details

.restore(file_name) ⇒ Object



13
14
15
16
17
18
# File 'lib/renuo/cli/services/cache.rb', line 13

def restore(file_name)
  file_path = File.join(CACHE_DIR, "#{file_name}.yml")
  return nil unless File.exist?(file_path)

  YAML.load_file(file_path)
end

.store(file_name, object) ⇒ Object



8
9
10
11
# File 'lib/renuo/cli/services/cache.rb', line 8

def store(file_name, object)
  file_path = File.join(CACHE_DIR, "#{file_name}.yml")
  File.write(file_path, YAML.dump(object))
end

.stored_at(file_name) ⇒ Object



20
21
22
23
24
25
# File 'lib/renuo/cli/services/cache.rb', line 20

def stored_at(file_name)
  file_path = File.join(CACHE_DIR, "#{file_name}.yml")
  return nil unless File.exist?(file_path)

  File.mtime(file_path).localtime.strftime("%Y-%m-%d %H:%M")
end