Class: Tilda::Cache

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

Instance Method Summary collapse

Constructor Details

#initialize(cache_path = nil) ⇒ Cache

Returns a new instance of Cache.



3
4
5
6
7
8
# File 'lib/tilda/cache.rb', line 3

def initialize(cache_path = nil)
  @cache_path = cache_path || Config.config.cache_path
  if @cache_path.nil?
    @cache_path = defined?(Rails) ? "#{Rails.public_path}/tilda/" : "/tmp/tilda/"
  end
end

Instance Method Details

#cache_page(id) ⇒ Object



14
15
16
# File 'lib/tilda/cache.rb', line 14

def cache_page(id)

end

#clear_page(page) ⇒ Object

private



24
25
26
# File 'lib/tilda/cache.rb', line 24

def clear_page(page)
  FileUtils.rmdir(get_page_fullpath(page), noop: true, verbose: true) #TODO: really do nothing
end

#get_cached_page(id) ⇒ Object



10
11
12
# File 'lib/tilda/cache.rb', line 10

def get_cached_page(id)
  @cache_path
end

#get_page_by_idObject



18
19
20
# File 'lib/tilda/cache.rb', line 18

def get_page_by_id

end

#get_page_dirname(page) ⇒ Object



28
29
30
# File 'lib/tilda/cache.rb', line 28

def get_page_dirname(page)
  "#{page.get_html_filename}__#{page.get_published_timestamp}"
end

#get_page_fullpath(page) ⇒ Object



32
33
34
# File 'lib/tilda/cache.rb', line 32

def get_page_fullpath(page)
  "#{@cache_path}/#{get_page_dirname(page)}"
end