Sha256: f60dde59e16b8f9355d366793d4a85cd31e9baa4bb8cdbe190050f064c3bb472

Contents?: true

Size: 1.05 KB

Versions: 34

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8
# author: Dominik Richter
# author: Christoph Hartmann

require 'inspec/plugin/v1'

module Inspec
  class FetcherRegistry < PluginRegistry
    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

    NON_FETCHER_KEYS = [:name, :version_constraint, :cwd, :backend, :cache, :sha256].freeze
    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

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

  Fetcher = FetcherRegistry.new

  def self.fetcher(version)
    if version != 1
      raise 'Only fetcher version 1 is supported!'
    end
    Inspec::Plugins::Fetcher
  end
end

require 'fetchers/local'
require 'fetchers/url'
require 'fetchers/git'

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
inspec-core-2.3.28 lib/inspec/fetcher.rb
inspec-2.3.28 lib/inspec/fetcher.rb
inspec-core-3.0.46 lib/inspec/fetcher.rb
inspec-3.0.46 lib/inspec/fetcher.rb
inspec-core-3.0.25 lib/inspec/fetcher.rb
inspec-3.0.25 lib/inspec/fetcher.rb
inspec-core-3.0.12 lib/inspec/fetcher.rb
inspec-3.0.12 lib/inspec/fetcher.rb
inspec-core-3.0.9 lib/inspec/fetcher.rb
inspec-3.0.9 lib/inspec/fetcher.rb
inspec-core-3.0.0 lib/inspec/fetcher.rb
inspec-3.0.0 lib/inspec/fetcher.rb
inspec-core-2.3.24 lib/inspec/fetcher.rb
inspec-2.3.24 lib/inspec/fetcher.rb
inspec-core-2.3.23 lib/inspec/fetcher.rb
inspec-2.3.23 lib/inspec/fetcher.rb
inspec-core-2.3.10 lib/inspec/fetcher.rb
inspec-2.3.10 lib/inspec/fetcher.rb
inspec-core-2.3.5 lib/inspec/fetcher.rb
inspec-2.3.5 lib/inspec/fetcher.rb