Class: Vara::ProductMetadata
- Inherits:
-
Object
- Object
- Vara::ProductMetadata
- Defined in:
- lib/vara/product_metadata.rb
Overview
“Struct” representing the information in metadata/<product_name>.yml
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Class Method Summary collapse
-
.from_file(metadata_path) ⇒ Vara::ProductMetadata
Build a ProductMetadata from a metadata.yml on disk.
Instance Method Summary collapse
-
#compiled_packages_file ⇒ String
The filename of the compiled packages.
-
#compiled_packages_metadata ⇒ Vara::Metadata::CompiledPackages
The compiled packages metadata contained in this ProductMetadata.
- #explicit_stemcell? ⇒ Boolean
-
#has_compiled_packages? ⇒ Boolean
Whether the compiled packages field is present.
-
#initialize(hash) ⇒ ProductMetadata
constructor
A new instance of ProductMetadata.
-
#name ⇒ String
The name of the product.
-
#product_version ⇒ String
The version of the product.
-
#releases_metadata ⇒ <Vara::Metadata::Release>
The releases metadata contained in this ProductMetadata.
- #stemcell_criteria ⇒ Object
- #stemcell_criteria? ⇒ Boolean
-
#stemcell_file ⇒ String
The filename of the stemcell.
-
#stemcell_metadata ⇒ Vara::Metadata::Stemcell
The stemcell metadata contained in this ProductMetadata.
Constructor Details
#initialize(hash) ⇒ ProductMetadata
Returns a new instance of ProductMetadata.
20 21 22 |
# File 'lib/vara/product_metadata.rb', line 20 def initialize(hash) @hash = hash end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
10 11 12 |
# File 'lib/vara/product_metadata.rb', line 10 def hash @hash end |
Class Method Details
.from_file(metadata_path) ⇒ Vara::ProductMetadata
Build a ProductMetadata from a metadata.yml on disk
15 16 17 |
# File 'lib/vara/product_metadata.rb', line 15 def self.from_file() new(YAML.load_file()) end |
Instance Method Details
#compiled_packages_file ⇒ String
Returns the filename of the compiled packages.
80 81 82 |
# File 'lib/vara/product_metadata.rb', line 80 def compiled_packages_file .basename end |
#compiled_packages_metadata ⇒ Vara::Metadata::CompiledPackages
Returns the compiled packages metadata contained in this ProductMetadata.
57 58 59 60 61 62 |
# File 'lib/vara/product_metadata.rb', line 57 def 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? ⇒ Boolean
24 25 26 |
# File 'lib/vara/product_metadata.rb', line 24 def explicit_stemcell? hash.key? 'stemcell' end |
#has_compiled_packages? ⇒ Boolean
Returns whether the compiled packages field is present.
85 86 87 |
# File 'lib/vara/product_metadata.rb', line 85 def has_compiled_packages? hash.key?('compiled_package') end |
#name ⇒ String
Returns the name of the product.
70 71 72 |
# File 'lib/vara/product_metadata.rb', line 70 def name hash.fetch('name') end |
#product_version ⇒ String
Returns the version of the product.
75 76 77 |
# File 'lib/vara/product_metadata.rb', line 75 def product_version hash.fetch('product_version') end |
#releases_metadata ⇒ <Vara::Metadata::Release>
Returns the releases metadata contained in this ProductMetadata.
50 51 52 53 |
# File 'lib/vara/product_metadata.rb', line 50 def releases = hash.fetch('releases') releases.map { |release| (release) } end |
#stemcell_criteria ⇒ Object
28 29 30 31 |
# File 'lib/vara/product_metadata.rb', line 28 def stemcell_criteria return nil if explicit_stemcell? hash.fetch('stemcell_criteria') end |
#stemcell_criteria? ⇒ Boolean
33 34 35 |
# File 'lib/vara/product_metadata.rb', line 33 def stemcell_criteria? hash.key? 'stemcell_criteria' end |
#stemcell_file ⇒ String
Returns the filename of the stemcell.
65 66 67 |
# File 'lib/vara/product_metadata.rb', line 65 def stemcell_file .basename end |
#stemcell_metadata ⇒ Vara::Metadata::Stemcell
Returns the stemcell metadata contained in this ProductMetadata.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vara/product_metadata.rb', line 38 def 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 |