Class: PuppetLibrary::Forge::Proxy
- Inherits:
-
Object
- Object
- PuppetLibrary::Forge::Proxy
- Defined in:
- lib/puppet_library/forge/proxy.rb
Overview
A forge that proxies a remote forge.
Direct Known Subclasses
Instance Method Summary collapse
- #get_module_buffer(author, name, version) ⇒ Object
- #get_module_metadata(author, name) ⇒ Object
- #get_module_metadata_with_dependencies(author, name, version) ⇒ Object
-
#initialize(url, query_cache = PuppetLibrary::Http::Cache::InMemory.new, download_cache = PuppetLibrary::Http::Cache::NoOp.new, http_client = PuppetLibrary::Http::HttpClient.new) ⇒ Proxy
constructor
-
:url- The URL of the remote forge.
-
- #search_modules(query) ⇒ Object
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
-
:url- The URL of the remote forge.
28 29 30 31 32 33 34 35 36 |
# File 'lib/puppet_library/forge/proxy.rb', line 28 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 |
Instance Method Details
#get_module_buffer(author, name, version) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/puppet_library/forge/proxy.rb', line 44 def get_module_buffer(, name, version) begin version_info = get_module_version(, name, version) raise ModuleNotFound if version_info.nil? download_module(, name, version, version_info["file"]) rescue OpenURI::HTTPError raise ModuleNotFound end end |
#get_module_metadata(author, name) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/puppet_library/forge/proxy.rb', line 54 def (, name) begin response = get("/#{author}/#{name}.json") JSON.parse(response) rescue OpenURI::HTTPError raise ModuleNotFound end end |
#get_module_metadata_with_dependencies(author, name, version) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/puppet_library/forge/proxy.rb', line 63 def (, name, version) begin look_up_releases(, 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
38 39 40 41 42 |
# File 'lib/puppet_library/forge/proxy.rb', line 38 def search_modules(query) query_parameter = query.nil? ? "" : "?q=#{query}" results = get("/modules.json#{query_parameter}") JSON.parse results end |