Class: Mixlib::Install::ProductMatrix

Inherits:
Object
  • Object
show all
Defined in:
lib/mixlib/install/product.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ ProductMatrix

Returns a new instance of ProductMatrix.



94
95
96
97
# File 'lib/mixlib/install/product.rb', line 94

def initialize(&block)
  @product_map = {}
  instance_eval(&block)
end

Instance Method Details

#lookup(key, version = :latest) ⇒ Product

Looks up a product and sets version on it to be used later by the Product.

Parameters:

  • key (String)

    Lookup key of the product.

  • version (String) (defaults to: :latest)

    Version to be set for the product. By default version is set to :latest

Returns:



125
126
127
128
129
130
131
132
133
# File 'lib/mixlib/install/product.rb', line 125

def lookup(key, version = :latest)
  product = @product_map[key]
  # We set the lookup version for the product to a very high number in
  # order to mimic :latest so that one does not need to handle this
  # symbol explicitly when constructing logic based on version numbers.
  version = "1000.1000.1000" if version.to_sym == :latest
  product.version(version)
  product
end

#product(key, &block) ⇒ Object

The only DSL method of this class. It creates a Product with given ‘key` and stores it.



103
104
105
# File 'lib/mixlib/install/product.rb', line 103

def product(key, &block)
  @product_map[key] = Product.new(&block)
end

#productsObject

Fetches the keys of available products.



111
112
113
# File 'lib/mixlib/install/product.rb', line 111

def products
  @product_map.keys
end