module MotherBrain::Berkshelf

This module contains integration code for Berkshelf into motherbrain

Public Class Methods

cookbooks(options = {}) click to toggle source

An array of Pathnames representing cookbooks in the Berkshelf

@option options [Boolean] :with_plugin

only return cookbooks that contain a plugin

@return [Array<Pathname>]

# File lib/mb/berkshelf.rb, line 11
def cookbooks(options = {})
  cookbooks = cookbooks_path.children

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

  cookbooks
end
cookbooks_path() click to toggle source

Location of the cookbooks directory in the Berkshelf

@return [Pathname]

# File lib/mb/berkshelf.rb, line 24
def cookbooks_path
  path.join('cookbooks')
end
default_path() click to toggle source

The default location of the Berkshelf. This is in your user directory unless explicitly specified by the environment variable ‘BERKSHELF_PATH’

@return [String]

# File lib/mb/berkshelf.rb, line 32
def default_path
  ENV["BERKSHELF_PATH"] || File.expand_path("~/.berkshelf")
end
init() click to toggle source

Create the directory structure for the Berkshelf

# File lib/mb/berkshelf.rb, line 37
def init
  FileUtils.mkdir_p(path)
  FileUtils.mkdir_p(cookbooks_path)
end
path() click to toggle source

The location of the Berkshelf

@return [Pathname]

# File lib/mb/berkshelf.rb, line 45
def path
  Pathname.new(Application.config.berkshelf.path || default_path)
end