Class: PuppetLibrary::Forge::Cache

Inherits:
Proxy show all
Defined in:
lib/puppet_library/forge/cache.rb

Overview

A forge that proxies a remote forge. All module archives downloaded from the remote forged are cached to disk.

Usage:

forge = PuppetLibrary::Forge::Cache.configure do
    # The URL of the remote forge
    url "http://forge.example.com"

    # The path to cache the files to on disk
    path "/var/modules/cache"
end

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Proxy

#clear_cache, #get_module_buffer, #get_module_metadata, #get_module_metadata_with_dependencies, #search_modules

Methods inherited from Forge

#clear_cache, #prime

Methods included from Util::Logging

#debug, #info, #logger, #logs, #warn

Constructor Details

#initialize(url, cache_dir, http_client = PuppetLibrary::Http::HttpClient.new) ⇒ Cache

  • :url - The URL of the remote forge.

  • :cache_dir - The directory in which to cache the downloaded artifacts.



51
52
53
# File 'lib/puppet_library/forge/cache.rb', line 51

def initialize(url, cache_dir, http_client = PuppetLibrary::Http::HttpClient.new)
    super(url, PuppetLibrary::Http::Cache::InMemory.new, PuppetLibrary::Http::Cache::Disk.new(cache_dir), http_client)
end

Class Method Details

.configure(&block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/puppet_library/forge/cache.rb', line 38

def self.configure(&block)
    config_api = PuppetLibrary::Util::ConfigApi.for(Cache) do
        required :url, "URL"
        required :path, "path" do |path|
            Dir.new(path)
        end
    end
    config = config_api.configure(&block)
    Cache.new(config.get_url, config.get_path)
end