class MotherBrain::Berkshelf::Lockfile

A wrapper around the berkshelf’s Berkshelf::Lockfile

Constants

BERKSFILE_LOCK

Attributes

berksfile_lock[R]

Public Class Methods

from_path(root_path) click to toggle source
# File lib/mb/berkshelf.rb, line 57
def from_path(root_path)
  new(File.join(root_path, BERKSFILE_LOCK))
end
new(berksfile_lock_path) click to toggle source
# File lib/mb/berkshelf.rb, line 64
def initialize(berksfile_lock_path)
  @berksfile_lock = ::Berkshelf::Lockfile.from_file(berksfile_lock_path)
rescue ::Berkshelf::LockfileParserError
  log.warn "Unable to parse Berksfile.lock - maybe it's an old format?"
end

Public Instance Methods

locked_versions() click to toggle source

Return a hash of all of the cookbook versions found in the Berksfile.lock The key is the name of the cookbook and the value is the version as a String. If there is no lockfile an empty hash is returned.

@return [Hash]

# File lib/mb/berkshelf.rb, line 75
def locked_versions
  berksfile_lock.graph.locks.inject({}) do |hash, (name, dependency)|
    hash[name] = dependency.locked_version.to_s
    hash
  end
end