Sha256: efe2391816ce6f535e8ec3646c9ef3917ae34af623c13d9f6671b4dccc810dad

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

module Minimart
  module Mirror
    # A collection of Minimart::Mirror::Source
    class Sources < Array

      # @param [Array<String>] source_urls An array of source URL's specified in the inventory
      def initialize(source_urls = [])
        source_urls.each { |source_url| add_source(source_url) }
      end

      # Iterate over each cookbook defined in each source
      # @yield [Minimart::Mirror::SourceCookbook]
      def each_cookbook(&block)
        each { |source| source.cookbooks.each(&block) }
      end

      # Find the first cookbook from the avaiable sources with a matching name, and
      # version
      # @param [String] name The name of the cookbook to search for
      # @param [String] version The version of the cookbook to search for
      def find_cookbook(name, version)
        each do |source|
          cookbook = source.find_cookbook(name, version)
          return cookbook if cookbook
        end

        raise Error::CookbookNotFound, "The cookbook #{name} with the version #{version} could not be found"
      end

      private

      def add_source(source_url)
        self << Source.new(source_url)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
minimart-1.2.5 lib/minimart/mirror/sources.rb
minimart-1.2.4 lib/minimart/mirror/sources.rb
minimart-1.2.3 lib/minimart/mirror/sources.rb
minimart-1.2.0 lib/minimart/mirror/sources.rb
minimart-1.1.6 lib/minimart/mirror/sources.rb
minimart-1.1.3 lib/minimart/mirror/sources.rb
minimart-1.0.2 lib/minimart/mirror/sources.rb
minimart-1.0.1 lib/minimart/mirror/sources.rb
minimart-0.0.1 lib/minimart/mirror/sources.rb