Class: Inspec::FetcherRegistry

Inherits:
PluginRegistry show all
Defined in:
lib/inspec/fetcher.rb

Constant Summary collapse

NON_FETCHER_KEYS =
[:name, :version_constraint, :cwd, :backend, :cache, :sha256].freeze

Instance Attribute Summary

Attributes inherited from PluginRegistry

#registry

Instance Method Summary collapse

Methods inherited from PluginRegistry

#initialize

Constructor Details

This class inherits a constructor from PluginRegistry

Instance Method Details

#fetcher_specified?(target) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/inspec/fetcher.rb', line 19

def fetcher_specified?(target)
  # Only set a default for Hash-based (i.e. from
  # inspec.yml/inspec.lock) targets

  return true if !target.respond_to?(:keys)
  !(target.keys - NON_FETCHER_KEYS).empty?
end

#resolve(target) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/inspec/fetcher.rb', line 9

def resolve(target)
  if fetcher_specified?(target)
    super(target)
  else
    Inspec::Log.debug("Assuming default supermarket source for #{target}")
    super(with_default_fetcher(target))
  end
end

#with_default_fetcher(target) ⇒ Object



27
28
29
# File 'lib/inspec/fetcher.rb', line 27

def with_default_fetcher(target)
  target.merge({ supermarket: target[:name] })
end