Class: PuppetLibrary::Forge::Proxy
- Inherits:
-
Object
- Object
- PuppetLibrary::Forge::Proxy
- Defined in:
- lib/puppet_library/forge/proxy.rb
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.
25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet_library/forge/proxy.rb', line 25 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
41 42 43 44 45 46 47 48 49 |
# File 'lib/puppet_library/forge/proxy.rb', line 41 def get_module_buffer(, name, version) begin version_info = get_module_version(, name, version) raise ModuleNotFound if version_info.nil? download_file(version_info["file"]) rescue OpenURI::HTTPError raise ModuleNotFound end end |
#get_module_metadata(author, name) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/puppet_library/forge/proxy.rb', line 51 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
60 61 62 63 64 65 66 |
# File 'lib/puppet_library/forge/proxy.rb', line 60 def (, name, version) begin look_up_releases(, name, version) rescue OpenURI::HTTPError raise ModuleNotFound end end |
#search_modules(query) ⇒ Object
35 36 37 38 39 |
# File 'lib/puppet_library/forge/proxy.rb', line 35 def search_modules(query) query_parameter = query.nil? ? "" : "?q=#{query}" results = get("/modules.json#{query_parameter}") JSON.parse results end |