Sha256: 06b1fc6d715e688ae8b0488e55b35d0560507bf89df299f79c0f0ed76abe778a

Contents?: true

Size: 1.07 KB

Versions: 20

Compression:

Stored size: 1.07 KB

Contents

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

require 'inspec/plugins'
require 'utils/plugin_registry'

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
      fail 'Only fetcher version 1 is supported!'
    end
    Inspec::Plugins::Fetcher
  end
end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
inspec-1.13.0 lib/inspec/fetcher.rb
inspec-1.12.0 lib/inspec/fetcher.rb
inspec-1.11.0 lib/inspec/fetcher.rb
inspec-1.10.0 lib/inspec/fetcher.rb
inspec-1.9.0 lib/inspec/fetcher.rb
inspec-1.8.0 lib/inspec/fetcher.rb
inspec-1.7.2 lib/inspec/fetcher.rb
inspec-1.7.1 lib/inspec/fetcher.rb
inspec-1.7.0 lib/inspec/fetcher.rb
inspec-1.6.0 lib/inspec/fetcher.rb
inspec-1.5.0 lib/inspec/fetcher.rb
inspec-1.4.1 lib/inspec/fetcher.rb
inspec-1.4.0 lib/inspec/fetcher.rb
inspec-1.3.0 lib/inspec/fetcher.rb
inspec-1.2.1 lib/inspec/fetcher.rb
inspec-1.2.0 lib/inspec/fetcher.rb
inspec-1.1.0 lib/inspec/fetcher.rb
inspec-1.0.0 lib/inspec/fetcher.rb
inspec-1.0.0.beta3 lib/inspec/fetcher.rb
inspec-1.0.0.beta2 lib/inspec/fetcher.rb