Class: Jekyll::FileCache

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll_bluesky.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileCache

Returns a new instance of FileCache.



107
108
109
110
# File 'lib/jekyll_bluesky.rb', line 107

def initialize(path)
  @cache_folder = File.expand_path path
  FileUtils.mkdir_p @cache_folder
end

Instance Method Details

#read(key) ⇒ Object



112
113
114
115
# File 'lib/jekyll_bluesky.rb', line 112

def read(key)
  file_to_read = cache_file(key)
  File.read(file_to_read) if File.exist?(file_to_read)
end

#write(key, data) ⇒ Object



117
118
119
120
121
122
# File 'lib/jekyll_bluesky.rb', line 117

def write(key, data)
  file_to_write = cache_file(key)
  File.open(file_to_write, "w") do |f|
    f.write(data)
  end
end