class Vara::ProductMetadata

“Struct” representing the information in metadata/<product_name>.yml

Attributes

hash[R]

Public Class Methods

from_file(metadata_path) click to toggle source

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
new(hash) click to toggle source

@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

compiled_packages_file() click to toggle source

@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
compiled_packages_metadata() click to toggle source

@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
explicit_stemcell?() click to toggle source
# File lib/vara/product_metadata.rb, line 24
def explicit_stemcell?
  hash.key? 'stemcell'
end
has_compiled_packages?() click to toggle source

@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
name() click to toggle source

@return [String] the name of the product

# File lib/vara/product_metadata.rb, line 70
def name
  hash.fetch('name')
end
product_version() click to toggle source

@return [String] the version of the product

# File lib/vara/product_metadata.rb, line 75
def product_version
  hash.fetch('product_version')
end
releases_metadata() click to toggle source

@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
stemcell_criteria() click to toggle source
# File lib/vara/product_metadata.rb, line 28
def stemcell_criteria
  return nil if explicit_stemcell?
  hash.fetch('stemcell_criteria')
end
stemcell_criteria?() click to toggle source
# File lib/vara/product_metadata.rb, line 33
def stemcell_criteria?
  hash.key? 'stemcell_criteria'
end
stemcell_file() click to toggle source

@return [String] the filename of the stemcell

# File lib/vara/product_metadata.rb, line 65
def stemcell_file
  stemcell_metadata.basename
end
stemcell_metadata() click to toggle source

@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

release_metadata(release_hash) click to toggle source

@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