Class: PuppetLibrary::Forge::Proxy
- Inherits:
-
Object
- Object
- PuppetLibrary::Forge::Proxy
- Defined in:
- lib/puppet_library/forge/proxy.rb
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
A new instance of Proxy.
- #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
Returns a new instance of Proxy.
24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet_library/forge/proxy.rb', line 24 def initialize(url, query_cache = PuppetLibrary::Http::Cache::InMemory.new, download_cache = PuppetLibrary::Http::Cache::NoOp.new, http_client = PuppetLibrary::Http::HttpClient.new) @url = url @http_client = http_client @query_cache = query_cache @download_cache = download_cache end |
Instance Method Details
#get_module_buffer(author, name, version) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/puppet_library/forge/proxy.rb', line 40 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
50 51 52 53 54 55 56 57 |
# File 'lib/puppet_library/forge/proxy.rb', line 50 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
59 60 61 62 63 64 65 66 67 |
# File 'lib/puppet_library/forge/proxy.rb', line 59 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
34 35 36 37 38 |
# File 'lib/puppet_library/forge/proxy.rb', line 34 def search_modules(query) query_parameter = query.nil? ? "" : "?q=#{query}" results = get("/modules.json#{query_parameter}") JSON.parse results end |