Class: PuppetForgeServer::Backends::ProxyV1

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

Constant Summary collapse

@@PRIORITY =

Priority should be lower than v3 API proxies as v3 requires less API calls

15

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) ⇒ ProxyV1

Returns a new instance of ProxyV1.



27
28
29
# File 'lib/puppet_forge_server/backends/proxy_v1.rb', line 27

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

Instance Attribute Details

#PRIORITYObject (readonly)

Returns the value of attribute PRIORITY.



25
26
27
# File 'lib/puppet_forge_server/backends/proxy_v1.rb', line 25

def PRIORITY
  @PRIORITY
end

Instance Method Details

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



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

def (author, name, options = {})
  options = ({:with_checksum => true}).merge(options)
  query ="#{author}/#{name}"
  begin
    (JSON.parse(get("/modules.json?q=#{query}")).select { |e| e['full_name'].match("#{query}") }, options)
  rescue => e
    @log.debug("#{self.class.name} failed querying metadata for '#{query}' with options #{options}")
    @log.debug("Error: #{e}")
    return nil
  end
end

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



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

def (query, options = {})
  options = ({:with_checksum => true}).merge(options)
  begin
    (JSON.parse(get("/modules.json?q=#{query}")).select { |e| e['full_name'].match("*#{query}*") }, options)
  rescue => e
    @log.debug("#{self.class.name} failed querying metadata for '#{query}' with options #{options}")
    @log.debug("Error: #{e}")
    return nil
  end
end