Class: Mixlib::Install::ProductMatrix
- Inherits:
-
Object
- Object
- Mixlib::Install::ProductMatrix
- Defined in:
- lib/mixlib/install/product.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ ProductMatrix
constructor
A new instance of ProductMatrix.
-
#lookup(key, version = :latest) ⇒ Product
Looks up a product and sets version on it to be used later by the Product.
-
#product(key, &block) ⇒ Object
The only DSL method of this class.
-
#products ⇒ Object
Fetches the keys of available products.
-
#products_available_on_downloads_site ⇒ Object
Looks up all products that are available on downloads.chef.io.
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.
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 |
#products ⇒ Object
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_site ⇒ Object
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 |