Class: PuppetLibrary::Forge::Proxy
- Inherits:
-
Forge
- Object
- Forge
- PuppetLibrary::Forge::Proxy
show all
- Defined in:
- lib/puppet_library/forge/proxy.rb
Overview
A forge that proxies a remote forge.
Usage:
forge = PuppetLibrary::Forge::Proxy.configure do
url "http://forge.example.com"
end
Direct Known Subclasses
Cache
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Forge
#prime
#debug, #info, #logger, #logs, #warn
Constructor Details
#initialize(url, query_cache = PuppetLibrary::Http::Cache::InMemory.new, download_cache = PuppetLibrary::Http::Cache::NoOp.new, http_client = PuppetLibrary::Http::HttpClient.new) ⇒ Proxy
45
46
47
48
49
50
|
# File 'lib/puppet_library/forge/proxy.rb', line 45
def initialize(url, query_cache = PuppetLibrary::Http::Cache::InMemory.new, download_cache = PuppetLibrary::Http::Cache::NoOp.new, http_client = PuppetLibrary::Http::HttpClient.new)
@url = PuppetLibrary::Http::Url.normalize(url)
@http_client = http_client
@query_cache = query_cache
@download_cache = download_cache
end
|
Class Method Details
36
37
38
39
40
41
42
|
# File 'lib/puppet_library/forge/proxy.rb', line 36
def self.configure(&block)
config_api = PuppetLibrary::Util::ConfigApi.for(Proxy) do
required :url, "URL"
end
config = config_api.configure(&block)
Proxy.new(config.get_url)
end
|
Instance Method Details
#clear_cache ⇒ Object
52
53
54
55
|
# File 'lib/puppet_library/forge/proxy.rb', line 52
def clear_cache
@query_cache.clear
@download_cache.clear
end
|
#get_module_buffer(author, name, version) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/puppet_library/forge/proxy.rb', line 63
def get_module_buffer(author, name, version)
begin
version_info = get_module_version(author, name, version)
raise ModuleNotFound if version_info.nil?
download_module(author, name, version, version_info["file"])
rescue OpenURI::HTTPError
raise ModuleNotFound
end
end
|
73
74
75
76
77
78
79
80
|
# File 'lib/puppet_library/forge/proxy.rb', line 73
def get_module_metadata(author, name)
begin
response = get("/#{author}/#{name}.json")
JSON.parse(response)
rescue OpenURI::HTTPError
raise ModuleNotFound
end
end
|
82
83
84
85
86
87
88
89
90
|
# File 'lib/puppet_library/forge/proxy.rb', line 82
def get_module_metadata_with_dependencies(author, name, version)
begin
look_up_releases(author, name, version) do |full_name, release_info|
release_info["file"] = module_path_for(full_name, release_info["version"])
end
rescue OpenURI::HTTPError
raise ModuleNotFound
end
end
|
#search_modules(query) ⇒ Object
57
58
59
60
61
|
# File 'lib/puppet_library/forge/proxy.rb', line 57
def search_modules(query)
query_parameter = query.nil? ? "" : "?q=#{query}"
results = get("/modules.json#{query_parameter}")
JSON.parse results
end
|