Sha256: 8a19e584812c98c9fdbaa88d14d981ab81680413bfa84e626ad41e272f8f4cf4

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

module KnifeCookbookDependencies
  class Lockfile
    def initialize(cookbooks)
      @cookbooks = cookbooks
    end

    def write(filename = KCD::DEFAULT_FILENAME)
      content = @cookbooks.map do |cookbook|
                  get_cookbook_definition(cookbook)
                end.join("\n")
      File.write(filename + ".lock", content)
    end

    def get_cookbook_definition(cookbook)
      definition = "cookbook '#{cookbook.name}'"

      if cookbook.from_git?
        definition += ", :git => '#{cookbook.git_repo}', :ref => '#{cookbook.git_ref || 'HEAD'}'"
      elsif cookbook.from_path?
        definition += ", :path => '#{cookbook.local_path}'"
      else
        definition += ", :locked_version => '#{cookbook.locked_version}'"
      end

      return definition
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knife_cookbook_dependencies-0.0.5 lib/kcd/lockfile.rb