Class: PuppetForgeServer::Backends::ProxyV3

Inherits:
Proxy
  • Object
show all
Defined in:
lib/puppet_forge_server/backends/proxy_v3.rb

Constant Summary collapse

@@PRIORITY =
10
@@FILE_PATH =
'/v3/files'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Proxy

#get_file_buffer, #upload

Constructor Details

#initialize(url, cache_dir, http_client = PuppetForgeServer::Http::HttpClient.new) ⇒ ProxyV3

Returns a new instance of ProxyV3.



26
27
28
# File 'lib/puppet_forge_server/backends/proxy_v3.rb', line 26

def initialize(url, cache_dir, http_client = PuppetForgeServer::Http::HttpClient.new)
  super(url, cache_dir, http_client, @@FILE_PATH)
end

Instance Attribute Details

#PRIORITYObject (readonly)

Returns the value of attribute PRIORITY.



24
25
26
# File 'lib/puppet_forge_server/backends/proxy_v3.rb', line 24

def PRIORITY
  @PRIORITY
end

Instance Method Details

#get_metadata(author, name, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/puppet_forge_server/backends/proxy_v3.rb', line 30

def (author, name, options = {})
  query ="#{author}-#{name}"
  begin
    releases = get_releases(query, options)
    get_modules(releases)
  rescue => e
    @log.error("#{self.class.name} failed querying metadata for '#{query}' with options #{options}")
    @log.error("Error: #{e}")
    return nil
  end
end

#query_metadata(query, options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/puppet_forge_server/backends/proxy_v3.rb', line 42

def (query, options = {})
  begin
    releases = get_all_result_pages("/v3/modules?query=#{query}").map {|element| element['current_release']}
    get_modules(releases)
  rescue => e
    @log.error("#{self.class.name} failed querying metadata for '#{query}' with options #{options}")
    @log.error("Error: #{e}")
    return nil
  end
end