supermarket tools get and filter by tool_type (#1254)

Signed-off-by: Alex Pop <apop@chef.io>
This commit is contained in:
Alex Pop 2016-10-26 14:42:43 +01:00 committed by Christoph Hartmann
parent 755f24ed6f
commit d40ee684f8

View file

@ -11,11 +11,11 @@ module Supermarket
# displays a list of profiles # displays a list of profiles
def self.profiles(supermarket_url = SUPERMARKET_URL) def self.profiles(supermarket_url = SUPERMARKET_URL)
url = "#{supermarket_url}/api/v1/tools-search" url = "#{supermarket_url}/api/v1/tools"
_success, data = get(url, { q: 'compliance_profile' }) _success, data = get(url, { start: 0, items: 100, order: 'recently_added' })
if !data.nil? if !data.nil?
profiles = JSON.parse(data) profiles = JSON.parse(data)
profiles['items'].map { |x| profiles['items'].select { |p| p['tool_type'] == 'compliance_profile' }.map { |x|
m = %r{^#{supermarket_url}/api/v1/tools/(?<slug>[\w-]+)(/)?$}.match(x['tool']) m = %r{^#{supermarket_url}/api/v1/tools/(?<slug>[\w-]+)(/)?$}.match(x['tool'])
x['slug'] = m[:slug] x['slug'] = m[:slug]
x x