Class: Jekyll::WebmentionIO::Caches

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

Overview

The Caches class is a utility service that provides access to the cache files used by this plugin.

It is initialized with a config object and creates a folder in the configured cache folder to store the cache files.

The class is a singleton and the instance is accessed via the WebmentionIO.caches method.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Caches

Returns a new instance of Caches.



16
17
18
19
20
# File 'lib/jekyll/caches.rb', line 16

def initialize(config)
  @config = config

  FileUtils.makedirs(@config.cache_folder)
end

Class Method Details

.resetObject

Resets all singleton cache instances by clearing the class variables. This is useful for testing to ensure clean state between tests.



40
41
42
43
44
45
# File 'lib/jekyll/caches.rb', line 40

def self.reset
  @@incoming_webmentions = nil
  @@outgoing_webmentions = nil
  @@bad_uris = nil
  @@site_lookups = nil
end

Instance Method Details

#bad_urisObject



30
31
32
# File 'lib/jekyll/caches.rb', line 30

def bad_uris
  @@bad_uris ||= Cache.new(cache_file_path('bad_uris'))
end

#incoming_webmentionsObject



22
23
24
# File 'lib/jekyll/caches.rb', line 22

def incoming_webmentions
  @@incoming_webmentions ||= Cache.new(cache_file_path('incoming'))
end

#outgoing_webmentionsObject



26
27
28
# File 'lib/jekyll/caches.rb', line 26

def outgoing_webmentions
  @@outgoing_webmentions ||= Cache.new(cache_file_path('outgoing'))
end

#site_lookupsObject



34
35
36
# File 'lib/jekyll/caches.rb', line 34

def site_lookups
  @@site_lookups ||= Cache.new(cache_file_path('lookups'))
end