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.



134
135
136
137
# File 'lib/mixlib/install/product.rb', line 134

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:



165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/mixlib/install/product.rb', line 165

def lookup(key, version = :latest)
  # return nil unless the product exists
  return nil unless @product_map.key?(key)

  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.



143
144
145
# File 'lib/mixlib/install/product.rb', line 143

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

#productsObject

Fetches the keys of available products.



151
152
153
# File 'lib/mixlib/install/product.rb', line 151

def products
  @product_map.keys
end

#products_available_on_downloads_siteObject

Looks up all products that are available on downloads.chef.io



184
185
186
187
188
# File 'lib/mixlib/install/product.rb', line 184

def products_available_on_downloads_site
  @product_map.reject do |product_key, product|
    product.downloads_product_page_url == :not_available
  end
end