Sha256: c073f8d70618543cfb70e956a9e95a4e2e14479756c8114d16369f19115190ba

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

module MotherBrain
  # This module contains integration code for Berkshelf into motherbrain
  module Berkshelf
    class << self
      # An array of Pathnames representing cookbooks in the Berkshelf
      #
      # @option options [Boolean] :with_plugin
      #   only return cookbooks that contain a plugin
      #
      # @return [Array<Pathname>]
      def cookbooks(options = {})
        cookbooks = cookbooks_path.children

        if options[:with_plugin]
          cookbooks.select! { |cb_path| Dir.has_mb_plugin?(cb_path) }
        end

        cookbooks
      end

      # Location of the cookbooks directory in the Berkshelf
      #
      # @return [Pathname]
      def cookbooks_path
        path.join('cookbooks')
      end

      # The default location of the Berkshelf. This is in your user directory
      # unless explicitly specified by the environment variable 'BERKSHELF_PATH'
      #
      # @return [String]
      def default_path
        ENV["BERKSHELF_PATH"] || File.expand_path("~/.berkshelf")
      end

      # Create the directory structure for the Berkshelf
      def init
        FileUtils.mkdir_p(path)
        FileUtils.mkdir_p(cookbooks_path)
      end

      # The location of the Berkshelf
      #
      # @return [Pathname]
      def path
        Pathname.new(Application.config.berkshelf.path || default_path)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
motherbrain-0.14.4 lib/mb/berkshelf.rb
motherbrain-0.14.3 lib/mb/berkshelf.rb
motherbrain-0.14.2 lib/mb/berkshelf.rb
motherbrain-0.13.1 lib/mb/berkshelf.rb