Class: Bosh::Director::Models::ReleaseVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/models/release_version.rb

Instance Method Summary collapse

Instance Method Details

#dependencies(package_name) ⇒ Object



14
15
16
17
18
# File 'lib/bosh/director/models/release_version.rb', line 14

def dependencies(package_name)
  package_by_name(package_name).dependency_set.map do |package_name|
    package_by_name(package_name)
  end
end

#package_by_name(package_name) ⇒ Object



20
21
22
# File 'lib/bosh/director/models/release_version.rb', line 20

def package_by_name(package_name)
  packages_by_name.fetch(package_name)
end

#package_cache_key(package_name, stemcell) ⇒ Object



32
33
34
35
36
# File 'lib/bosh/director/models/release_version.rb', line 32

def package_cache_key(package_name, stemcell)
  dependency_fingerprints = dependencies(package_name).sort_by(&:name).map {|p| p.fingerprint }
  hash_input = ([package_by_name(package_name).fingerprint, stemcell.sha1]+dependency_fingerprints).join("")
  Digest::SHA1.hexdigest(hash_input)
end

#package_dependency_key(package_name) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/bosh/director/models/release_version.rb', line 24

def package_dependency_key(package_name)
  key = dependencies(package_name).sort { |a, b|
    a.name <=> b.name
  }.map { |p| [p.name, p.version]}

  Yajl::Encoder.encode(key)
end

#validateObject



8
9
10
11
12
# File 'lib/bosh/director/models/release_version.rb', line 8

def validate
  validates_format VALID_ID, :version
  validates_presence [:release_id, :version]
  validates_unique [:release_id, :version]
end