Class: PuppetForgeServer::Backends::ProxyV1
- 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
- @@FILE_PATH =
'/api/v1/files'
Instance Attribute Summary collapse
-
#PRIORITY ⇒ Object
readonly
Returns the value of attribute PRIORITY.
Instance Method Summary collapse
- #get_metadata(author, name, options = {}) ⇒ Object
-
#initialize(url, cache_dir, http_client = PuppetForgeServer::Http::HttpClient.new) ⇒ ProxyV1
constructor
A new instance of ProxyV1.
- #query_metadata(query, options = {}) ⇒ Object
Methods inherited from Proxy
Constructor Details
#initialize(url, cache_dir, http_client = PuppetForgeServer::Http::HttpClient.new) ⇒ ProxyV1
Returns a new instance of ProxyV1.
28 29 30 |
# File 'lib/puppet_forge_server/backends/proxy_v1.rb', line 28 def initialize(url, cache_dir, http_client = PuppetForgeServer::Http::HttpClient.new) super(url, cache_dir, http_client, @@FILE_PATH) end |
Instance Attribute Details
#PRIORITY ⇒ Object (readonly)
Returns the value of attribute PRIORITY.
26 27 28 |
# File 'lib/puppet_forge_server/backends/proxy_v1.rb', line 26 def PRIORITY @PRIORITY end |
Instance Method Details
#get_metadata(author, name, options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/puppet_forge_server/backends/proxy_v1.rb', line 32 def (, name, = {}) = ({:with_checksum => true}).merge() query ="#{}/#{name}" begin get_modules(JSON.parse(get("/modules.json?q=#{query}")).select { |e| e['full_name'].match("#{query}") }, ) rescue => e @log.debug("#{self.class.name} failed querying metadata for '#{query}' with options #{}") @log.debug("Error: #{e}") return nil end end |
#query_metadata(query, options = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/puppet_forge_server/backends/proxy_v1.rb', line 44 def (query, = {}) = ({:with_checksum => true}).merge() begin get_modules(JSON.parse(get("/modules.json?q=#{query}")).select { |e| e['full_name'].match("*#{query}*") }, ) rescue => e @log.debug("#{self.class.name} failed querying metadata for '#{query}' with options #{}") @log.debug("Error: #{e}") return nil end end |