Class: Inspec::FetcherRegistry

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

Constant Summary collapse

NON_FETCHER_KEYS =
%i{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)


15
16
17
18
19
20
21
22
# File 'lib/inspec/fetcher.rb', line 15

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

  return true unless target.respond_to?(:keys)

  !(target.keys - NON_FETCHER_KEYS).empty?
end

#resolve(target) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/inspec/fetcher.rb', line 5

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



24
25
26
# File 'lib/inspec/fetcher.rb', line 24

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