class Vara::Product
Constants
- METADATA_DIR
- METADATA_PARTS_DIR
Attributes
base_dir[R]
Public Class Methods
new(base_dir, options = {})
click to toggle source
# File lib/vara/product.rb, line 15 def initialize(base_dir, options = {}) @base_dir = base_dir @options = options end
Public Instance Methods
bom_path()
click to toggle source
# File lib/vara/product.rb, line 42 def bom_path "#{path}.yml" end
build()
click to toggle source
# File lib/vara/product.rb, line 24 def build if metadata.explicit_stemcell? && metadata.stemcell_criteria? raise 'binaries.yml includes both stemcell and stemcell criteria keys' end ProductArtifactZipper.new(path, ProductContents.from_metadata_path(metadata_file), @options).zip! MD5Creator.md5(path) Materials.build(metadata_file, path).save_to(bom_path) path end
md5_path()
click to toggle source
# File lib/vara/product.rb, line 46 def md5_path "#{path}.md5" end
metadata_file()
click to toggle source
# File lib/vara/product.rb, line 20 def metadata_file @metadata_file ||= find_metadata_file || raise('No metadata file found.') end
metadata_ref()
click to toggle source
# File lib/vara/product.rb, line 58 def metadata_ref `cd #{base_dir} && git log -1 --format=format:%h` end
path()
click to toggle source
# File lib/vara/product.rb, line 38 def path File.join(base_dir, "#{filename_components.join('-')}.pivotal") end
paths()
click to toggle source
# File lib/vara/product.rb, line 50 def paths [path, bom_path, md5_path] end
releases()
click to toggle source
# File lib/vara/product.rb, line 62 def releases metadata.releases_metadata.map do |release_metadata| { 'name' => release_metadata['name'], 'version' => release_metadata['version'] } end end
stemcell_version()
click to toggle source
# File lib/vara/product.rb, line 54 def stemcell_version metadata.stemcell_metadata.version end
update_product_version(new_version)
click to toggle source
# File lib/vara/product.rb, line 71 def update_product_version(new_version) metadata_hash = metadata.hash metadata_hash['product_version'] = new_version File.open(metadata_file, 'w') do |out| YAML.dump(metadata_hash, out) end end
Private Instance Methods
filename_components()
click to toggle source
# File lib/vara/product.rb, line 85 def filename_components [metadata.name, metadata.product_version] end
find_metadata_file()
click to toggle source
# File lib/vara/product.rb, line 89 def find_metadata_file files = Dir.glob(File.join(base_dir, METADATA_DIR, '*.yml')).sort case files.size when 0 then nil when 1 then files.first else raise("Found: #{files.map { |f| File.basename(f) }}. Vara supports one .yml file under metadata/") end end
metadata()
click to toggle source
# File lib/vara/product.rb, line 81 def metadata ProductMetadata.from_file(metadata_file) end