Sha256: efdb3cb0f868995fdf386efc2a6100a2e7ef2a0eec5060fe1860083e07d9d844

Contents?: true

Size: 954 Bytes

Versions: 4

Compression:

Stored size: 954 Bytes

Contents

require 'digest/sha1'
require 'fileutils'
require 'knife-solo/cookbook_manager'
require 'knife-solo/tools'

module KnifeSolo
  class Berkshelf
    include CookbookManager

    def self.gem_libraries
      %w[berkshelf]
    end

    def self.conf_file_name
      'Berksfile'
    end

    def install!
      path = berkshelf_path
      ui.msg "Installing Berkshelf cookbooks to '#{path}'..."

      berksfile = ::Berkshelf::Berksfile.from_file('Berksfile')
      if berksfile.respond_to?(:vendor)
        FileUtils.rm_rf(path)
        berksfile.vendor(path)
      else
        berksfile.install(:path => path)
      end

      path
    end

    def berkshelf_path
      KnifeSolo::Tools.config_value(config, :berkshelf_path) || default_path
    end

    def default_path
      File.join(::Berkshelf.berkshelf_path, 'knife-solo',
        Digest::SHA1.hexdigest(File.expand_path('.')))
    end

    def initial_config
      'site :opscode'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
knife-solo-0.4.3 lib/knife-solo/berkshelf.rb
knife-solo-0.4.2 lib/knife-solo/berkshelf.rb
knife-solo-0.4.1 lib/knife-solo/berkshelf.rb
knife-solo-0.4.0 lib/knife-solo/berkshelf.rb