class Vara::ProductMetadata
“Struct” representing the information in metadata/<product_name>.yml
Attributes
Public Class Methods
Build a ProductMetadata
from a metadata.yml on disk @param metadata_path Path to the product metadata file on disk @return [Vara::ProductMetadata]
# File lib/vara/product_metadata.rb, line 15 def self.from_file(metadata_path) new(YAML.load_file(metadata_path)) end
@param hash [Hash] the hash representing the product metadata
# File lib/vara/product_metadata.rb, line 20 def initialize(hash) @hash = hash end
Public Instance Methods
@return [String] the filename of the compiled packages
# File lib/vara/product_metadata.rb, line 80 def compiled_packages_file compiled_packages_metadata.basename end
@raise [KeyNotFoundError] if this ProductMetadata
does not contain compiled packages @return [Vara::Metadata::CompiledPackages] the compiled packages metadata contained in this ProductMetadata
# File lib/vara/product_metadata.rb, line 57 def compiled_packages_metadata c = hash.fetch('compiled_package') Metadata::CompiledPackages.new( c.fetch('name'), c.fetch('version'), c.fetch('file'), c.fetch('md5'), c.fetch('url', nil) ) end
# File lib/vara/product_metadata.rb, line 24 def explicit_stemcell? hash.key? 'stemcell' end
@return [Boolean] whether the compiled packages field is present
# File lib/vara/product_metadata.rb, line 85 def has_compiled_packages? hash.key?('compiled_package') end
@return [String] the name of the product
# File lib/vara/product_metadata.rb, line 70 def name hash.fetch('name') end
@return [String] the version of the product
# File lib/vara/product_metadata.rb, line 75 def product_version hash.fetch('product_version') end
@return [<Vara::Metadata::Release>] the releases metadata contained in this ProductMetadata
# File lib/vara/product_metadata.rb, line 50 def releases_metadata releases = hash.fetch('releases') releases.map { |release| release_metadata(release) } end
# File lib/vara/product_metadata.rb, line 28 def stemcell_criteria return nil if explicit_stemcell? hash.fetch('stemcell_criteria') end
# File lib/vara/product_metadata.rb, line 33 def stemcell_criteria? hash.key? 'stemcell_criteria' end
@return [String] the filename of the stemcell
# File lib/vara/product_metadata.rb, line 65 def stemcell_file stemcell_metadata.basename end
@return [Vara::Metadata::Stemcell] the stemcell metadata contained in this ProductMetadata
# File lib/vara/product_metadata.rb, line 38 def stemcell_metadata stemcell = hash.fetch('stemcell') Metadata::Stemcell.new( name: stemcell.fetch('name'), version: stemcell.fetch('version'), file: stemcell.fetch('file'), md5: stemcell.fetch('md5', nil), sha1: stemcell.fetch('sha1', nil) ) end
Private Instance Methods
@return [Vara::Metadata::Release]
# File lib/vara/product_metadata.rb, line 92 def release_metadata(release_hash) release = release_hash Metadata::Release.new( name: release.fetch('name'), version: release.fetch('version'), file: release.fetch('file'), md5: release.fetch('md5', nil), sha1: release.fetch('sha1', nil), url: release.fetch('url', nil), aws: release.fetch('aws', nil) ) end