Sha256: 09fd308d00fdf558b1a6fd93dbc17a86eecf481c608bd9064d1e658e24adc2be

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

require 'minimart/inventory_requirement/base_requirement'

module Minimart
  module InventoryRequirement

    # This class is used to parse any Supermarket requirements specified in the inventory
    # and build Minimart::Inventory::BaseRequirements from them.
    class SupermarketRequirementsBuilder

      # @return [String] the name of the cookbook
      attr_reader :name

      # @return [Array<String>] an array of versions to fetch for this cookbook
      attr_reader :versions

      # @param [String] name The name of the cookbook
      # @param [Hash] reqs
      #   * 'versions' [Array<String>] A listing of versions to fetch.
      #   * 'version' [String] A single version to fetch.
      def initialize(name, reqs)
        @name     = name
        @versions = reqs['versions'] || reqs['version'] || []
        @versions = [@versions] if @versions.is_a? String
      end

      # Build the Supemarket requirements.
      # @return [Array<Minimart::InventoryRequirement::BaseRequirement>]
      def build
        versions.map do |v|
          InventoryRequirement::BaseRequirement.new(name, version_requirement: v)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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