Module: Shibkit::MetaMeta::Mixin::CachedDownloads::CDClassMethods

Defined in:
lib/shibkit/meta_meta/mixin/cached_downloads.rb

Overview

Class methods to mixin to including class

Instance Method Summary collapse

Instance Method Details

#init_cachesObject

Create the web cache



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/shibkit/meta_meta/mixin/cached_downloads.rb', line 84

def init_caches

  @initialised_caches ||= false

  ## Because these long class names are pain to keep typing
  config = ::Shibkit::MetaMeta.config

  unless @initialised_caches
    

    ## JIT loading of the Cache module so we can set options first
    RestClient.enable Rack::Cache, config.download_cache_options

    ## Allow user to write log of all downloads in a standard format
    if config.downloads_logger

      RestClient.enable Rack::CommonLogger, config.downloads_logger

    else

      RestClient.disable Rack::CommonLogger

    end


    @initialised_caches = true

  end
  
  ## Helps if the locations actually exist, of course.
  FileUtils.mkdir_p File.join(config.cache_root, 'meta')
  FileUtils.mkdir_p File.join(config.cache_root, 'body')
  
end