Class: Supermarket::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/bundles/inspec-supermarket/target.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resolve(target, opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bundles/inspec-supermarket/target.rb', line 11

def self.resolve(target, opts = {})
  supermarket_url = opts["supermarket_url"] || Supermarket::API::SUPERMARKET_URL
  supermarket_uri, supermarket_server = if target.is_a?(String) && URI(target).scheme == "supermarket"
                                          [target, supermarket_url]
                                        elsif target.respond_to?(:key?) && target.key?(:supermarket)
                                          supermarket_server = target[:supermarket_url] || supermarket_url
                                          ["supermarket://#{target[:supermarket]}", supermarket_server]
                                        end
  return nil unless supermarket_uri
  return nil unless Supermarket::API.exist?(supermarket_uri, supermarket_server)

  tool_info = Supermarket::API.find(supermarket_uri, supermarket_server)
  resolve_next(tool_info["tool_source_url"], opts)
rescue URI::Error
  nil
end

Instance Method Details

#to_sObject



28
29
30
# File 'lib/bundles/inspec-supermarket/target.rb', line 28

def to_s
  "Chef Compliance Profile Loader"
end