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.



175
176
177
178
# File 'lib/jekyll-bluesky.rb', line 175

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

Instance Method Details

#read(key) ⇒ Object



180
181
182
183
# File 'lib/jekyll-bluesky.rb', line 180

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



185
186
187
188
189
190
# File 'lib/jekyll-bluesky.rb', line 185

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