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.



112
113
114
115
# File 'lib/jekyll-bluesky.rb', line 112

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

Instance Method Details

#read(key) ⇒ Object



117
118
119
120
# File 'lib/jekyll-bluesky.rb', line 117

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



122
123
124
125
126
127
# File 'lib/jekyll-bluesky.rb', line 122

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