Class: Vara::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/vara/product.rb

Constant Summary collapse

METADATA_DIR =
'metadata'.freeze
METADATA_PARTS_DIR =
'metadata_parts'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_dir, options = {}) ⇒ Product

Returns a new instance of Product.



15
16
17
18
# File 'lib/vara/product.rb', line 15

def initialize(base_dir, options = {})
  @base_dir = base_dir
  @options = options
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



13
14
15
# File 'lib/vara/product.rb', line 13

def base_dir
  @base_dir
end

Instance Method Details

#bom_pathObject



42
43
44
# File 'lib/vara/product.rb', line 42

def bom_path
  "#{path}.yml"
end

#buildObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vara/product.rb', line 24

def build
  if .explicit_stemcell? && .stemcell_criteria?
    raise 'binaries.yml includes both stemcell and stemcell criteria keys'
  end

  ProductArtifactZipper.new(path, ProductContents.(), @options).zip!

  MD5Creator.md5(path)

  Materials.build(, path).save_to(bom_path)

  path
end

#md5_pathObject



46
47
48
# File 'lib/vara/product.rb', line 46

def md5_path
  "#{path}.md5"
end

#metadata_fileObject



20
21
22
# File 'lib/vara/product.rb', line 20

def 
  @metadata_file ||=  || raise('No metadata file found.')
end

#metadata_refObject



58
59
60
# File 'lib/vara/product.rb', line 58

def 
  `cd #{base_dir} && git log -1 --format=format:%h`
end

#pathObject



38
39
40
# File 'lib/vara/product.rb', line 38

def path
  File.join(base_dir, "#{filename_components.join('-')}.pivotal")
end

#pathsObject



50
51
52
# File 'lib/vara/product.rb', line 50

def paths
  [path, bom_path, md5_path]
end

#releasesObject



62
63
64
65
66
67
68
69
# File 'lib/vara/product.rb', line 62

def releases
  ..map do ||
    {
      'name'    => ['name'],
      'version' => ['version']
    }
  end
end

#stemcell_versionObject



54
55
56
# File 'lib/vara/product.rb', line 54

def stemcell_version
  ..version
end

#update_product_version(new_version) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/vara/product.rb', line 71

def update_product_version(new_version)
   = .hash
  ['product_version'] = new_version
  File.open(, 'w') do |out|
    YAML.dump(, out)
  end
end