Sha256: b598c47e9d08c8bc3fe2ce3f37674972f88d044e1c648c49df7c3e1fba5cdaff

Contents?: true

Size: 1.74 KB

Versions: 4

Compression:

Stored size: 1.74 KB

Contents

begin
  require 'vagrant'
rescue LoadError
  raise 'The Vagrant Berkshelf plugin must be run within Vagrant.'
end

require 'fileutils'
require 'json'
require 'tmpdir'

require_relative 'vagrant/errors'
require_relative 'vagrant/version'

module Berkshelf
  class << self
    # Returns the filepath to the location Berkshelf will use for
    # storage; temp files will go here, Cookbooks will be downloaded
    # to or uploaded from here. By default this is '~/.berkshelf' but
    # can be overridden by specifying a value for the ENV variable
    # 'BERKSHELF_PATH'.
    #
    # @return [String]
    def berkshelf_path
      ENV['BERKSHELF_PATH'] || File.expand_path('~/.berkshelf')
    end
  end

  module Vagrant
    require_relative 'vagrant/chef_config'
    require_relative 'vagrant/berks_config'
    require_relative 'vagrant/action'
    require_relative 'vagrant/config'
    require_relative 'vagrant/env'
    require_relative 'vagrant/env_helpers'

    TESTED_REQUIREMENTS = [">= 1.1", "< 1.5.0"]

    class << self
      # The path to where shelfs are created on the host machine to be mounted in
      # Vagrant guests
      #
      # @return [String]
      def shelf_path
        File.join(Berkshelf.berkshelf_path, 'vagrant')
      end

      # Generate a new shelf to be mounted in a Vagrant guest
      #
      # @return [String]
      #   path to the generated shelf
      def mkshelf(machine_name = nil)
        unless File.exist?(shelf_path)
          FileUtils.mkdir_p(shelf_path)
        end

        if machine_name.nil?
          prefix_suffix = 'berkshelf-'
        else
          prefix_suffix = ['berkshelf-', "-#{machine_name}"]
        end

        Dir.mktmpdir(prefix_suffix, shelf_path)
      end
    end
  end
end

require_relative 'vagrant/plugin'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-berkshelf-3.0.1 lib/berkshelf/vagrant.rb
vagrant-berkshelf-3.0.0 lib/berkshelf/vagrant.rb
vagrant-berkshelf-3.0.0.rc2 lib/berkshelf/vagrant.rb
vagrant-berkshelf-3.0.0.rc1 lib/berkshelf/vagrant.rb